Module Name: src
Committed By: jdc
Date: Fri Nov 2 15:44:07 UTC 2012
Modified Files:
src/sys/dev/ofw: ofw_subr.c
Log Message:
Only create the "i2c-child-devices" property if we actually found any
child devices (rather than unconditionally).
Allows indirect config of i2c busses to work (e,g. for Tadpole SPARCle).
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ofw/ofw_subr.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/ofw/ofw_subr.c
diff -u src/sys/dev/ofw/ofw_subr.c:1.18 src/sys/dev/ofw/ofw_subr.c:1.19
--- src/sys/dev/ofw/ofw_subr.c:1.18 Sun Feb 28 13:59:05 2010
+++ src/sys/dev/ofw/ofw_subr.c Fri Nov 2 15:44:07 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_subr.c,v 1.18 2010/02/28 13:59:05 martin Exp $ */
+/* $NetBSD: ofw_subr.c,v 1.19 2012/11/02 15:44:07 jdc Exp $ */
/*
* Copyright 1998
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.18 2010/02/28 13:59:05 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.19 2012/11/02 15:44:07 jdc Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -340,11 +340,9 @@ of_enter_i2c_devs(prop_dictionary_t prop
uint64_t reg64;
uint32_t reg32;
uint64_t addr;
- prop_array_t array;
+ prop_array_t array = NULL;
prop_dictionary_t dev;
- array = prop_array_create();
-
for (node = OF_child(ofnode); node; node = OF_peer(node)) {
if (OF_getprop(node, "name", name, sizeof(name)) <= 0)
continue;
@@ -366,6 +364,9 @@ of_enter_i2c_devs(prop_dictionary_t prop
addr >>= 1;
if (addr == 0) continue;
+ if (array == NULL)
+ array = prop_array_create();
+
dev = prop_dictionary_create();
prop_dictionary_set_cstring(dev, "name", name);
prop_dictionary_set_uint32(dev, "addr", addr);
@@ -375,6 +376,8 @@ of_enter_i2c_devs(prop_dictionary_t prop
prop_object_release(dev);
}
- prop_dictionary_set(props, "i2c-child-devices", array);
- prop_object_release(array);
+ if (array != NULL) {
+ prop_dictionary_set(props, "i2c-child-devices", array);
+ prop_object_release(array);
+ }
}