Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c get sensore names from properties, remove OF code



details:   https://anonhg.NetBSD.org/src/rev/99a62e9d5b1e
branches:  trunk
changeset: 942890:99a62e9d5b1e
user:      macallan <macallan%NetBSD.org@localhost>
date:      Fri Aug 21 20:44:38 2020 +0000

description:
get sensore names from properties, remove OF code

diffstat:

 sys/dev/i2c/adm1021.c |  48 +++++++++++++++++-------------------------------
 1 files changed, 17 insertions(+), 31 deletions(-)

diffs (96 lines):

diff -r 105c9bbacd3c -r 99a62e9d5b1e sys/dev/i2c/adm1021.c
--- a/sys/dev/i2c/adm1021.c     Fri Aug 21 20:41:43 2020 +0000
+++ b/sys/dev/i2c/adm1021.c     Fri Aug 21 20:44:38 2020 +0000
@@ -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 @@
 
 #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 @@
 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 @@
        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 @@
        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])) {



Home | Main Index | Thread Index | Old Index