Module Name:    src
Committed By:   macallan
Date:           Fri Aug 21 21:28:22 UTC 2020

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

Log Message:
more OF -> properties for sensor names, this should be the last one


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/dstemp.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/dstemp.c
diff -u src/sys/dev/i2c/dstemp.c:1.5 src/sys/dev/i2c/dstemp.c:1.6
--- src/sys/dev/i2c/dstemp.c:1.5	Fri Feb 28 13:18:25 2020
+++ src/sys/dev/i2c/dstemp.c	Fri Aug 21 21:28:22 2020
@@ -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
 
 #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
 #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 
 	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 
 
 	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);

Reply via email to