diff mbox series

[v8,12/16] pwm: atmel: Simplify using devm_clk_get_prepared()

Message ID 20220314141643.22184-13-u.kleine-koenig@pengutronix.de (mailing list archive)
State Not Applicable, archived
Headers show
Series clk: provide new devm helpers for prepared and enabled clocks | expand

Commit Message

Uwe Kleine-König March 14, 2022, 2:16 p.m. UTC
With devm_clk_get_prepared() caring to unprepare the clock the error
path and remove callback can be simplified accordingly.

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-atmel.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

Comments

Claudiu Beznea March 15, 2022, 9:33 a.m. UTC | #1
On 14.03.2022 16:16, Uwe Kleine-König wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> With devm_clk_get_prepared() caring to unprepare the clock the error
> path and remove callback can be simplified accordingly.
> 
> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
> Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>

> ---
>  drivers/pwm/pwm-atmel.c | 16 ++--------------
>  1 file changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
> index 98b34ea9f38e..309c31e40ce4 100644
> --- a/drivers/pwm/pwm-atmel.c
> +++ b/drivers/pwm/pwm-atmel.c
> @@ -480,16 +480,10 @@ static int atmel_pwm_probe(struct platform_device *pdev)
>         if (IS_ERR(atmel_pwm->base))
>                 return PTR_ERR(atmel_pwm->base);
> 
> -       atmel_pwm->clk = devm_clk_get(&pdev->dev, NULL);
> +       atmel_pwm->clk = devm_clk_get_prepared(&pdev->dev, NULL);
>         if (IS_ERR(atmel_pwm->clk))
>                 return PTR_ERR(atmel_pwm->clk);
> 
> -       ret = clk_prepare(atmel_pwm->clk);
> -       if (ret) {
> -               dev_err(&pdev->dev, "failed to prepare PWM clock\n");
> -               return ret;
> -       }
> -
>         atmel_pwm->chip.dev = &pdev->dev;
>         atmel_pwm->chip.ops = &atmel_pwm_ops;
>         atmel_pwm->chip.npwm = 4;
> @@ -497,16 +491,12 @@ static int atmel_pwm_probe(struct platform_device *pdev)
>         ret = pwmchip_add(&atmel_pwm->chip);
>         if (ret < 0) {
>                 dev_err(&pdev->dev, "failed to add PWM chip %d\n", ret);
> -               goto unprepare_clk;
> +               return ret;
>         }
> 
>         platform_set_drvdata(pdev, atmel_pwm);
> 
>         return ret;
> -
> -unprepare_clk:
> -       clk_unprepare(atmel_pwm->clk);
> -       return ret;
>  }
> 
>  static int atmel_pwm_remove(struct platform_device *pdev)
> @@ -515,8 +505,6 @@ static int atmel_pwm_remove(struct platform_device *pdev)
> 
>         pwmchip_remove(&atmel_pwm->chip);
> 
> -       clk_unprepare(atmel_pwm->clk);
> -
>         return 0;
>  }
> 
> --
> 2.35.1
>
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
index 98b34ea9f38e..309c31e40ce4 100644
--- a/drivers/pwm/pwm-atmel.c
+++ b/drivers/pwm/pwm-atmel.c
@@ -480,16 +480,10 @@  static int atmel_pwm_probe(struct platform_device *pdev)
 	if (IS_ERR(atmel_pwm->base))
 		return PTR_ERR(atmel_pwm->base);
 
-	atmel_pwm->clk = devm_clk_get(&pdev->dev, NULL);
+	atmel_pwm->clk = devm_clk_get_prepared(&pdev->dev, NULL);
 	if (IS_ERR(atmel_pwm->clk))
 		return PTR_ERR(atmel_pwm->clk);
 
-	ret = clk_prepare(atmel_pwm->clk);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to prepare PWM clock\n");
-		return ret;
-	}
-
 	atmel_pwm->chip.dev = &pdev->dev;
 	atmel_pwm->chip.ops = &atmel_pwm_ops;
 	atmel_pwm->chip.npwm = 4;
@@ -497,16 +491,12 @@  static int atmel_pwm_probe(struct platform_device *pdev)
 	ret = pwmchip_add(&atmel_pwm->chip);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to add PWM chip %d\n", ret);
-		goto unprepare_clk;
+		return ret;
 	}
 
 	platform_set_drvdata(pdev, atmel_pwm);
 
 	return ret;
-
-unprepare_clk:
-	clk_unprepare(atmel_pwm->clk);
-	return ret;
 }
 
 static int atmel_pwm_remove(struct platform_device *pdev)
@@ -515,8 +505,6 @@  static int atmel_pwm_remove(struct platform_device *pdev)
 
 	pwmchip_remove(&atmel_pwm->chip);
 
-	clk_unprepare(atmel_pwm->clk);
-
 	return 0;
 }