diff mbox series

pwm: crc: Simplify using devm_pwmchip_add()

Message ID 20210525203156.969295-1-u.kleine-koenig@pengutronix.de
State New
Headers show
Series pwm: crc: Simplify using devm_pwmchip_add() | expand

Commit Message

Uwe Kleine-König May 25, 2021, 8:31 p.m. UTC
With devm_pwmchip_add() we can drop pwmchip_remove() from the device
remove callback. The latter can then go away, too and as this is the
only user of platform_get_drvdata(), the respective call to
platform_set_drvdata() can go, too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

this patch depends on my earlier patch "pwm: Add a devm managed function to add
pwm_chips" that you can find at

        https://patchwork.ozlabs.org/project/linux-pwm/patch/20210407080155.55004-2-u.kleine-koenig@pengutronix.de/

or

        https://lore.kernel.org/r/20210407080155.55004-2-u.kleine-koenig@pengutronix.de

Best regards
Uwe

 drivers/pwm/pwm-crc.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)


base-commit: 6efb943b8616ec53a5e444193dccf1af9ad627b5
prerequisite-patch-id: fa39cd0c852d109ed957dc44dca5bdcf5dff0685

Comments

Hans de Goede May 26, 2021, 9:31 a.m. UTC | #1
Hi,

On 5/25/21 10:31 PM, Uwe Kleine-König wrote:
> With devm_pwmchip_add() we can drop pwmchip_remove() from the device
> remove callback. The latter can then go away, too and as this is the
> only user of platform_get_drvdata(), the respective call to
> platform_set_drvdata() can go, too.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
> Hello,
> 
> this patch depends on my earlier patch "pwm: Add a devm managed function to add
> pwm_chips" that you can find at
> 
>         https://patchwork.ozlabs.org/project/linux-pwm/patch/20210407080155.55004-2-u.kleine-koenig@pengutronix.de/
> 
> or
> 
>         https://lore.kernel.org/r/20210407080155.55004-2-u.kleine-koenig@pengutronix.de
> 
> Best regards
> Uwe
> 
>  drivers/pwm/pwm-crc.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-crc.c b/drivers/pwm/pwm-crc.c
> index 02522a9a3073..7b357d1cf642 100644
> --- a/drivers/pwm/pwm-crc.c
> +++ b/drivers/pwm/pwm-crc.c
> @@ -173,21 +173,11 @@ static int crystalcove_pwm_probe(struct platform_device *pdev)
>  	/* get the PMIC regmap */
>  	pwm->regmap = pmic->regmap;
>  
> -	platform_set_drvdata(pdev, pwm);
> -
> -	return pwmchip_add(&pwm->chip);
> -}
> -
> -static int crystalcove_pwm_remove(struct platform_device *pdev)
> -{
> -	struct crystalcove_pwm *pwm = platform_get_drvdata(pdev);
> -
> -	return pwmchip_remove(&pwm->chip);
> +	return devm_pwmchip_add(&pdev->dev, &pwm->chip);
>  }
>  
>  static struct platform_driver crystalcove_pwm_driver = {
>  	.probe = crystalcove_pwm_probe,
> -	.remove = crystalcove_pwm_remove,
>  	.driver = {
>  		.name = "crystal_cove_pwm",
>  	},
> 
> base-commit: 6efb943b8616ec53a5e444193dccf1af9ad627b5
> prerequisite-patch-id: fa39cd0c852d109ed957dc44dca5bdcf5dff0685
>
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-crc.c b/drivers/pwm/pwm-crc.c
index 02522a9a3073..7b357d1cf642 100644
--- a/drivers/pwm/pwm-crc.c
+++ b/drivers/pwm/pwm-crc.c
@@ -173,21 +173,11 @@  static int crystalcove_pwm_probe(struct platform_device *pdev)
 	/* get the PMIC regmap */
 	pwm->regmap = pmic->regmap;
 
-	platform_set_drvdata(pdev, pwm);
-
-	return pwmchip_add(&pwm->chip);
-}
-
-static int crystalcove_pwm_remove(struct platform_device *pdev)
-{
-	struct crystalcove_pwm *pwm = platform_get_drvdata(pdev);
-
-	return pwmchip_remove(&pwm->chip);
+	return devm_pwmchip_add(&pdev->dev, &pwm->chip);
 }
 
 static struct platform_driver crystalcove_pwm_driver = {
 	.probe = crystalcove_pwm_probe,
-	.remove = crystalcove_pwm_remove,
 	.driver = {
 		.name = "crystal_cove_pwm",
 	},