Message ID | a1230241a83a6abcd27b91edcafee1685232f81e.1620314616.git.mchehab+huawei@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: use pm_runtime_resume_and_get() on non-i2c drivers | expand |
On Thu, May 06, 2021 at 05:25:43PM +0200, Mauro Carvalho Chehab wrote: > @@ -1069,11 +1071,19 @@ static int tegra_vde_probe(struct platform_device *pdev) > * power-cycle it in order to put hardware into a predictable lower > * power state. > */ > - pm_runtime_get_sync(dev); > + if (pm_runtime_resume_and_get(dev) < 0) > + goto err_pm_runtime; Needs an error code on this path. These days the kbuild bot will send a warning for this eventually. > + > pm_runtime_put(dev); > > return 0; > > +err_pm_runtime: > + misc_deregister(&vde->miscdev); > + > + pm_runtime_dont_use_autosuspend(dev); > + pm_runtime_disable(dev); > + > err_deinit_iommu: > tegra_vde_iommu_deinit(vde); > regards, dan carpenter
07.05.2021 08:13, Dan Carpenter пишет: > On Thu, May 06, 2021 at 05:25:43PM +0200, Mauro Carvalho Chehab wrote: >> @@ -1069,11 +1071,19 @@ static int tegra_vde_probe(struct platform_device *pdev) >> * power-cycle it in order to put hardware into a predictable lower >> * power state. >> */ >> - pm_runtime_get_sync(dev); >> + if (pm_runtime_resume_and_get(dev) < 0) >> + goto err_pm_runtime; > > Needs an error code on this path. These days the kbuild bot will send > a warning for this eventually. Good catch, thank you.
diff --git a/drivers/staging/media/tegra-vde/vde.c b/drivers/staging/media/tegra-vde/vde.c index 28845b5bafaf..e025b69776f2 100644 --- a/drivers/staging/media/tegra-vde/vde.c +++ b/drivers/staging/media/tegra-vde/vde.c @@ -775,9 +775,9 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde, if (ret) goto release_dpb_frames; - ret = pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); if (ret < 0) - goto put_runtime_pm; + goto unlock; /* * We rely on the VDE registers reset value, otherwise VDE @@ -843,6 +843,8 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde, put_runtime_pm: pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); + +unlock: mutex_unlock(&vde->lock); release_dpb_frames: @@ -1069,11 +1071,19 @@ static int tegra_vde_probe(struct platform_device *pdev) * power-cycle it in order to put hardware into a predictable lower * power state. */ - pm_runtime_get_sync(dev); + if (pm_runtime_resume_and_get(dev) < 0) + goto err_pm_runtime; + pm_runtime_put(dev); return 0; +err_pm_runtime: + misc_deregister(&vde->miscdev); + + pm_runtime_dont_use_autosuspend(dev); + pm_runtime_disable(dev); + err_deinit_iommu: tegra_vde_iommu_deinit(vde); @@ -1089,7 +1099,12 @@ static int tegra_vde_remove(struct platform_device *pdev) struct tegra_vde *vde = platform_get_drvdata(pdev); struct device *dev = &pdev->dev; + /* + * As it increments RPM usage_count even on errors, we don't need to + * check the returned code here. + */ pm_runtime_get_sync(dev); + pm_runtime_dont_use_autosuspend(dev); pm_runtime_disable(dev);
Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") added pm_runtime_resume_and_get() in order to automatically handle dev->power.usage_count decrement on errors. Use the new API, in order to cleanup the error check logic. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> --- drivers/staging/media/tegra-vde/vde.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)