diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2023-09-29 18:19:15 +0200 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2023-10-13 10:07:18 +0200 |
commit | 21c0e1aaf7ef0ac3c67e4e1ab68c080adb2a186b (patch) | |
tree | 34bda0b88328b47df8866565a2130116bdd6e32f /drivers/pwm | |
parent | d8a2f6f26a079f3d0a34b6146e332797218cb5de (diff) |
pwm: sprd: Simplify using devm_pwmchip_add() and dev_err_probe()
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().
Link: https://lore.kernel.org/r/20230929161918.2410424-9-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r-- | drivers/pwm/pwm-sprd.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/drivers/pwm/pwm-sprd.c b/drivers/pwm/pwm-sprd.c index 98a36ff7df7b..77939e161006 100644 --- a/drivers/pwm/pwm-sprd.c +++ b/drivers/pwm/pwm-sprd.c @@ -242,10 +242,8 @@ static int sprd_pwm_clk_init(struct sprd_pwm_chip *spc) chn->clk_rate = clk_get_rate(clk_pwm); } - if (!i) { - dev_err(spc->dev, "no available PWM channels\n"); - return -ENODEV; - } + if (!i) + return dev_err_probe(spc->dev, -ENODEV, "no available PWM channels\n"); spc->num_pwms = i; @@ -266,7 +264,6 @@ static int sprd_pwm_probe(struct platform_device *pdev) return PTR_ERR(spc->base); spc->dev = &pdev->dev; - platform_set_drvdata(pdev, spc); ret = sprd_pwm_clk_init(spc); if (ret) @@ -276,20 +273,13 @@ static int sprd_pwm_probe(struct platform_device *pdev) spc->chip.ops = &sprd_pwm_ops; spc->chip.npwm = spc->num_pwms; - ret = pwmchip_add(&spc->chip); + ret = devm_pwmchip_add(&pdev->dev, &spc->chip); if (ret) dev_err(&pdev->dev, "failed to add PWM chip\n"); return ret; } -static void sprd_pwm_remove(struct platform_device *pdev) -{ - struct sprd_pwm_chip *spc = platform_get_drvdata(pdev); - - pwmchip_remove(&spc->chip); -} - static const struct of_device_id sprd_pwm_of_match[] = { { .compatible = "sprd,ums512-pwm", }, { }, @@ -302,7 +292,6 @@ static struct platform_driver sprd_pwm_driver = { .of_match_table = sprd_pwm_of_match, }, .probe = sprd_pwm_probe, - .remove_new = sprd_pwm_remove, }; module_platform_driver(sprd_pwm_driver); |