pwm: img: Use only a single idiom to get a runtime PM reference
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 12 Nov 2021 19:00:15 +0000 (20:00 +0100)
committerThierry Reding <thierry.reding@gmail.com>
Wed, 17 Nov 2021 16:24:28 +0000 (17:24 +0100)
Currently there are two very similar approaches in use by this driver:
img_pwm_config() uses pm_runtime_get_sync() and calls
pm_runtime_put_autosuspend() in the error path; img_pwm_enable() calls
pm_runtime_resume_and_get() which already puts the reference in its own
error path.

Align pm_runtime usage and use the same idiom in both locations.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-img.c

index 1f3d6346ab860956ca7914d47c8be3fea929eb73..5996049f66ece366e23d22be732b683874900f71 100644 (file)
@@ -128,11 +128,9 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 
        duty = DIV_ROUND_UP(timebase * duty_ns, period_ns);
 
-       ret = pm_runtime_get_sync(chip->dev);
-       if (ret < 0) {
-               pm_runtime_put_autosuspend(chip->dev);
+       ret = pm_runtime_resume_and_get(chip->dev);
+       if (ret < 0)
                return ret;
-       }
 
        val = img_pwm_readl(pwm_chip, PWM_CTRL_CFG);
        val &= ~(PWM_CTRL_CFG_DIV_MASK << PWM_CTRL_CFG_DIV_SHIFT(pwm->hwpwm));