diff options
| -rw-r--r-- | sys/dev/i2c/dstemp.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/sys/dev/i2c/dstemp.c b/sys/dev/i2c/dstemp.c index 8db74c7b579..40b2a1ac2c0 100644 --- a/sys/dev/i2c/dstemp.c +++ b/sys/dev/i2c/dstemp.c @@ -1,4 +1,4 @@ -/* $NetBSD: dstemp.c,v 1.5 2020/02/28 13:18:25 macallan Exp $ */ +/* $NetBSD: dstemp.c,v 1.6 2020/08/21 21:28:22 macallan Exp $ */ /*- * Copyright (c) 2018 Michael Lorenz @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dstemp.c,v 1.5 2020/02/28 13:18:25 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dstemp.c,v 1.6 2020/08/21 21:28:22 macallan Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -39,14 +39,6 @@ __KERNEL_RCSID(0, "$NetBSD: dstemp.c,v 1.5 2020/02/28 13:18:25 macallan Exp $"); #include <dev/sysmon/sysmonvar.h> -#ifdef macppc -#define HAVE_OF 1 -#endif - -#ifdef HAVE_OF -#include <dev/ofw/openfirm.h> -#endif - #define DSTEMP_CMD_START 0x51 /* command, no data */ #define DSTEMP_CMD_POR 0x54 /* command, no data */ #define DSTEMP_CMD_STOP 0x22 /* command, no data */ @@ -68,12 +60,12 @@ __KERNEL_RCSID(0, "$NetBSD: dstemp.c,v 1.5 2020/02/28 13:18:25 macallan Exp $"); #define DSTEMP_DONE 0x80 struct dstemp_softc { - device_t sc_dev; - i2c_tag_t sc_i2c; - i2c_addr_t sc_addr; - - struct sysmon_envsys *sc_sme; - envsys_data_t sc_sensor_temp; + device_t sc_dev; + i2c_tag_t sc_i2c; + i2c_addr_t sc_addr; + prop_dictionary_t sc_prop; + struct sysmon_envsys *sc_sme; + envsys_data_t sc_sensor_temp; }; static int dstemp_match(device_t, cfdata_t, void *); @@ -111,10 +103,12 @@ dstemp_attach(device_t parent, device_t self, void *aux) struct dstemp_softc *sc = device_private(self); struct i2c_attach_args *ia = aux; char name[64] = "temperature"; + const char *desc; sc->sc_dev = self; sc->sc_i2c = ia->ia_tag; sc->sc_addr = ia->ia_addr; + sc->sc_prop = ia->ia_prop; aprint_naive("\n"); aprint_normal(": DS1361\n"); @@ -128,13 +122,13 @@ dstemp_attach(device_t parent, device_t self, void *aux) sc->sc_sensor_temp.units = ENVSYS_STEMP; sc->sc_sensor_temp.state = ENVSYS_SINVALID; -#ifdef HAVE_OF - int ch; - ch = OF_child(ia->ia_cookie); - if (ch != 0) { - OF_getprop(ch, "location", name, 64); + + if (prop_dictionary_get_cstring_nocopy(sc->sc_prop, "s00", &desc)) { + strncpy(name, desc, 64); + } else if (prop_dictionary_get_cstring_nocopy(sc->sc_prop, "saa", &desc)) { + strncpy(name, desc, 64); } -#endif + strncpy(sc->sc_sensor_temp.desc, name, sizeof(sc->sc_sensor_temp.desc)); sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor_temp); |
