Module Name: src
Committed By: thorpej
Date: Sat May 8 16:56:10 UTC 2021
Modified Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf]: adadc.c fcu.c
Log Message:
ia->ia_cookie -> devhandle_to_of(device_handle(self))
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/dev/i2c/adadc.c
cvs rdiff -u -r1.12 -r1.12.4.1 src/sys/dev/i2c/fcu.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/adadc.c
diff -u src/sys/dev/i2c/adadc.c:1.10 src/sys/dev/i2c/adadc.c:1.10.4.1
--- src/sys/dev/i2c/adadc.c:1.10 Wed Jan 27 02:29:48 2021
+++ src/sys/dev/i2c/adadc.c Sat May 8 16:56:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: adadc.c,v 1.10 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: adadc.c,v 1.10.4.1 2021/05/08 16:56:10 thorpej Exp $ */
/*-
* Copyright (c) 2018 Michael Lorenz
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adadc.c,v 1.10 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adadc.c,v 1.10.4.1 2021/05/08 16:56:10 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -128,6 +128,7 @@ adadc_attach(device_t parent, device_t s
struct i2c_attach_args *ia = aux;
envsys_data_t *s;
int error, ch;
+ int phandle;
uint32_t eeprom[40];
char loc[256];
int which_cpu;
@@ -151,8 +152,8 @@ adadc_attach(device_t parent, device_t s
* should probably just expose the temperature and four ENVSYS_INTEGERs
*/
which_cpu = 0;
- ch = OF_child(ia->ia_cookie);
- while (ch != 0) {
+ phandle = devhandle_to_of(device_handle(self));
+ for (ch = OF_child(phandle); ch != 0; ch = OF_peer(ch)) {
if (OF_getprop(ch, "location", loc, 32) > 0) {
int reg = 0;
OF_getprop(ch, "reg", ®, sizeof(reg));
@@ -185,7 +186,6 @@ adadc_attach(device_t parent, device_t s
sysmon_envsys_sensor_attach(sc->sc_sme, s);
sc->sc_nsensors++;
}
- ch = OF_peer(ch);
}
aprint_debug_dev(self, "monitoring CPU %d\n", which_cpu);
error = get_cpuid(which_cpu, (uint8_t *)eeprom);
Index: src/sys/dev/i2c/fcu.c
diff -u src/sys/dev/i2c/fcu.c:1.12 src/sys/dev/i2c/fcu.c:1.12.4.1
--- src/sys/dev/i2c/fcu.c:1.12 Wed Jan 27 02:29:48 2021
+++ src/sys/dev/i2c/fcu.c Sat May 8 16:56:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.12 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: fcu.c,v 1.12.4.1 2021/05/08 16:56:10 thorpej Exp $ */
/*-
* Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.12 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.12.4.1 2021/05/08 16:56:10 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -141,6 +141,7 @@ fcu_attach(device_t parent, device_t sel
struct fcu_softc *sc = device_private(self);
struct i2c_attach_args *ia = aux;
int have_eeprom1 = 1;
+ int phandle;
sc->sc_dev = self;
sc->sc_i2c = ia->ia_tag;
@@ -185,11 +186,11 @@ fcu_attach(device_t parent, device_t sel
sc->sc_nfans = 0;
/* round up sensors */
+ phandle = devhandle_to_of(device_handle(self));
int ch;
sc->sc_nsensors = 0;
- ch = OF_child(ia->ia_cookie);
- while (ch != 0) {
+ for (ch = OF_child(phandle); ch != 0; ch = OF_peer(ch)) {
char type[32], descr[32];
uint32_t reg;
@@ -198,7 +199,7 @@ fcu_attach(device_t parent, device_t sel
s->state = ENVSYS_SINVALID;
if (OF_getprop(ch, "device_type", type, 32) <= 0)
- goto next;
+ continue;
if (strcmp(type, "fan-rpm-control") == 0) {
s->units = ENVSYS_SFANRPM;
@@ -214,15 +215,15 @@ fcu_attach(device_t parent, device_t sel
s->units = ENVSYS_INDICATOR;
} else {
/* ignore other types for now */
- goto next;
+ continue;
}
if (OF_getprop(ch, "reg", ®, sizeof(reg)) <= 0)
- goto next;
+ continue;
s->private = reg;
if (OF_getprop(ch, "location", descr, 32) <= 0)
- goto next;
+ continue;
strcpy(s->desc, descr);
if (s->units == ENVSYS_SFANRPM) {
@@ -304,8 +305,6 @@ fcu_attach(device_t parent, device_t sel
}
sysmon_envsys_sensor_attach(sc->sc_sme, s);
sc->sc_nsensors++;
-next:
- ch = OF_peer(ch);
}
sysmon_envsys_register(sc->sc_sme);