linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pwm: mediatek: Simplify using devm_pwmchip_add()
@ 2021-09-06  9:30 zhaoxiao
  2021-09-07  9:17 ` Uwe Kleine-König
  0 siblings, 1 reply; 2+ messages in thread
From: zhaoxiao @ 2021-09-06  9:30 UTC (permalink / raw)
  To: thierry.reding, lee.jones, matthias.bgg
  Cc: u.kleine-koenig, linux-pwm, linux-kernel, linux-arm-kernel,
	linux-mediatek, zhaoxiao

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: zhaoxiao <long870912@gmail.com>
---
 drivers/pwm/pwm-mediatek.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c
index b4a31060bcd7..0d4dd80e9f07 100644
--- a/drivers/pwm/pwm-mediatek.c
+++ b/drivers/pwm/pwm-mediatek.c
@@ -253,13 +253,11 @@ static int pwm_mediatek_probe(struct platform_device *pdev)
 		}
 	}
 
-	platform_set_drvdata(pdev, pc);
-
 	pc->chip.dev = &pdev->dev;
 	pc->chip.ops = &pwm_mediatek_ops;
 	pc->chip.npwm = pc->soc->num_pwms;
 
-	ret = pwmchip_add(&pc->chip);
+	ret = devm_pwmchip_add(&pdev->dev, &pc->chip);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
 		return ret;
@@ -268,13 +266,6 @@ static int pwm_mediatek_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int pwm_mediatek_remove(struct platform_device *pdev)
-{
-	struct pwm_mediatek_chip *pc = platform_get_drvdata(pdev);
-
-	return pwmchip_remove(&pc->chip);
-}
-
 static const struct pwm_mediatek_of_data mt2712_pwm_data = {
 	.num_pwms = 8,
 	.pwm45_fixup = false,
@@ -335,7 +326,6 @@ static struct platform_driver pwm_mediatek_driver = {
 		.of_match_table = pwm_mediatek_of_match,
 	},
 	.probe = pwm_mediatek_probe,
-	.remove = pwm_mediatek_remove,
 };
 module_platform_driver(pwm_mediatek_driver);
 
-- 
2.20.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pwm: mediatek: Simplify using devm_pwmchip_add()
  2021-09-06  9:30 [PATCH] pwm: mediatek: Simplify using devm_pwmchip_add() zhaoxiao
@ 2021-09-07  9:17 ` Uwe Kleine-König
  0 siblings, 0 replies; 2+ messages in thread
From: Uwe Kleine-König @ 2021-09-07  9:17 UTC (permalink / raw)
  To: zhaoxiao
  Cc: thierry.reding, lee.jones, matthias.bgg, linux-pwm, linux-kernel,
	linux-arm-kernel, linux-mediatek


[-- Attachment #1.1: Type: text/plain, Size: 2054 bytes --]

Hello,

On Mon, Sep 06, 2021 at 05:30:30PM +0800, zhaoxiao 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: zhaoxiao <long870912@gmail.com>
> ---
>  drivers/pwm/pwm-mediatek.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c
> index b4a31060bcd7..0d4dd80e9f07 100644
> --- a/drivers/pwm/pwm-mediatek.c
> +++ b/drivers/pwm/pwm-mediatek.c
> @@ -253,13 +253,11 @@ static int pwm_mediatek_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> -	platform_set_drvdata(pdev, pc);
> -
>  	pc->chip.dev = &pdev->dev;
>  	pc->chip.ops = &pwm_mediatek_ops;
>  	pc->chip.npwm = pc->soc->num_pwms;
>  
> -	ret = pwmchip_add(&pc->chip);
> +	ret = devm_pwmchip_add(&pdev->dev, &pc->chip);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
>  		return ret;
> @@ -268,13 +266,6 @@ static int pwm_mediatek_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -static int pwm_mediatek_remove(struct platform_device *pdev)
> -{
> -	struct pwm_mediatek_chip *pc = platform_get_drvdata(pdev);
> -
> -	return pwmchip_remove(&pc->chip);
> -}
> -
>  static const struct pwm_mediatek_of_data mt2712_pwm_data = {
>  	.num_pwms = 8,
>  	.pwm45_fixup = false,
> @@ -335,7 +326,6 @@ static struct platform_driver pwm_mediatek_driver = {
>  		.of_match_table = pwm_mediatek_of_match,
>  	},
>  	.probe = pwm_mediatek_probe,
> -	.remove = pwm_mediatek_remove,
>  };
>  module_platform_driver(pwm_mediatek_driver);

A patch like this is already in next, see e0150252a6437d12de3db84bb3af12bd5aa5cc70

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-07  9:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06  9:30 [PATCH] pwm: mediatek: Simplify using devm_pwmchip_add() zhaoxiao
2021-09-07  9:17 ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).