]> Git Repo - linux.git/commitdiff
pwm: sprd: Simplify using devm_pwmchip_add() and dev_err_probe()
authorUwe Kleine-König <[email protected]>
Fri, 29 Sep 2023 16:19:15 +0000 (18:19 +0200)
committerThierry Reding <[email protected]>
Fri, 13 Oct 2023 08:07:18 +0000 (10:07 +0200)
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/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
drivers/pwm/pwm-sprd.c

index 98a36ff7df7bb64fcb9e7be3325cc2da375b1f61..77939e1610067fe1d358893ae866ed49fe84464c 100644 (file)
@@ -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);
This page took 0.053585 seconds and 4 git commands to generate.