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

This commit is contained in:
jmcneill 2015-12-13 17:14:56 +00:00
parent 0f1d950746
commit ecc11e2fc3
2 changed files with 16 additions and 8 deletions

View File

@ -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 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;

View File

@ -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. */