Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/i2c more OF -> properties for sensor names, this sho...
details: https://anonhg.NetBSD.org/src/rev/e4feb36c602a
branches: trunk
changeset: 942892:e4feb36c602a
user: macallan <macallan%NetBSD.org@localhost>
date: Fri Aug 21 21:28:22 2020 +0000
description:
more OF -> properties for sensor names, this should be the last one
diffstat:
sys/dev/i2c/dstemp.c | 38 ++++++++++++++++----------------------
1 files changed, 16 insertions(+), 22 deletions(-)
diffs (85 lines):
diff -r 48af9683a488 -r e4feb36c602a sys/dev/i2c/dstemp.c
--- a/sys/dev/i2c/dstemp.c Fri Aug 21 20:46:03 2020 +0000
+++ b/sys/dev/i2c/dstemp.c Fri Aug 21 21:28:22 2020 +0000
@@ -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 @@
#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 @@
#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 @@
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index