Re: [PATCH v3 1/8] mfd / platform: cros_ec: use devm_mfd_add_devices.
On Mon, 03 Dec 2018, Enric Balletbo i Serra wrote: > Hi Lee, > > On 3/12/18 11:32, Lee Jones wrote: > > On Tue, 27 Nov 2018, Enric Balletbo i Serra wrote: > > > >> Use devm_mfd_add_devices() for adding cros-ec core MFD child devices. This > >> reduces the need of remove callback from platform/chrome for removing the > >> MFD child devices. > >> > >> Signed-off-by: Enric Balletbo i Serra > >> --- > >> > >> Changes in v3: > >> - Removed cros_ec_remove from include file. > >> > >> Changes in v2: > >> - Use devm only for the cros-ec core. > >> > >> drivers/mfd/cros_ec.c | 14 +++--- > >> drivers/mfd/cros_ec_dev.c | 1 + > >> drivers/platform/chrome/cros_ec_i2c.c | 10 -- > >> drivers/platform/chrome/cros_ec_lpc.c | 4 > >> drivers/platform/chrome/cros_ec_spi.c | 11 --- > >> include/linux/mfd/cros_ec.h | 10 -- > >> 6 files changed, 4 insertions(+), 46 deletions(-) > > > > Nice patch. > > > > Just one question: > > > > [...] > > > >> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c > >> index 8f9d6964173e..ff788d3e6d5f 100644 > >> --- a/drivers/mfd/cros_ec_dev.c > >> +++ b/drivers/mfd/cros_ec_dev.c > >> @@ -493,6 +493,7 @@ static int ec_device_remove(struct platform_device > >> *pdev) > >> > >>cros_ec_debugfs_remove(ec); > >> > >> + mfd_remove_devices(ec->dev); > > > > Why is this still required? > > > > Hmm, maybe that line shouldn't be here as is not really related to this patch, > it's more a fix for the cros_ec_dev to remove those cells that are registered > with mfd_add_devices. > > Actually what we have is cros_ec that instantiates one or two cros_ec_dev > (depends on the platform) and cros_ec_dev instantiating different subdrivers. > The purpose of the patch was use the device managed resource for the cros_ec > driver, I did not touch the cros_ec_dev driver Also, if you are using managed devices, you shouldn't need to call mfd_remove_devices() at all, since it will be called for you when the device is torn down, right? > >>cdev_del(>cdev); > >>device_unregister(>class_dev); > >>return 0; > > > > [...] > > -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v3 1/8] mfd / platform: cros_ec: use devm_mfd_add_devices.
On Mon, 03 Dec 2018, Enric Balletbo i Serra wrote: > Hi Lee, > > On 3/12/18 11:32, Lee Jones wrote: > > On Tue, 27 Nov 2018, Enric Balletbo i Serra wrote: > > > >> Use devm_mfd_add_devices() for adding cros-ec core MFD child devices. This > >> reduces the need of remove callback from platform/chrome for removing the > >> MFD child devices. > >> > >> Signed-off-by: Enric Balletbo i Serra > >> --- > >> > >> Changes in v3: > >> - Removed cros_ec_remove from include file. > >> > >> Changes in v2: > >> - Use devm only for the cros-ec core. > >> > >> drivers/mfd/cros_ec.c | 14 +++--- > >> drivers/mfd/cros_ec_dev.c | 1 + > >> drivers/platform/chrome/cros_ec_i2c.c | 10 -- > >> drivers/platform/chrome/cros_ec_lpc.c | 4 > >> drivers/platform/chrome/cros_ec_spi.c | 11 --- > >> include/linux/mfd/cros_ec.h | 10 -- > >> 6 files changed, 4 insertions(+), 46 deletions(-) > > > > Nice patch. > > > > Just one question: > > > > [...] > > > >> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c > >> index 8f9d6964173e..ff788d3e6d5f 100644 > >> --- a/drivers/mfd/cros_ec_dev.c > >> +++ b/drivers/mfd/cros_ec_dev.c > >> @@ -493,6 +493,7 @@ static int ec_device_remove(struct platform_device > >> *pdev) > >> > >>cros_ec_debugfs_remove(ec); > >> > >> + mfd_remove_devices(ec->dev); > > > > Why is this still required? > > > > Hmm, maybe that line shouldn't be here as is not really related to this patch, > it's more a fix for the cros_ec_dev to remove those cells that are registered > with mfd_add_devices. > > Actually what we have is cros_ec that instantiates one or two cros_ec_dev > (depends on the platform) and cros_ec_dev instantiating different subdrivers. > The purpose of the patch was use the device managed resource for the cros_ec > driver, I did not touch the cros_ec_dev driver Also, if you are using managed devices, you shouldn't need to call mfd_remove_devices() at all, since it will be called for you when the device is torn down, right? > >>cdev_del(>cdev); > >>device_unregister(>class_dev); > >>return 0; > > > > [...] > > -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v3 1/8] mfd / platform: cros_ec: use devm_mfd_add_devices.
Hi Lee, On 3/12/18 11:32, Lee Jones wrote: > On Tue, 27 Nov 2018, Enric Balletbo i Serra wrote: > >> Use devm_mfd_add_devices() for adding cros-ec core MFD child devices. This >> reduces the need of remove callback from platform/chrome for removing the >> MFD child devices. >> >> Signed-off-by: Enric Balletbo i Serra >> --- >> >> Changes in v3: >> - Removed cros_ec_remove from include file. >> >> Changes in v2: >> - Use devm only for the cros-ec core. >> >> drivers/mfd/cros_ec.c | 14 +++--- >> drivers/mfd/cros_ec_dev.c | 1 + >> drivers/platform/chrome/cros_ec_i2c.c | 10 -- >> drivers/platform/chrome/cros_ec_lpc.c | 4 >> drivers/platform/chrome/cros_ec_spi.c | 11 --- >> include/linux/mfd/cros_ec.h | 10 -- >> 6 files changed, 4 insertions(+), 46 deletions(-) > > Nice patch. > > Just one question: > > [...] > >> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c >> index 8f9d6964173e..ff788d3e6d5f 100644 >> --- a/drivers/mfd/cros_ec_dev.c >> +++ b/drivers/mfd/cros_ec_dev.c >> @@ -493,6 +493,7 @@ static int ec_device_remove(struct platform_device *pdev) >> >> cros_ec_debugfs_remove(ec); >> >> +mfd_remove_devices(ec->dev); > > Why is this still required? > Hmm, maybe that line shouldn't be here as is not really related to this patch, it's more a fix for the cros_ec_dev to remove those cells that are registered with mfd_add_devices. Actually what we have is cros_ec that instantiates one or two cros_ec_dev (depends on the platform) and cros_ec_dev instantiating different subdrivers. The purpose of the patch was use the device managed resource for the cros_ec driver, I did not touch the cros_ec_dev driver >> cdev_del(>cdev); >> device_unregister(>class_dev); >> return 0; > > [...] >
Re: [PATCH v3 1/8] mfd / platform: cros_ec: use devm_mfd_add_devices.
Hi Lee, On 3/12/18 11:32, Lee Jones wrote: > On Tue, 27 Nov 2018, Enric Balletbo i Serra wrote: > >> Use devm_mfd_add_devices() for adding cros-ec core MFD child devices. This >> reduces the need of remove callback from platform/chrome for removing the >> MFD child devices. >> >> Signed-off-by: Enric Balletbo i Serra >> --- >> >> Changes in v3: >> - Removed cros_ec_remove from include file. >> >> Changes in v2: >> - Use devm only for the cros-ec core. >> >> drivers/mfd/cros_ec.c | 14 +++--- >> drivers/mfd/cros_ec_dev.c | 1 + >> drivers/platform/chrome/cros_ec_i2c.c | 10 -- >> drivers/platform/chrome/cros_ec_lpc.c | 4 >> drivers/platform/chrome/cros_ec_spi.c | 11 --- >> include/linux/mfd/cros_ec.h | 10 -- >> 6 files changed, 4 insertions(+), 46 deletions(-) > > Nice patch. > > Just one question: > > [...] > >> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c >> index 8f9d6964173e..ff788d3e6d5f 100644 >> --- a/drivers/mfd/cros_ec_dev.c >> +++ b/drivers/mfd/cros_ec_dev.c >> @@ -493,6 +493,7 @@ static int ec_device_remove(struct platform_device *pdev) >> >> cros_ec_debugfs_remove(ec); >> >> +mfd_remove_devices(ec->dev); > > Why is this still required? > Hmm, maybe that line shouldn't be here as is not really related to this patch, it's more a fix for the cros_ec_dev to remove those cells that are registered with mfd_add_devices. Actually what we have is cros_ec that instantiates one or two cros_ec_dev (depends on the platform) and cros_ec_dev instantiating different subdrivers. The purpose of the patch was use the device managed resource for the cros_ec driver, I did not touch the cros_ec_dev driver >> cdev_del(>cdev); >> device_unregister(>class_dev); >> return 0; > > [...] >
Re: [PATCH v3 1/8] mfd / platform: cros_ec: use devm_mfd_add_devices.
On Tue, 27 Nov 2018, Enric Balletbo i Serra wrote: > Use devm_mfd_add_devices() for adding cros-ec core MFD child devices. This > reduces the need of remove callback from platform/chrome for removing the > MFD child devices. > > Signed-off-by: Enric Balletbo i Serra > --- > > Changes in v3: > - Removed cros_ec_remove from include file. > > Changes in v2: > - Use devm only for the cros-ec core. > > drivers/mfd/cros_ec.c | 14 +++--- > drivers/mfd/cros_ec_dev.c | 1 + > drivers/platform/chrome/cros_ec_i2c.c | 10 -- > drivers/platform/chrome/cros_ec_lpc.c | 4 > drivers/platform/chrome/cros_ec_spi.c | 11 --- > include/linux/mfd/cros_ec.h | 10 -- > 6 files changed, 4 insertions(+), 46 deletions(-) Nice patch. Just one question: [...] > diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c > index 8f9d6964173e..ff788d3e6d5f 100644 > --- a/drivers/mfd/cros_ec_dev.c > +++ b/drivers/mfd/cros_ec_dev.c > @@ -493,6 +493,7 @@ static int ec_device_remove(struct platform_device *pdev) > > cros_ec_debugfs_remove(ec); > > + mfd_remove_devices(ec->dev); Why is this still required? > cdev_del(>cdev); > device_unregister(>class_dev); > return 0; [...] -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v3 1/8] mfd / platform: cros_ec: use devm_mfd_add_devices.
On Tue, 27 Nov 2018, Enric Balletbo i Serra wrote: > Use devm_mfd_add_devices() for adding cros-ec core MFD child devices. This > reduces the need of remove callback from platform/chrome for removing the > MFD child devices. > > Signed-off-by: Enric Balletbo i Serra > --- > > Changes in v3: > - Removed cros_ec_remove from include file. > > Changes in v2: > - Use devm only for the cros-ec core. > > drivers/mfd/cros_ec.c | 14 +++--- > drivers/mfd/cros_ec_dev.c | 1 + > drivers/platform/chrome/cros_ec_i2c.c | 10 -- > drivers/platform/chrome/cros_ec_lpc.c | 4 > drivers/platform/chrome/cros_ec_spi.c | 11 --- > include/linux/mfd/cros_ec.h | 10 -- > 6 files changed, 4 insertions(+), 46 deletions(-) Nice patch. Just one question: [...] > diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c > index 8f9d6964173e..ff788d3e6d5f 100644 > --- a/drivers/mfd/cros_ec_dev.c > +++ b/drivers/mfd/cros_ec_dev.c > @@ -493,6 +493,7 @@ static int ec_device_remove(struct platform_device *pdev) > > cros_ec_debugfs_remove(ec); > > + mfd_remove_devices(ec->dev); Why is this still required? > cdev_del(>cdev); > device_unregister(>class_dev); > return 0; [...] -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v3 1/8] mfd / platform: cros_ec: use devm_mfd_add_devices.
On Tue, Nov 27, 2018 at 4:18 AM Enric Balletbo i Serra wrote: > > Use devm_mfd_add_devices() for adding cros-ec core MFD child devices. This > reduces the need of remove callback from platform/chrome for removing the > MFD child devices. > > Signed-off-by: Enric Balletbo i Serra Reviewed-by: Guenter Roeck > --- > > Changes in v3: > - Removed cros_ec_remove from include file. > > Changes in v2: > - Use devm only for the cros-ec core. > > drivers/mfd/cros_ec.c | 14 +++--- > drivers/mfd/cros_ec_dev.c | 1 + > drivers/platform/chrome/cros_ec_i2c.c | 10 -- > drivers/platform/chrome/cros_ec_lpc.c | 4 > drivers/platform/chrome/cros_ec_spi.c | 11 --- > include/linux/mfd/cros_ec.h | 10 -- > 6 files changed, 4 insertions(+), 46 deletions(-) > > diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c > index fe6f83766144..6acfe036d522 100644 > --- a/drivers/mfd/cros_ec.c > +++ b/drivers/mfd/cros_ec.c > @@ -129,8 +129,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev) > } > } > > - err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, _cell, 1, > - NULL, ec_dev->irq, NULL); > + err = devm_mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, _cell, > + 1, NULL, ec_dev->irq, NULL); > if (err) { > dev_err(dev, > "Failed to register Embedded Controller subdevice > %d\n", > @@ -147,7 +147,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) > * - the EC is responsive at init time (it is not true for a > * sensor hub. > */ > - err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, > + err = devm_mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, > _pd_cell, 1, NULL, ec_dev->irq, > NULL); > if (err) { > dev_err(dev, > @@ -181,14 +181,6 @@ int cros_ec_register(struct cros_ec_device *ec_dev) > } > EXPORT_SYMBOL(cros_ec_register); > > -int cros_ec_remove(struct cros_ec_device *ec_dev) > -{ > - mfd_remove_devices(ec_dev->dev); > - > - return 0; > -} > -EXPORT_SYMBOL(cros_ec_remove); > - > #ifdef CONFIG_PM_SLEEP > int cros_ec_suspend(struct cros_ec_device *ec_dev) > { > diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c > index 8f9d6964173e..ff788d3e6d5f 100644 > --- a/drivers/mfd/cros_ec_dev.c > +++ b/drivers/mfd/cros_ec_dev.c > @@ -493,6 +493,7 @@ static int ec_device_remove(struct platform_device *pdev) > > cros_ec_debugfs_remove(ec); > > + mfd_remove_devices(ec->dev); > cdev_del(>cdev); > device_unregister(>class_dev); > return 0; > diff --git a/drivers/platform/chrome/cros_ec_i2c.c > b/drivers/platform/chrome/cros_ec_i2c.c > index ef9b4763356f..9a009eaa4ada 100644 > --- a/drivers/platform/chrome/cros_ec_i2c.c > +++ b/drivers/platform/chrome/cros_ec_i2c.c > @@ -317,15 +317,6 @@ static int cros_ec_i2c_probe(struct i2c_client *client, > return 0; > } > > -static int cros_ec_i2c_remove(struct i2c_client *client) > -{ > - struct cros_ec_device *ec_dev = i2c_get_clientdata(client); > - > - cros_ec_remove(ec_dev); > - > - return 0; > -} > - > #ifdef CONFIG_PM_SLEEP > static int cros_ec_i2c_suspend(struct device *dev) > { > @@ -376,7 +367,6 @@ static struct i2c_driver cros_ec_driver = { > .pm = _ec_i2c_pm_ops, > }, > .probe = cros_ec_i2c_probe, > - .remove = cros_ec_i2c_remove, > .id_table = cros_ec_i2c_id, > }; > > diff --git a/drivers/platform/chrome/cros_ec_lpc.c > b/drivers/platform/chrome/cros_ec_lpc.c > index e1b75775cd4a..14684a56e40f 100644 > --- a/drivers/platform/chrome/cros_ec_lpc.c > +++ b/drivers/platform/chrome/cros_ec_lpc.c > @@ -327,7 +327,6 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) > > static int cros_ec_lpc_remove(struct platform_device *pdev) > { > - struct cros_ec_device *ec_dev; > struct acpi_device *adev; > > adev = ACPI_COMPANION(>dev); > @@ -335,9 +334,6 @@ static int cros_ec_lpc_remove(struct platform_device > *pdev) > acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY, >cros_ec_lpc_acpi_notify); > > - ec_dev = platform_get_drvdata(pdev); > - cros_ec_remove(ec_dev); > - > return 0; > } > > diff --git a/drivers/platform/chrome/cros_ec_spi.c > b/drivers/platform/chrome/cros_ec_spi.c > index 2060d1483043..6cfbc2835beb 100644 > --- a/drivers/platform/chrome/cros_ec_spi.c > +++ b/drivers/platform/chrome/cros_ec_spi.c > @@ -685,16 +685,6 @@ static int cros_ec_spi_probe(struct spi_device *spi) > return 0; > } > > -static int cros_ec_spi_remove(struct spi_device *spi) > -{ > - struct cros_ec_device
Re: [PATCH v3 1/8] mfd / platform: cros_ec: use devm_mfd_add_devices.
On Tue, Nov 27, 2018 at 4:18 AM Enric Balletbo i Serra wrote: > > Use devm_mfd_add_devices() for adding cros-ec core MFD child devices. This > reduces the need of remove callback from platform/chrome for removing the > MFD child devices. > > Signed-off-by: Enric Balletbo i Serra Reviewed-by: Guenter Roeck > --- > > Changes in v3: > - Removed cros_ec_remove from include file. > > Changes in v2: > - Use devm only for the cros-ec core. > > drivers/mfd/cros_ec.c | 14 +++--- > drivers/mfd/cros_ec_dev.c | 1 + > drivers/platform/chrome/cros_ec_i2c.c | 10 -- > drivers/platform/chrome/cros_ec_lpc.c | 4 > drivers/platform/chrome/cros_ec_spi.c | 11 --- > include/linux/mfd/cros_ec.h | 10 -- > 6 files changed, 4 insertions(+), 46 deletions(-) > > diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c > index fe6f83766144..6acfe036d522 100644 > --- a/drivers/mfd/cros_ec.c > +++ b/drivers/mfd/cros_ec.c > @@ -129,8 +129,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev) > } > } > > - err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, _cell, 1, > - NULL, ec_dev->irq, NULL); > + err = devm_mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, _cell, > + 1, NULL, ec_dev->irq, NULL); > if (err) { > dev_err(dev, > "Failed to register Embedded Controller subdevice > %d\n", > @@ -147,7 +147,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) > * - the EC is responsive at init time (it is not true for a > * sensor hub. > */ > - err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, > + err = devm_mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, > _pd_cell, 1, NULL, ec_dev->irq, > NULL); > if (err) { > dev_err(dev, > @@ -181,14 +181,6 @@ int cros_ec_register(struct cros_ec_device *ec_dev) > } > EXPORT_SYMBOL(cros_ec_register); > > -int cros_ec_remove(struct cros_ec_device *ec_dev) > -{ > - mfd_remove_devices(ec_dev->dev); > - > - return 0; > -} > -EXPORT_SYMBOL(cros_ec_remove); > - > #ifdef CONFIG_PM_SLEEP > int cros_ec_suspend(struct cros_ec_device *ec_dev) > { > diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c > index 8f9d6964173e..ff788d3e6d5f 100644 > --- a/drivers/mfd/cros_ec_dev.c > +++ b/drivers/mfd/cros_ec_dev.c > @@ -493,6 +493,7 @@ static int ec_device_remove(struct platform_device *pdev) > > cros_ec_debugfs_remove(ec); > > + mfd_remove_devices(ec->dev); > cdev_del(>cdev); > device_unregister(>class_dev); > return 0; > diff --git a/drivers/platform/chrome/cros_ec_i2c.c > b/drivers/platform/chrome/cros_ec_i2c.c > index ef9b4763356f..9a009eaa4ada 100644 > --- a/drivers/platform/chrome/cros_ec_i2c.c > +++ b/drivers/platform/chrome/cros_ec_i2c.c > @@ -317,15 +317,6 @@ static int cros_ec_i2c_probe(struct i2c_client *client, > return 0; > } > > -static int cros_ec_i2c_remove(struct i2c_client *client) > -{ > - struct cros_ec_device *ec_dev = i2c_get_clientdata(client); > - > - cros_ec_remove(ec_dev); > - > - return 0; > -} > - > #ifdef CONFIG_PM_SLEEP > static int cros_ec_i2c_suspend(struct device *dev) > { > @@ -376,7 +367,6 @@ static struct i2c_driver cros_ec_driver = { > .pm = _ec_i2c_pm_ops, > }, > .probe = cros_ec_i2c_probe, > - .remove = cros_ec_i2c_remove, > .id_table = cros_ec_i2c_id, > }; > > diff --git a/drivers/platform/chrome/cros_ec_lpc.c > b/drivers/platform/chrome/cros_ec_lpc.c > index e1b75775cd4a..14684a56e40f 100644 > --- a/drivers/platform/chrome/cros_ec_lpc.c > +++ b/drivers/platform/chrome/cros_ec_lpc.c > @@ -327,7 +327,6 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) > > static int cros_ec_lpc_remove(struct platform_device *pdev) > { > - struct cros_ec_device *ec_dev; > struct acpi_device *adev; > > adev = ACPI_COMPANION(>dev); > @@ -335,9 +334,6 @@ static int cros_ec_lpc_remove(struct platform_device > *pdev) > acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY, >cros_ec_lpc_acpi_notify); > > - ec_dev = platform_get_drvdata(pdev); > - cros_ec_remove(ec_dev); > - > return 0; > } > > diff --git a/drivers/platform/chrome/cros_ec_spi.c > b/drivers/platform/chrome/cros_ec_spi.c > index 2060d1483043..6cfbc2835beb 100644 > --- a/drivers/platform/chrome/cros_ec_spi.c > +++ b/drivers/platform/chrome/cros_ec_spi.c > @@ -685,16 +685,6 @@ static int cros_ec_spi_probe(struct spi_device *spi) > return 0; > } > > -static int cros_ec_spi_remove(struct spi_device *spi) > -{ > - struct cros_ec_device