From ecc11e2fc39597af1e41db8fa41b7760bdca72ed Mon Sep 17 00:00:00 2001 From: jmcneill Date: Sun, 13 Dec 2015 17:14:56 +0000 Subject: [PATCH] allow child devices to be passed in attach args instead of device dictionary --- sys/dev/i2c/i2c.c | 20 +++++++++++++------- sys/dev/i2c/i2cvar.h | 4 +++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sys/dev/i2c/i2c.c b/sys/dev/i2c/i2c.c index 6c6ad141278b..cc55e71f4cb8 100644 --- a/sys/dev/i2c/i2c.c +++ b/sys/dev/i2c/i2c.c @@ -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 -__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 #include @@ -217,11 +217,17 @@ iic_attach(device_t parent, device_t self, void *aux) 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; diff --git a/sys/dev/i2c/i2cvar.h b/sys/dev/i2c/i2cvar.h index e668375add60..fb30cf319856 100644 --- a/sys/dev/i2c/i2cvar.h +++ b/sys/dev/i2c/i2cvar.h @@ -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 +#include /* 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. */