On Thu, 11 Sep 2014, Javier Martinez Canillas wrote: > From: Todd Broch <tbroch@xxxxxxxxxxxx> > > If the EC device tree node has sub-nodes, try to instantiate them as > MFD sub-devices. We can configure the EC features provided by the board. > > Signed-off-by: Todd Broch <tbroch@xxxxxxxxxxxx> > Signed-off-by: Javier Martinez Canillas <javier.martinez@xxxxxxxxxxxxxxx> > --- > > Changes since v2: > - Drop if guards since of_node is unconditionally built. Suggested by Lee Jones > - Drop unneeded comment about of_platform_populate(). Suggested by Lee Jones. > - Fix error message if of_platform_populate() fails. Suggested by Lee Jones. > > Changes since v1: > - Don't leave an empty struct mfd_cell array. Suggested by Lee Jones. > - Just use of_platform_populate() instead of manually iterating through > sub-devices and calling mfd_add_devices. Suggested by Lee Jones. > --- > drivers/mfd/cros_ec.c | 27 ++++++++------------------- > 1 file changed, 8 insertions(+), 19 deletions(-) > > diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c > index 751af0b..7c533d2 100644 > --- a/drivers/mfd/cros_ec.c > +++ b/drivers/mfd/cros_ec.c > @@ -21,6 +21,7 @@ > #include <linux/slab.h> > #include <linux/module.h> > #include <linux/mfd/core.h> > +#include <linux/of_platform.h> > #include <linux/mfd/cros_ec.h> > #include <linux/mfd/cros_ec_commands.h> > #include <linux/delay.h> > @@ -109,22 +110,10 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, > } > EXPORT_SYMBOL(cros_ec_cmd_xfer); > > -static const struct mfd_cell cros_devs[] = { > - { > - .name = "cros-ec-keyb", > - .id = 1, > - .of_compatible = "google,cros-ec-keyb", > - }, > - { > - .name = "cros-ec-i2c-tunnel", > - .id = 2, > - .of_compatible = "google,cros-ec-i2c-tunnel", > - }, > -}; > - > int cros_ec_register(struct cros_ec_device *ec_dev) > { > struct device *dev = ec_dev->dev; > + struct device_node *node = dev->of_node; > int err = 0; > > if (ec_dev->din_size) { > @@ -140,12 +129,12 @@ int cros_ec_register(struct cros_ec_device *ec_dev) > > mutex_init(&ec_dev->lock); > > - err = mfd_add_devices(dev, 0, cros_devs, > - ARRAY_SIZE(cros_devs), > - NULL, ec_dev->irq, NULL); > - if (err) { > - dev_err(dev, "failed to add mfd devices\n"); > - return err; So these devices will only ever probe with DT now ... > + if (node) { So it would be wrong for dev->of_node not to be populated. > + err = of_platform_populate(node, NULL, NULL, dev); > + if (err) { > + dev_err(dev, "Failed to register subordinate devices"); > + return err; > + } > } > > dev_info(dev, "Chrome EC device registered\n"); -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html