Module Name:    src
Committed By:   macallan
Date:           Fri Aug 21 20:44:38 UTC 2020

Modified Files:
        src/sys/dev/i2c: adm1021.c

Log Message:
get sensore names from properties, remove OF code


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/i2c/adm1021.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/adm1021.c
diff -u src/sys/dev/i2c/adm1021.c:1.19 src/sys/dev/i2c/adm1021.c:1.20
--- src/sys/dev/i2c/adm1021.c:1.19	Tue Jun 26 06:03:57 2018
+++ src/sys/dev/i2c/adm1021.c	Fri Aug 21 20:44:38 2020
@@ -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 
 
 #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 
 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
 	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
 	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])) {

Reply via email to