From: Mauro Carvalho Chehab Date: Fri, 23 Apr 2021 15:03:23 +0000 (+0200) Subject: media: renesas-ceu: Properly check for PM errors X-Git-Tag: v5.14-rc1~165^2~381 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=220955ec3c84505ec6a75bea494ec61f5295ef7a;p=thirdparty%2Fkernel%2Fstable.git media: renesas-ceu: Properly check for PM errors Right now, the driver just assumes that PM runtime resume worked, but it may fail. Well, the pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors. So, using it is tricky. Let's replace it by the new pm_runtime_resume_and_get(), introduced by: commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") and return an error if something bad happens. This should ensure that the PM runtime usage_count will be properly decremented if an error happens at open time. Reviewed-by: Jonathan Cameron Acked-by: Jacopo Mondi Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c index cd137101d41ea..17f01b6e3fe0f 100644 --- a/drivers/media/platform/renesas-ceu.c +++ b/drivers/media/platform/renesas-ceu.c @@ -1099,10 +1099,10 @@ static int ceu_open(struct file *file) mutex_lock(&ceudev->mlock); /* Causes soft-reset and sensor power on on first open */ - pm_runtime_get_sync(ceudev->dev); + ret = pm_runtime_resume_and_get(ceudev->dev); mutex_unlock(&ceudev->mlock); - return 0; + return ret; } static int ceu_release(struct file *file)