Module Name:    src
Committed By:   thorpej
Date:           Sat Sep 11 12:58:48 UTC 2021

Modified Files:
        src/sys/dev/ofw [thorpej-i2c-spi-conf2]: ofw_i2c_subr.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.1.16.3 -r1.1.16.4 src/sys/dev/ofw/ofw_i2c_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_i2c_subr.c
diff -u src/sys/dev/ofw/ofw_i2c_subr.c:1.1.16.3 src/sys/dev/ofw/ofw_i2c_subr.c:1.1.16.4
--- src/sys/dev/ofw/ofw_i2c_subr.c:1.1.16.3	Sat Sep 11 12:44:49 2021
+++ src/sys/dev/ofw/ofw_i2c_subr.c	Sat Sep 11 12:58:48 2021
@@ -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 @@ of_i2c_enumerate_devices(device_t dev, d
 	 * 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;
 		}

Reply via email to