Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/i2c Use iic_compatible_lookup() in admtemp_setflags().
details: https://anonhg.NetBSD.org/src/rev/150904f523d4
branches: trunk
changeset: 950408:150904f523d4
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Jan 28 14:35:11 2021 +0000
description:
Use iic_compatible_lookup() in admtemp_setflags().
diffstat:
sys/dev/i2c/adm1021.c | 73 +++++++++++++++++++++++++++++++++-----------------
1 files changed, 48 insertions(+), 25 deletions(-)
diffs (109 lines):
diff -r aee8fe047519 -r 150904f523d4 sys/dev/i2c/adm1021.c
--- a/sys/dev/i2c/adm1021.c Thu Jan 28 11:45:31 2021 +0000
+++ b/sys/dev/i2c/adm1021.c Thu Jan 28 14:35:11 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: adm1021.c,v 1.25 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: adm1021.c,v 1.26 2021/01/28 14:35:11 thorpej Exp $ */
/* $OpenBSD: adm1021.c,v 1.27 2007/06/24 05:34:35 dlg Exp $ */
/*
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.25 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.26 2021/01/28 14:35:11 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -143,11 +143,42 @@
CFATTACH_DECL_NEW(admtemp, sizeof(struct admtemp_softc),
admtemp_match, admtemp_attach, NULL, NULL);
-/* XXX: add flags for compats to admtemp_setflags() */
+struct admtemp_params {
+ const char *name;
+ int noneg;
+ int nolow;
+ int ext11;
+ int therm;
+};
+
+static const struct admtemp_params admtemp_params_max1617 = {
+ .name = "MAX1617A",
+ .noneg = 0,
+ .nolow = 0,
+ .ext11 = 0,
+ .therm = 0,
+};
+
+static const struct admtemp_params admtemp_params_max6642 = {
+ .name = "MAX6642",
+ .noneg = 0,
+ .nolow = 1,
+ .ext11 = 0,
+ .therm = 0,
+};
+
+static const struct admtemp_params admtemp_params_max6690 = {
+ .name = "MAX6690",
+ .noneg = 0,
+ .nolow = 0,
+ .ext11 = 1,
+ .therm = 0,
+};
+
static const struct device_compatible_entry compat_data[] = {
- { .compat = "i2c-max1617" },
- { .compat = "max6642" },
- { .compat = "max6690" },
+ { .compat = "i2c-max1617", .data = &admtemp_params_max1617 },
+ { .compat = "max6642", .data = &admtemp_params_max6642 },
+ { .compat = "max6690", .data = &admtemp_params_max6690 },
DEVICE_COMPAT_EOL
};
@@ -203,7 +234,6 @@
uint8_t* comp, uint8_t *rev, char* name)
{
uint8_t cmd, data, tmp;
- int i;
*comp = 0;
*rev = 0;
@@ -220,24 +250,17 @@
sc->sc_therm = 0;
/* Direct config */
- for (i = 0; i < ia->ia_ncompat; i++) {
- if (strcmp("i2c-max1617", ia->ia_compat[i]) == 0) {
- sc->sc_noneg = 0;
- strlcpy(name, "MAX1617A", ADMTEMP_NAMELEN);
- return;
- }
- if (strcmp("max6642", ia->ia_compat[i]) == 0) {
- sc->sc_noneg = 0;
- sc->sc_nolow = 1;
- strlcpy(name, "MAX6642", ADMTEMP_NAMELEN);
- return;
- }
- if (strcmp("max6690", ia->ia_compat[i]) == 0) {
- sc->sc_noneg = 0;
- sc->sc_ext11 = 1;
- strlcpy(name, "MAX6690", ADMTEMP_NAMELEN);
- return;
- }
+ const struct device_compatible_entry *dce =
+ iic_compatible_lookup(ia, compat_data);
+ if (dce != NULL) {
+ const struct admtemp_params *params = dce->data;
+
+ sc->sc_noneg = params->noneg;
+ sc->sc_nolow = params->nolow;
+ sc->sc_ext11 = params->ext11;
+ sc->sc_therm = params->therm;
+ strlcpy(name, params->name, ADMTEMP_NAMELEN);
+ return;
}
/* Indirect config */
Home |
Main Index |
Thread Index |
Old Index