diff mbox series

[10/15] mfd: motorola-cpcap: use devm_of_platform_populate()

Message ID 1496072763-31209-11-git-send-email-benjamin.gaignard@linaro.org
State New
Headers show
Series [01/15] iio: adc: stm32: use devm_of_platform_populate() | expand

Commit Message

Benjamin Gaignard May 29, 2017, 3:45 p.m. UTC
Usage of  devm_of_platform_populate() simplify driver code
by allowing to delete cpcap_remove().

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>


CC: Lee Jones <lee.jones@linaro.org>
CC: linux-kernel@vger.kernel.org
---
 drivers/mfd/motorola-cpcap.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

-- 
1.9.1

Comments

Andy Shevchenko May 29, 2017, 10:07 p.m. UTC | #1
On Mon, May 29, 2017 at 6:45 PM, Benjamin Gaignard
<benjamin.gaignard@linaro.org> wrote:
> Usage of  devm_of_platform_populate() simplify driver code

> by allowing to delete cpcap_remove().


> -       .remove = cpcap_remove,


Can you remove module after that change?

-- 
With Best Regards,
Andy Shevchenko
Benjamin Gaignard May 30, 2017, 7:29 a.m. UTC | #2
2017-05-30 0:07 GMT+02:00 Andy Shevchenko <andy.shevchenko@gmail.com>:
> On Mon, May 29, 2017 at 6:45 PM, Benjamin Gaignard

> <benjamin.gaignard@linaro.org> wrote:

>> Usage of  devm_of_platform_populate() simplify driver code

>> by allowing to delete cpcap_remove().

>

>> -       .remove = cpcap_remove,

>

> Can you remove module after that change?


yes you can, it will be done by driver default function and
of_platform_depopulate() will be called after

>

> --

> With Best Regards,

> Andy Shevchenko
Lee Jones May 30, 2017, 10:03 a.m. UTC | #3
On Tue, 30 May 2017, Andy Shevchenko wrote:

> On Mon, May 29, 2017 at 6:45 PM, Benjamin Gaignard

> <benjamin.gaignard@linaro.org> wrote:

> > Usage of  devm_of_platform_populate() simplify driver code

> > by allowing to delete cpcap_remove().

> 

> > -       .remove = cpcap_remove,

> 

> Can you remove module after that change?


Why wouldn't you?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Lee Jones May 30, 2017, 10:09 a.m. UTC | #4
On Mon, 29 May 2017, Benjamin Gaignard wrote:

> Usage of  devm_of_platform_populate() simplify driver code

> by allowing to delete cpcap_remove().

> 

> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>

> 

> CC: Lee Jones <lee.jones@linaro.org>

> CC: linux-kernel@vger.kernel.org

> ---

>  drivers/mfd/motorola-cpcap.c | 13 +------------

>  1 file changed, 1 insertion(+), 12 deletions(-)


Applied, thanks.

> diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c

> index 3cab58a..d2cc1ea 100644

> --- a/drivers/mfd/motorola-cpcap.c

> +++ b/drivers/mfd/motorola-cpcap.c

> @@ -260,17 +260,7 @@ static int cpcap_probe(struct spi_device *spi)

>  	if (ret)

>  		return ret;

>  

> -	return of_platform_populate(spi->dev.of_node, NULL, NULL,

> -				    &cpcap->spi->dev);

> -}

> -

> -static int cpcap_remove(struct spi_device *pdev)

> -{

> -	struct cpcap_ddata *cpcap = spi_get_drvdata(pdev);

> -

> -	of_platform_depopulate(&cpcap->spi->dev);

> -

> -	return 0;

> +	return devm_of_platform_populate(&cpcap->spi->dev);

>  }

>  

>  static struct spi_driver cpcap_driver = {

> @@ -279,7 +269,6 @@ static int cpcap_remove(struct spi_device *pdev)

>  		.of_match_table = cpcap_of_match,

>  	},

>  	.probe = cpcap_probe,

> -	.remove = cpcap_remove,

>  };

>  module_spi_driver(cpcap_driver);

>  


-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Andy Shevchenko May 30, 2017, 10:46 a.m. UTC | #5
On Tue, May 30, 2017 at 1:03 PM, Lee Jones <lee.jones@linaro.org> wrote:
> On Tue, 30 May 2017, Andy Shevchenko wrote:

>

>> On Mon, May 29, 2017 at 6:45 PM, Benjamin Gaignard

>> <benjamin.gaignard@linaro.org> wrote:

>> > Usage of  devm_of_platform_populate() simplify driver code

>> > by allowing to delete cpcap_remove().

>>

>> > -       .remove = cpcap_remove,

>>

>> Can you remove module after that change?

>

> Why wouldn't you?


Indeed.
Just checked __device_release_driver().

-- 
With Best Regards,
Andy Shevchenko
diff mbox series

Patch

diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
index 3cab58a..d2cc1ea 100644
--- a/drivers/mfd/motorola-cpcap.c
+++ b/drivers/mfd/motorola-cpcap.c
@@ -260,17 +260,7 @@  static int cpcap_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
-	return of_platform_populate(spi->dev.of_node, NULL, NULL,
-				    &cpcap->spi->dev);
-}
-
-static int cpcap_remove(struct spi_device *pdev)
-{
-	struct cpcap_ddata *cpcap = spi_get_drvdata(pdev);
-
-	of_platform_depopulate(&cpcap->spi->dev);
-
-	return 0;
+	return devm_of_platform_populate(&cpcap->spi->dev);
 }
 
 static struct spi_driver cpcap_driver = {
@@ -279,7 +269,6 @@  static int cpcap_remove(struct spi_device *pdev)
 		.of_match_table = cpcap_of_match,
 	},
 	.probe = cpcap_probe,
-	.remove = cpcap_remove,
 };
 module_spi_driver(cpcap_driver);