On Wed, 17 Jan 2018, Enric Balletbo i Serra wrote:

> From: Sameer Nanda <sna...@chromium.org>
> 
> Check whether this EC instance has USBPD host command support and
> instatiate the cros_usbpd-charger driver as a subdevice in such case.
> 
> Signed-off-by: Sameer Nanda <sna...@chromium.org>
> Signed-off-by: Enric Balletbo i Serra <enric.balle...@collabora.com>
> ---
>  drivers/mfd/cros_ec_dev.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
> index 26a8731499bf..d98f03f3d251 100644
> --- a/drivers/mfd/cros_ec_dev.c
> +++ b/drivers/mfd/cros_ec_dev.c
> @@ -37,6 +37,9 @@ static const struct attribute_group *cros_ec_groups[] = {
>       &cros_ec_attr_group,
>       &cros_ec_lightbar_attr_group,
>       &cros_ec_vbc_attr_group,
> +#if IS_ENABLED(CONFIG_CHARGER_CROS_USB_PD)
> +     &cros_usb_pd_charger_attr_group,
> +#endif

I'd rather not introduce #ifery into *.c files.

Please find another way of doing this.  Perhaps create a nil-Byte
alternative that you can shove away in a header file somewhere?

>       NULL,
>  };
>  
> @@ -269,6 +272,24 @@ static void __remove(struct device *dev)
>       kfree(ec);
>  }
>  
> +static const struct mfd_cell cros_usb_pd_charger_devs[] = {
> +     {
> +             .name = "cros-usb-pd-charger",
> +             .id   = -1,

What are you trying to achieve here?

> +     },
> +};
> +
> +static void cros_ec_usb_pd_charger_register(struct cros_ec_dev *ec)
> +{
> +     int ret;
> +
> +     ret = mfd_add_devices(ec->dev, 0, cros_usb_pd_charger_devs,

What does 0 mean here?

> +                           ARRAY_SIZE(cros_usb_pd_charger_devs),
> +                           NULL, 0, NULL);
> +     if (ret)
> +             dev_err(ec->dev, "failed to add usb-pd-charger device\n");
> +}
> +
>  static void cros_ec_sensors_register(struct cros_ec_dev *ec)
>  {
>       /*
> @@ -451,6 +472,10 @@ static int ec_device_probe(struct platform_device *pdev)
>       if (cros_ec_debugfs_init(ec))
>               dev_warn(dev, "failed to create debugfs directory\n");
>  
> +     /* check whether this EC instance has the PD charge manager */
> +     if (cros_ec_check_features(ec, EC_FEATURE_USB_PD))
> +             cros_ec_usb_pd_charger_register(ec);
> +
>       /* check whether this EC is a sensor hub. */
>       if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE))
>               cros_ec_sensors_register(ec);

-- 
Lee Jones
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

Reply via email to