* [PATCH 11/11] pwm: cros-ec: Simplify using devm_pwmchip_add() and dev_err_probe()
2023-09-29 16:19 [PATCH 00/11] pwm: Some random cleanups Uwe Kleine-König
@ 2023-09-29 16:19 ` Uwe Kleine-König
2023-10-02 6:01 ` Tzung-Bi Shih
2023-11-13 3:23 ` [PATCH 00/11] pwm: Some random cleanups patchwork-bot+chrome-platform
2023-11-13 3:42 ` patchwork-bot+chrome-platform
2 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2023-09-29 16:19 UTC (permalink / raw)
To: Thierry Reding
Cc: Benson Leung, Guenter Roeck, linux-pwm, chrome-platform, kernel
Using devm_pwmchip_add() allows to drop pwmchip_remove() from the remove
function which makes this function empty. Then there is no user of
drvdata left and platform_set_drvdata() can be dropped, too.
Further simplify and improve error returning using dev_err_probe().
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/pwm/pwm-cros-ec.c | 33 ++++++++-------------------------
1 file changed, 8 insertions(+), 25 deletions(-)
diff --git a/drivers/pwm/pwm-cros-ec.c b/drivers/pwm/pwm-cros-ec.c
index baaac0c33aa0..f048150fffc7 100644
--- a/drivers/pwm/pwm-cros-ec.c
+++ b/drivers/pwm/pwm-cros-ec.c
@@ -286,10 +286,8 @@ static int cros_ec_pwm_probe(struct platform_device *pdev)
struct pwm_chip *chip;
int ret;
- if (!ec) {
- dev_err(dev, "no parent EC device\n");
- return -EINVAL;
- }
+ if (!ec)
+ return dev_err_probe(dev, -EINVAL, "no parent EC device\n");
ec_pwm = devm_kzalloc(dev, sizeof(*ec_pwm), GFP_KERNEL);
if (!ec_pwm)
@@ -310,32 +308,18 @@ static int cros_ec_pwm_probe(struct platform_device *pdev)
chip->npwm = CROS_EC_PWM_DT_COUNT;
} else {
ret = cros_ec_num_pwms(ec_pwm);
- if (ret < 0) {
- dev_err(dev, "Couldn't find PWMs: %d\n", ret);
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "Couldn't find PWMs\n");
chip->npwm = ret;
}
dev_dbg(dev, "Probed %u PWMs\n", chip->npwm);
- ret = pwmchip_add(chip);
- if (ret < 0) {
- dev_err(dev, "cannot register PWM: %d\n", ret);
- return ret;
- }
+ ret = devm_pwmchip_add(dev, chip);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "cannot register PWM\n");
- platform_set_drvdata(pdev, ec_pwm);
-
- return ret;
-}
-
-static void cros_ec_pwm_remove(struct platform_device *dev)
-{
- struct cros_ec_pwm_device *ec_pwm = platform_get_drvdata(dev);
- struct pwm_chip *chip = &ec_pwm->chip;
-
- pwmchip_remove(chip);
+ return 0;
}
#ifdef CONFIG_OF
@@ -349,7 +333,6 @@ MODULE_DEVICE_TABLE(of, cros_ec_pwm_of_match);
static struct platform_driver cros_ec_pwm_driver = {
.probe = cros_ec_pwm_probe,
- .remove_new = cros_ec_pwm_remove,
.driver = {
.name = "cros-ec-pwm",
.of_match_table = of_match_ptr(cros_ec_pwm_of_match),
--
2.40.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 11/11] pwm: cros-ec: Simplify using devm_pwmchip_add() and dev_err_probe()
2023-09-29 16:19 ` [PATCH 11/11] pwm: cros-ec: Simplify using devm_pwmchip_add() and dev_err_probe() Uwe Kleine-König
@ 2023-10-02 6:01 ` Tzung-Bi Shih
0 siblings, 0 replies; 5+ messages in thread
From: Tzung-Bi Shih @ 2023-10-02 6:01 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Thierry Reding, Benson Leung, Guenter Roeck, linux-pwm,
chrome-platform, kernel
On Fri, Sep 29, 2023 at 06:19:18PM +0200, Uwe Kleine-König wrote:
> Using devm_pwmchip_add() allows to drop pwmchip_remove() from the remove
> function which makes this function empty. Then there is no user of
> drvdata left and platform_set_drvdata() can be dropped, too.
>
> Further simplify and improve error returning using dev_err_probe().
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 00/11] pwm: Some random cleanups
2023-09-29 16:19 [PATCH 00/11] pwm: Some random cleanups Uwe Kleine-König
2023-09-29 16:19 ` [PATCH 11/11] pwm: cros-ec: Simplify using devm_pwmchip_add() and dev_err_probe() Uwe Kleine-König
@ 2023-11-13 3:23 ` patchwork-bot+chrome-platform
2023-11-13 3:42 ` patchwork-bot+chrome-platform
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+chrome-platform @ 2023-11-13 3:23 UTC (permalink / raw)
To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig_=3Cu=2Ekleine-koenig=40pengutronix=2Ede=3E?=
Cc: thierry.reding, rjui, sbranden, bcm-kernel-feedback-list,
linux-pwm, linux-arm-kernel, kernel, florian.fainelli,
linux-rpi-kernel, shawnguo, s.hauer, festevam, linux-imx,
matthias.bgg, angelogioacchino.delregno, linux-mediatek,
orsonzhai, baolin.wang, zhang.lyra, krzysztof.kozlowski,
alim.akhtar, linux-samsung-soc, bleung, groeck, chrome-platform
Hello:
This patch was applied to chrome-platform/linux.git (for-kernelci)
by Thierry Reding <thierry.reding@gmail.com>:
On Fri, 29 Sep 2023 18:19:07 +0200 you wrote:
> Hello,
>
> this is a set of patches I based my efforts for closing a race condition
> in the pwm core on. I thought I already sent them out, but it seems I
> didn't. So here they come!
>
> Best regards
> Uwe
>
> [...]
Here is the summary with links:
- [11/11] pwm: cros-ec: Simplify using devm_pwmchip_add() and dev_err_probe()
https://git.kernel.org/chrome-platform/c/896c450960f5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 00/11] pwm: Some random cleanups
2023-09-29 16:19 [PATCH 00/11] pwm: Some random cleanups Uwe Kleine-König
2023-09-29 16:19 ` [PATCH 11/11] pwm: cros-ec: Simplify using devm_pwmchip_add() and dev_err_probe() Uwe Kleine-König
2023-11-13 3:23 ` [PATCH 00/11] pwm: Some random cleanups patchwork-bot+chrome-platform
@ 2023-11-13 3:42 ` patchwork-bot+chrome-platform
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+chrome-platform @ 2023-11-13 3:42 UTC (permalink / raw)
To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig_=3Cu=2Ekleine-koenig=40pengutronix=2Ede=3E?=
Cc: thierry.reding, rjui, sbranden, bcm-kernel-feedback-list,
linux-pwm, linux-arm-kernel, kernel, florian.fainelli,
linux-rpi-kernel, shawnguo, s.hauer, festevam, linux-imx,
matthias.bgg, angelogioacchino.delregno, linux-mediatek,
orsonzhai, baolin.wang, zhang.lyra, krzysztof.kozlowski,
alim.akhtar, linux-samsung-soc, bleung, groeck, chrome-platform
Hello:
This patch was applied to chrome-platform/linux.git (for-next)
by Thierry Reding <thierry.reding@gmail.com>:
On Fri, 29 Sep 2023 18:19:07 +0200 you wrote:
> Hello,
>
> this is a set of patches I based my efforts for closing a race condition
> in the pwm core on. I thought I already sent them out, but it seems I
> didn't. So here they come!
>
> Best regards
> Uwe
>
> [...]
Here is the summary with links:
- [11/11] pwm: cros-ec: Simplify using devm_pwmchip_add() and dev_err_probe()
https://git.kernel.org/chrome-platform/c/896c450960f5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread