Module Name:    src
Committed By:   jmcneill
Date:           Sun Dec 13 17:14:56 UTC 2015

Modified Files:
        src/sys/dev/i2c: i2c.c i2cvar.h

Log Message:
allow child devices to be passed in attach args instead of device dictionary


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/i2c/i2c.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/i2c/i2cvar.h

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/i2c.c
diff -u src/sys/dev/i2c/i2c.c:1.50 src/sys/dev/i2c/i2c.c:1.51
--- src/sys/dev/i2c/i2c.c:1.50	Thu Dec 10 05:33:28 2015
+++ src/sys/dev/i2c/i2c.c	Sun Dec 13 17:14:56 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c.c,v 1.50 2015/12/10 05:33:28 pgoyette Exp $	*/
+/*	$NetBSD: i2c.c,v 1.51 2015/12/13 17:14:56 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.50 2015/12/10 05:33:28 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.51 2015/12/13 17:14:56 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -217,11 +217,17 @@ iic_attach(device_t parent, device_t sel
 	if (!pmf_device_register(self, NULL, NULL))
 		aprint_error_dev(self, "couldn't establish power handler\n");
 
-	props = device_properties(parent);
-	if (!prop_dictionary_get_bool(props, "i2c-indirect-config",
-	    &indirect_config))
-		indirect_config = true;
-	child_devices = prop_dictionary_get(props, "i2c-child-devices");
+	if (iba->iba_child_devices) {
+		child_devices = iba->iba_child_devices;
+		indirect_config = false;
+	} else {
+		props = device_properties(parent);
+		if (!prop_dictionary_get_bool(props, "i2c-indirect-config",
+		    &indirect_config))
+			indirect_config = true;
+		child_devices = prop_dictionary_get(props, "i2c-child-devices");
+	}
+
 	if (child_devices) {
 		unsigned int i, count;
 		prop_dictionary_t dev;

Index: src/sys/dev/i2c/i2cvar.h
diff -u src/sys/dev/i2c/i2cvar.h:1.8 src/sys/dev/i2c/i2cvar.h:1.9
--- src/sys/dev/i2c/i2cvar.h:1.8	Sun Feb 28 15:33:21 2010
+++ src/sys/dev/i2c/i2cvar.h	Sun Dec 13 17:14:56 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2cvar.h,v 1.8 2010/02/28 15:33:21 snj Exp $	*/
+/*	$NetBSD: i2cvar.h,v 1.9 2015/12/13 17:14:56 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -39,6 +39,7 @@
 #define	_DEV_I2C_I2CVAR_H_
 
 #include <dev/i2c/i2c_io.h>
+#include <prop/proplib.h>
 
 /* Flags passed to i2c routines. */
 #define	I2C_F_WRITE		0x00	/* new transfer is a write */
@@ -110,6 +111,7 @@ typedef struct i2c_controller {
 struct i2cbus_attach_args {
 	i2c_tag_t iba_tag;		/* the controller */
 	int iba_type;			/* bus type */
+	prop_array_t iba_child_devices;	/* child devices (direct config) */
 };
 
 /* Used to attach devices on the i2c bus. */

Reply via email to