Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp306891pxy; Wed, 5 May 2021 02:43:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZFELeICOAF614gDjnIKKSNc3bsR7iPTtw13LfXP4ZkxoddKGC6E99WzB8KTHwXnyaJ3wp X-Received: by 2002:a65:618c:: with SMTP id c12mr27777589pgv.296.1620207829202; Wed, 05 May 2021 02:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620207829; cv=none; d=google.com; s=arc-20160816; b=nn+GZ6vlDcmhtotP3FM2a+QJfSlomF9F9RbB0xN9AQ9eSO2tSy5F/U3dzqXGDBvDLo iwWUcrhJLAN2Gxx+SHp79yhqE8mjbDc1+P9p1mNJS8yj38+Uv64xIiKll/cGQ7ILhrdy 91hcSVlpIYmsRvQ5oaCGHekMoQ+GW/+vKgeJu566tbSGFgJ3Tw+RFhV4HI5hKyuMdm9U M6VqJVD8xfb8nfwaQL9VPh7v+PfkVwE9eqcBKIdb91KRb1u3nqT7KOQeWDVY38GUA8ah Wf2frBEEY+2JjF8gnZEnieBxlH2Lm/e/UsG2ocMcHBU7CvIyzmypFEl6WWS2WDvNlqIy +Erw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=CX5nyhxGQLt8kQZhwKTE0FM6WiDteoziHYmPAWLlqck=; b=KtEZEOmVvykKRm9H8+c/brw7AazMJTys4k9SSopte4LUIWf1bi/mYO9HuwiBHNo0bn jQxUYSLufCpwD1dXUCDh0KYW+vXeGESLharHTiJIN1h/WwbiaporEvIg2FI6uG3NLJdJ 9pE6u3hAOOm16xqXrEFeeSOBH3piLJNxQrhV270YbJZjyyEbiwhmjk0t5VvhvsF0H5pW 9GC89A1/J/mVCSB2Rji8Wi+LBtPjg7SMHX+3rWchtIwyUelnaiI953le4s6tvXnIT4xY XMINzAEMkybPDenlb+0IUKGQb5PFneFq+jhpk/RHCodLAb6vPWPyrbZHGfKgQoFmgLpi CxYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=FWPk3sVY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x12si6946354pgj.61.2021.05.05.02.43.37; Wed, 05 May 2021 02:43:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=FWPk3sVY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232994AbhEEJnl (ORCPT + 99 others); Wed, 5 May 2021 05:43:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:48656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232435AbhEEJnR (ORCPT ); Wed, 5 May 2021 05:43:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 44BC161423; Wed, 5 May 2021 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=6MhSd0Gx/6VuoMI9uWT2v1VRzcCGAFf3IJvFSMDOw+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FWPk3sVYJHJFzNk5hqt10Ix93PRAUjxWb5bPNk0UkGojFOgypyd5HMdoKdDdkjIEC FyYah+GV1zFdewE7dpqboFKqO4wcfPy8jGC5Fr+mv44rI/AvHfZRgqZgJ5QVAM0skq ve0rBKhepGUR1xCOq5IhUkPzDbZ/zWc43XQdw4rXgXOS0+t41Tg284oXVBq+WvqG99 MRIMHX5TC5iqXqH6heIRMiTJiln3DUNsQdjDwTagu+R7loMe7/vkynzzdmOGCSsMe+ 2vszbikT8+ly+cOVJZaS+453+Ow+I8yhk2dUcQgcjOIpXPKnuGuNko/ds5ssfsTrOx LOSBaFL3lQSMw== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2r-00AHwU-6x; Wed, 05 May 2021 11:42:17 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Jacopo Mondi , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Jonathan Cameron Subject: [PATCH 14/25] media: renesas-ceu: Properly check for PM errors Date: Wed, 5 May 2021 11:42:04 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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