diff options
| author | macallan <macallan@NetBSD.org> | 2020-08-21 20:44:38 +0000 |
|---|---|---|
| committer | macallan <macallan@NetBSD.org> | 2020-08-21 20:44:38 +0000 |
| commit | 17486bff7778238999fbd4dd97dc4ab0a8cb862b (patch) | |
| tree | 410156efbbc669b9c39aabb5ce52043cf4202eb1 /sys/dev | |
| parent | 4c3cf556e7cce1f0b287066081b7431b7535f28d (diff) | |
get sensore names from properties, remove OF code
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/i2c/adm1021.c | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/sys/dev/i2c/adm1021.c b/sys/dev/i2c/adm1021.c index 1ce64f5400e..64bdc7f9d04 100644 --- a/sys/dev/i2c/adm1021.c +++ b/sys/dev/i2c/adm1021.c @@ -1,4 +1,4 @@ -/* $NetBSD: adm1021.c,v 1.19 2018/06/26 06:03:57 thorpej Exp $ */ +/* $NetBSD: adm1021.c,v 1.20 2020/08/21 20:44:38 macallan 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.19 2018/06/26 06:03:57 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.20 2020/08/21 20:44:38 macallan Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -47,14 +47,6 @@ __KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.19 2018/06/26 06:03:57 thorpej Exp $") #include <dev/i2c/i2cvar.h> -#ifdef macppc -#define HAVE_OF 1 -#endif - -#ifdef HAVE_OF -#include <dev/ofw/openfirm.h> -#endif - /* Registers */ #define ADM1021_INT_TEMP 0x00 /* Internal temperature value */ #define ADM1021_EXT_TEMP 0x01 /* External temperature value */ @@ -118,6 +110,7 @@ __KERNEL_RCSID(0, "$NetBSD: adm1021.c,v 1.19 2018/06/26 06:03:57 thorpej Exp $") struct admtemp_softc { i2c_tag_t sc_tag; i2c_addr_t sc_addr; + prop_dictionary_t sc_prop; int sc_flags; int sc_noexternal, sc_noneg, sc_nolow; @@ -320,12 +313,12 @@ admtemp_attach(device_t parent, device_t self, void *aux) struct i2c_attach_args *ia = aux; uint8_t cmd, data, stat, comp, rev; char name[ADMTEMP_NAMELEN]; -#ifdef HAVE_OF - char ename[64], iname[64]; - int ch; -#endif + char ename[64] = "external", iname[64] = "internal"; + const char *desc; + sc->sc_tag = ia->ia_tag; sc->sc_addr = ia->ia_addr; + sc->sc_prop = ia->ia_prop; iic_acquire_bus(sc->sc_tag, 0); cmd = ADM1021_CONFIG_READ; @@ -385,27 +378,20 @@ admtemp_attach(device_t parent, device_t self, void *aux) sc->sc_sensor[ADMTEMP_EXT].units = ENVSYS_STEMP; sc->sc_sensor[ADMTEMP_INT].flags = ENVSYS_FMONLIMITS; sc->sc_sensor[ADMTEMP_EXT].flags = ENVSYS_FMONLIMITS; -#ifdef HAVE_OF - strcpy(iname, "internal"); - strcpy(ename, "external"); - ch = OF_child(ia->ia_cookie); - if (ch != 0) { - OF_getprop(ch, "location", iname, 64); - ch = OF_peer(ch); - if (ch != 0) { - OF_getprop(ch, "location", ename, 64); - } - } + + if (prop_dictionary_get_cstring_nocopy(sc->sc_prop, "s00", &desc)) { + strncpy(iname, desc, 64); + } + + if (prop_dictionary_get_cstring_nocopy(sc->sc_prop, "s01", &desc)) { + strncpy(ename, desc, 64); + } + strlcpy(sc->sc_sensor[ADMTEMP_INT].desc, iname, sizeof(sc->sc_sensor[ADMTEMP_INT].desc)); strlcpy(sc->sc_sensor[ADMTEMP_EXT].desc, ename, sizeof(sc->sc_sensor[ADMTEMP_EXT].desc)); -#else - strlcpy(sc->sc_sensor[ADMTEMP_INT].desc, "internal", - sizeof(sc->sc_sensor[ADMTEMP_INT].desc)); - strlcpy(sc->sc_sensor[ADMTEMP_EXT].desc, "external", - sizeof(sc->sc_sensor[ADMTEMP_EXT].desc)); -#endif + sc->sc_sme = sysmon_envsys_create(); if (sysmon_envsys_sensor_attach( sc->sc_sme, &sc->sc_sensor[ADMTEMP_INT])) { |
