Skip to content

Commit d5a3c7a

Browse files
geertuthierryreding
authored andcommitted
pwm: renesas-tpu: Fix late Runtime PM enablement
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 <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 1451a3e commit d5a3c7a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/pwm/pwm-renesas-tpu.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,16 +415,17 @@ static int tpu_probe(struct platform_device *pdev)
415415
tpu->chip.base = -1;
416416
tpu->chip.npwm = TPU_CHANNEL_MAX;
417417

418+
pm_runtime_enable(&pdev->dev);
419+
418420
ret = pwmchip_add(&tpu->chip);
419421
if (ret < 0) {
420422
dev_err(&pdev->dev, "failed to register PWM chip\n");
423+
pm_runtime_disable(&pdev->dev);
421424
return ret;
422425
}
423426

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

426-
pm_runtime_enable(&pdev->dev);
427-
428429
return 0;
429430
}
430431

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

436437
ret = pwmchip_remove(&tpu->chip);
437-
if (ret)
438-
return ret;
439438

440439
pm_runtime_disable(&pdev->dev);
441440

442-
return 0;
441+
return ret;
443442
}
444443

445444
#ifdef CONFIG_OF

0 commit comments

Comments
 (0)