Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3343338pxv; Sun, 4 Jul 2021 16:05:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAtm86VMdCLNor8vIBcXZ/pRN1Gf8l189My9fSva1rAiU27sBAm6z5Yy7M48FOnJPt8rhY X-Received: by 2002:a02:2a07:: with SMTP id w7mr9702465jaw.96.1625439912557; Sun, 04 Jul 2021 16:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625439912; cv=none; d=google.com; s=arc-20160816; b=LVYQvd9qg0/A4gfNBRDY3KYZXO8e4DxSaXjjh6ZygErp/UzJd6R+d6JZ4bOpK9g17d XBhQwMkCjHS7WWRw94HUG6PkALIB8D9oppN8UlNHvDqCf9Of3J8ttLYeH4npXD2UeSTB UN0aJ+uIq34OcmypO4pU7PrGRnbepDGIUoInMN2e+DC7v9DgWpLujNPqUd2kxnymaczG H47q5dyXz2KIwtdqETTvTsHBH7iyJxwmJdpK7Vg59MUUkSroqbH/0zrS98kZ3eh5Tvq+ xkRphvuTov1euyV5ezv/aCONuVTRC5aEIXmuME+CYZog50CrgkEtUeYYO4UXTxI48UPt /BMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uopKChHKArtbSm69SR9ZbXMMKOR5l7y3BPyCPgf2KpM=; b=qBkNRMiGiNFaawpwfmLrA5Sf80AFqLwHaJKcjfhkNv0fEeswvpoVok/vvDNMQGS+xn y0ML687N5aVDiBo8MzaYgopw300ChCCNFtozBtwpSjC2xo3v0bSsNO7q8CT5jfpKk9tT KMibQEaVf4tIV8nmqFSo6iHoGlCjHEIT3fZD9Z01O+g0GZbfUWOhOTbBn3S2VCmnz4wd QPMyeEmRs/Kqi4ixHEpuY1B5IO1VJgFO9tbVYlDwlzgTESj2OXxH9lqYeUW0knKfcbev CnFP1mTdS+HcfMle6vUwtzcasWaHNo/mD3oyiZPnNKx19W494D0eRUxx6/GXnFNFC438 HpKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jo1QkYSj; 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 w17si11641518iot.47.2021.07.04.16.05.00; Sun, 04 Jul 2021 16:05:12 -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=pass header.i=@kernel.org header.s=k20201202 header.b=Jo1QkYSj; 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 S229869AbhGDXHF (ORCPT + 99 others); Sun, 4 Jul 2021 19:07:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:44898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229794AbhGDXHD (ORCPT ); Sun, 4 Jul 2021 19:07:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3AAF8613E9; Sun, 4 Jul 2021 23:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439867; bh=+kWkDaGTsPPxJT4uqZ2LrjFWemhGoRnIa21NCqiEzNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jo1QkYSjzAht6OdgmIjhAoAmB5z2oHJ/is5UWsmVLdMu3m8NnPGrDu46mjXFFzvXK 4X2zZmRZ/h29WpnuSMpOy/4IUMUGaecamaYiWRedfnIeflhQJvc9UG7mNWA2tMKNxo r/DmpzyxNRUKUZf70r+pVm8D3VzPhvITGlNERfvHEMjTlGv5kj2aiVQqSN3gkIKHEd YN22W1MPUZZ9c8uDUtTLtzodmJqpKZ4fPHFEToCNKTKXn/WO4H9wFyp6uziuV7ctTA W37u3P3DLTD/QgiIqGbwIt3pKgavUVgrTs1eQUhyte2/V+PDUZMim85d4jCSho/1ul Hmcd1deQN95Xw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mauro Carvalho Chehab , Dan Carpenter , Daniele Alessandrelli , Jonathan Cameron , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.13 04/85] media: i2c: imx334: fix the pm runtime get logic Date: Sun, 4 Jul 2021 19:02:59 -0400 Message-Id: <20210704230420.1488358-4-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230420.1488358-1-sashal@kernel.org> References: <20210704230420.1488358-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mauro Carvalho Chehab [ Upstream commit 62c90446868b439929cb04395f04a709a64ae04b ] The PM runtime get logic is currently broken, as it checks if ret is zero instead of checking if it is an error code, as reported by Dan Carpenter. While here, use the pm_runtime_resume_and_get() as added by: 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. As a bonus, such function always return zero on success. It should also be noticed that a fail of pm_runtime_get_sync() would potentially result in a spurious runtime_suspend(), instead of using pm_runtime_put_noidle(). Reported-by: Dan Carpenter Reviewed-by: Daniele Alessandrelli Reviewed-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/imx334.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/imx334.c b/drivers/media/i2c/imx334.c index 047aa7658d21..23f28606e570 100644 --- a/drivers/media/i2c/imx334.c +++ b/drivers/media/i2c/imx334.c @@ -717,9 +717,9 @@ static int imx334_set_stream(struct v4l2_subdev *sd, int enable) } if (enable) { - ret = pm_runtime_get_sync(imx334->dev); - if (ret) - goto error_power_off; + ret = pm_runtime_resume_and_get(imx334->dev); + if (ret < 0) + goto error_unlock; ret = imx334_start_streaming(imx334); if (ret) @@ -737,6 +737,7 @@ static int imx334_set_stream(struct v4l2_subdev *sd, int enable) error_power_off: pm_runtime_put(imx334->dev); +error_unlock: mutex_unlock(&imx334->mutex); return ret; -- 2.30.2