From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 763B0C433B4 for ; Wed, 5 May 2021 09:55:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C9C4613D6 for ; Wed, 5 May 2021 09:55:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232503AbhEEJ42 (ORCPT ); Wed, 5 May 2021 05:56:28 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:57929 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232331AbhEEJ4Y (ORCPT ); Wed, 5 May 2021 05:56:24 -0400 X-Originating-IP: 93.61.96.190 Received: from uno.localdomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) (Authenticated sender: jacopo@jmondi.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id AE699FF809; Wed, 5 May 2021 09:55:24 +0000 (UTC) Date: Wed, 5 May 2021 11:56:08 +0200 From: Jacopo Mondi To: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Jonathan Cameron Subject: Re: [PATCH 14/25] media: renesas-ceu: Properly check for PM errors Message-ID: <20210505095608.cpe45sljqkyeyeez@uno.localdomain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mauro, On Wed, May 05, 2021 at 11:42:04AM +0200, Mauro Carvalho Chehab wrote: > 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 > Signed-off-by: Mauro Carvalho Chehab Looks good! Acked-by: Jacopo Mondi Thanks j > --- > drivers/media/platform/renesas-ceu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c > index cd137101d41e..17f01b6e3fe0 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) > -- > 2.30.2 >