Skip to content

Commit ca162ce

Browse files
Navidemthierryreding
authored andcommitted
pwm: img: Call pm_runtime_put() in pm_runtime_get_sync() failed case
Even in failed case of pm_runtime_get_sync(), the usage_count is incremented. In order to keep the usage_count with correct value call appropriate pm_runtime_put(). Signed-off-by: Navid Emamdoost <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 1d7796b commit ca162ce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/pwm/pwm-img.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
129129
duty = DIV_ROUND_UP(timebase * duty_ns, period_ns);
130130

131131
ret = pm_runtime_get_sync(chip->dev);
132-
if (ret < 0)
132+
if (ret < 0) {
133+
pm_runtime_put_autosuspend(chip->dev);
133134
return ret;
135+
}
134136

135137
val = img_pwm_readl(pwm_chip, PWM_CTRL_CFG);
136138
val &= ~(PWM_CTRL_CFG_DIV_MASK << PWM_CTRL_CFG_DIV_SHIFT(pwm->hwpwm));
@@ -331,8 +333,10 @@ static int img_pwm_remove(struct platform_device *pdev)
331333
int ret;
332334

333335
ret = pm_runtime_get_sync(&pdev->dev);
334-
if (ret < 0)
336+
if (ret < 0) {
337+
pm_runtime_put(&pdev->dev);
335338
return ret;
339+
}
336340

337341
for (i = 0; i < pwm_chip->chip.npwm; i++) {
338342
val = img_pwm_readl(pwm_chip, PWM_CTRL_CFG);

0 commit comments

Comments
 (0)