Skip to content

Commit

Permalink
pwm: img: Call pm_runtime_put() in pm_runtime_get_sync() failed case
Browse files Browse the repository at this point in the history
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 <navid.emamdoost@gmail.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
  • Loading branch information
Navid Emamdoost authored and Thierry Reding committed Jun 2, 2020
1 parent 1d7796b commit ca162ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/pwm/pwm-img.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ 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)
if (ret < 0) {
pm_runtime_put_autosuspend(chip->dev);
return ret;
}

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

ret = pm_runtime_get_sync(&pdev->dev);
if (ret < 0)
if (ret < 0) {
pm_runtime_put(&pdev->dev);
return ret;
}

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

0 comments on commit ca162ce

Please sign in to comment.