Skip to content

Commit

Permalink
pwm: renesas-tpu: Fix late Runtime PM enablement
Browse files Browse the repository at this point in the history
Runtime PM should be enabled before calling pwmchip_add(), as PWM users
can appear immediately after the PWM chip has been added.
Likewise, Runtime PM should always be disabled after the removal of the
PWM chip, even if the latter failed.

Fixes: 99b82ab ("pwm: Add Renesas TPU PWM driver")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
  • Loading branch information
geertu authored and thierryreding committed Mar 30, 2020
1 parent 1451a3e commit d5a3c7a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/pwm/pwm-renesas-tpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,16 +415,17 @@ static int tpu_probe(struct platform_device *pdev)
tpu->chip.base = -1;
tpu->chip.npwm = TPU_CHANNEL_MAX;

pm_runtime_enable(&pdev->dev);

ret = pwmchip_add(&tpu->chip);
if (ret < 0) {
dev_err(&pdev->dev, "failed to register PWM chip\n");
pm_runtime_disable(&pdev->dev);
return ret;
}

dev_info(&pdev->dev, "TPU PWM %d registered\n", tpu->pdev->id);

pm_runtime_enable(&pdev->dev);

return 0;
}

Expand All @@ -434,12 +435,10 @@ static int tpu_remove(struct platform_device *pdev)
int ret;

ret = pwmchip_remove(&tpu->chip);
if (ret)
return ret;

pm_runtime_disable(&pdev->dev);

return 0;
return ret;
}

#ifdef CONFIG_OF
Expand Down

0 comments on commit d5a3c7a

Please sign in to comment.