Source-Changes-HG archive

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

[src/thorpej-i2c-spi-conf2]: src/sys/dev/ofw Building on the previous, some S...



details:   https://anonhg.NetBSD.org/src/rev/7506f139ffa0
branches:  thorpej-i2c-spi-conf2
changeset: 985855:7506f139ffa0
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Sep 11 12:58:48 2021 +0000

description:
Building on the previous, some Sun OpenFirmware device trees have a
similar schema (e.g. /pci/pmu@6/i2c@0,0), but use a slightly different
name ("i2c" vs "i2c-bus").  Handle this.

diffstat:

 sys/dev/ofw/ofw_i2c_subr.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (38 lines):

diff -r 90e36291628f -r 7506f139ffa0 sys/dev/ofw/ofw_i2c_subr.c
--- a/sys/dev/ofw/ofw_i2c_subr.c        Sat Sep 11 12:44:49 2021 +0000
+++ b/sys/dev/ofw/ofw_i2c_subr.c        Sat Sep 11 12:58:48 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ofw_i2c_subr.c,v 1.1.16.3 2021/09/11 12:44:49 thorpej Exp $    */
+/*     $NetBSD: ofw_i2c_subr.c,v 1.1.16.4 2021/09/11 12:58:48 thorpej Exp $    */
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_i2c_subr.c,v 1.1.16.3 2021/09/11 12:44:49 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_i2c_subr.c,v 1.1.16.4 2021/09/11 12:58:48 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -143,12 +143,18 @@
         * The Device Tree bindings state that if a controller has a
         * child node named "i2c-bus", then that is the node beneath
         * which the child devices are populated.
+        *
+        * Some OpenFirmware variants use a slightly different name.
         */
        for (node = OF_child(i2c_node); node != 0; node = OF_peer(node)) {
                if (OF_getprop(node, "name", name, sizeof(name)) <= 0) {
                        continue;
                }
-               if (strcmp(name, "i2c-bus") == 0) {
+               if (strcmp(name, "i2c-bus") == 0
+#if defined(__HAVE_OPENFIRMWARE_VARIANT_SUNW)
+                   || strcmp(name, "i2c") == 0
+#endif /* __HAVE_OPENFIRMWARE_VARIANT_SUNW */
+                   ) {
                        i2c_node = node;
                        break;
                }



Home | Main Index | Thread Index | Old Index