diff mbox series

[2/2] pwm: atmel-hlcdc: Don't use pwm consumer API

Message ID 6e34607828b290cd64ca9f82df40872853069f07.1706269232.git.u.kleine-koenig@pengutronix.de
State Accepted
Headers show
Series pwm: atmel-hlcdc: Two improvements | expand

Commit Message

Uwe Kleine-König Jan. 26, 2024, 12:04 p.m. UTC
Lowlevel driver callbacks are not supposed to use the consumer API
functions. Currently this works, but with the upcoming locking changes
this probably results in dead locks.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pwm/pwm-atmel-hlcdc.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

claudiu beznea Feb. 3, 2024, 3:47 p.m. UTC | #1
On 26.01.2024 14:04, Uwe Kleine-König wrote:
> Lowlevel driver callbacks are not supposed to use the consumer API
> functions. Currently this works, but with the upcoming locking changes
> this probably results in dead locks.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>

> ---
>  drivers/pwm/pwm-atmel-hlcdc.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
> index 1f6fc9a9fcf3..2d64af045fc5 100644
> --- a/drivers/pwm/pwm-atmel-hlcdc.c
> +++ b/drivers/pwm/pwm-atmel-hlcdc.c
> @@ -183,9 +183,10 @@ static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = {
>  static int atmel_hlcdc_pwm_suspend(struct device *dev)
>  {
>  	struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev);
> +	struct pwm_device *pwm = &atmel->chip.pwms[0];
>  
>  	/* Keep the periph clock enabled if the PWM is still running. */
> -	if (!pwm_is_enabled(&atmel->chip.pwms[0]))
> +	if (!pwm->state.enabled)
>  		clk_disable_unprepare(atmel->hlcdc->periph_clk);
>  
>  	return 0;
> @@ -194,20 +195,17 @@ static int atmel_hlcdc_pwm_suspend(struct device *dev)
>  static int atmel_hlcdc_pwm_resume(struct device *dev)
>  {
>  	struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev);
> -	struct pwm_state state;
> +	struct pwm_device *pwm = &atmel->chip.pwms[0];
>  	int ret;
>  
> -	pwm_get_state(&atmel->chip.pwms[0], &state);
> -
>  	/* Re-enable the periph clock it was stopped during suspend. */
> -	if (!state.enabled) {
> +	if (!pwm->state.enabled) {
>  		ret = clk_prepare_enable(atmel->hlcdc->periph_clk);
>  		if (ret)
>  			return ret;
>  	}
>  
> -	return atmel_hlcdc_pwm_apply(&atmel->chip, &atmel->chip.pwms[0],
> -				     &state);
> +	return atmel_hlcdc_pwm_apply(&atmel->chip, pwm, &pwm->state);
>  }
>  
>  static DEFINE_SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops,
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
index 1f6fc9a9fcf3..2d64af045fc5 100644
--- a/drivers/pwm/pwm-atmel-hlcdc.c
+++ b/drivers/pwm/pwm-atmel-hlcdc.c
@@ -183,9 +183,10 @@  static const struct atmel_hlcdc_pwm_errata atmel_hlcdc_pwm_sama5d3_errata = {
 static int atmel_hlcdc_pwm_suspend(struct device *dev)
 {
 	struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev);
+	struct pwm_device *pwm = &atmel->chip.pwms[0];
 
 	/* Keep the periph clock enabled if the PWM is still running. */
-	if (!pwm_is_enabled(&atmel->chip.pwms[0]))
+	if (!pwm->state.enabled)
 		clk_disable_unprepare(atmel->hlcdc->periph_clk);
 
 	return 0;
@@ -194,20 +195,17 @@  static int atmel_hlcdc_pwm_suspend(struct device *dev)
 static int atmel_hlcdc_pwm_resume(struct device *dev)
 {
 	struct atmel_hlcdc_pwm *atmel = dev_get_drvdata(dev);
-	struct pwm_state state;
+	struct pwm_device *pwm = &atmel->chip.pwms[0];
 	int ret;
 
-	pwm_get_state(&atmel->chip.pwms[0], &state);
-
 	/* Re-enable the periph clock it was stopped during suspend. */
-	if (!state.enabled) {
+	if (!pwm->state.enabled) {
 		ret = clk_prepare_enable(atmel->hlcdc->periph_clk);
 		if (ret)
 			return ret;
 	}
 
-	return atmel_hlcdc_pwm_apply(&atmel->chip, &atmel->chip.pwms[0],
-				     &state);
+	return atmel_hlcdc_pwm_apply(&atmel->chip, pwm, &pwm->state);
 }
 
 static DEFINE_SIMPLE_DEV_PM_OPS(atmel_hlcdc_pwm_pm_ops,