For direct-config devices, pass the whole dictionary to the child as

ia_prop, so that chil drivers can look up device-specific properties.
Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
This commit is contained in:
bouyer 2017-12-10 16:53:32 +00:00
parent db8cbfd3e3
commit 03fcded0fc
2 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: i2c.c,v 1.56 2017/10/28 04:53:55 riastradh Exp $ */
/* $NetBSD: i2c.c,v 1.57 2017/12/10 16:53:32 bouyer Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -40,7 +40,7 @@
#endif
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.56 2017/10/28 04:53:55 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.57 2017/12/10 16:53:32 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -140,6 +140,7 @@ iic_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
ia.ia_name = NULL;
ia.ia_ncompat = 0;
ia.ia_compat = NULL;
ia.ia_prop = NULL;
for (ia.ia_addr = 0; ia.ia_addr <= I2C_MAX_ADDR; ia.ia_addr++) {
if (sc->sc_devices[ia.ia_addr] != NULL)
@ -262,6 +263,7 @@ iic_attach(device_t parent, device_t self, void *aux)
ia.ia_name = name;
ia.ia_cookie = cookie;
ia.ia_size = size;
ia.ia_prop = dev;
buf = NULL;
cdata = prop_dictionary_get(dev, "compatible");

View File

@ -1,4 +1,4 @@
/* $NetBSD: i2cvar.h,v 1.9 2015/12/13 17:14:56 jmcneill Exp $ */
/* $NetBSD: i2cvar.h,v 1.10 2017/12/10 16:53:32 bouyer Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -125,6 +125,7 @@ struct i2c_attach_args {
int ia_ncompat; /* number of pointers in the
ia_compat array */
const char ** ia_compat; /* chip names */
prop_dictionary_t ia_prop; /* dictionnary for this device */
/*
* The following is of limited usefulness and should only be used
* in rare cases where we really know what we are doing. Example:
@ -134,6 +135,8 @@ struct i2c_attach_args {
* may be present. Example: on OpenFirmware machines the device
* tree OF node - if available. This info is hard to transport
* down to MD drivers through the MI i2c bus otherwise.
*
* On ACPI platforms this is the ACPI_HANDLE of the device.
*/
uintptr_t ia_cookie; /* OF node in openfirmware machines */
};