Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ofw Only create the "i2c-child-devices" property if ...



details:   https://anonhg.NetBSD.org/src/rev/4ae893ce999a
branches:  trunk
changeset: 782420:4ae893ce999a
user:      jdc <jdc%NetBSD.org@localhost>
date:      Fri Nov 02 15:44:07 2012 +0000

description:
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).

diffstat:

 sys/dev/ofw/ofw_subr.c |  17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diffs (52 lines):

diff -r 817d2d73501d -r 4ae893ce999a sys/dev/ofw/ofw_subr.c
--- a/sys/dev/ofw/ofw_subr.c    Fri Nov 02 14:59:11 2012 +0000
+++ b/sys/dev/ofw/ofw_subr.c    Fri Nov 02 15:44:07 2012 +0000
@@ -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 @@
        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 @@
                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 @@
                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);
+       }
 }



Home | Main Index | Thread Index | Old Index