Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3343380pxv; Sun, 4 Jul 2021 16:05:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTdhUKwYo/4H7ezgC72HlFKdEt6YG5mrV8plkmQs0XEW70tWEwjMtwHqUj+bS6CG6Is0XC X-Received: by 2002:a6b:d108:: with SMTP id l8mr9249737iob.65.1625439918375; Sun, 04 Jul 2021 16:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625439918; cv=none; d=google.com; s=arc-20160816; b=sMQb3uv/yDnasc4Lwjdfqk+YRUUL9BOBDQf5RH9kn0js3wC9AcNLKkWSY26Q9zYT87 n8ENnXUcfYKxxrTFi0xP+p98edDz7reEu6BL5pzGhjXGgcAILjiYRaCN5+4BgvhEQG0m Uy/7YsHXn0JEYuU3nb9h7XJ1k7ji5TLH50xXKjr9wK8YpSR61HhecGgWEG1KMLB8VAUG nbtSAR+BxaxftrRFpI/JcdIjXNQBKG/Lb6m0zkdpJYgmPz0y3zV7+ogHJRLWA1smexl3 JX3sq4p9DxC3NzSB1fOg9wBHja+l/QmqVWIj8+GQgGNDoYwYw5HyIiPaZlvAGxC8a7f+ hr3w== 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=P0/a4FhcG28MAzAgpy3uU8pLMvmnXx3FAqlshq9vl60=; b=oNpxGsDBFYikkeyQ8FznEh+WqgNg3jhkwZmkZiAVgwXgr8eiUnSval0q/ck7G9p7/M Ih1K7dwGK2DW9heIEf6Eqssan/TtZwbxa0h9VKk3OqcfskHysGlD4cvyFJ1fUjZYsKYm KDG+CAXuHsOS6aF74uDZHGxYZRHjGIdJWoa8F+3mo89oqUGGbNGLSO91bp7i5ANB2eY8 +qklRdxTRFwimvjnmANuh3E2hLB84jfWrbyHYTUFcmyZYX6n8FRim7C2sgqWZWS+znOs dADG/O+7YSQ9K8MTQe3hFMqkd5Qv6p2WN/FRjoYnainzYxoR9+J8gbvZTsS3Cw5ivffr Z/4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ERtPcYe6; 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 u8si14008126ill.90.2021.07.04.16.05.06; Sun, 04 Jul 2021 16:05:18 -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=ERtPcYe6; 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 S229898AbhGDXHG (ORCPT + 99 others); Sun, 4 Jul 2021 19:07:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:44936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229824AbhGDXHE (ORCPT ); Sun, 4 Jul 2021 19:07:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 890566135A; Sun, 4 Jul 2021 23:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439868; bh=IaLWchXqtwge6yNl+R9qPP2VlfBnURJKq1vPQED7chQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ERtPcYe6sU2mT1ILcs2J2vOesudaaKb+M2gVkvVuZqphhWan8Wlgj/MqMnUBMILi1 SxiWn1uTmEM0zKEt6ZGA0G4a+Y2M3thbvpykfuxoDR7Zu4rAhrrsFaq/rucbdXMk6g Qkz8sblYMKwGF5DfH1aj0qsEVDhDWg9weQGRXsL48MyV7kGNkeTIl85gg7Y+XPox/n qkNo46t5fVAUm85RmwCLW5SJ7cR0LnNZKDXHn61xnrKqTZJA5iE1hhPCdF6dr+98Ic 5wRJ52lGvL/IEjUnvOETwMnRJa/8Xy2DepXR0l+WgPhxdjRJSHVtQEvQDzS4VU3XOO IVQ+BYxfTupSQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mauro Carvalho Chehab , Jonathan Cameron , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.13 05/85] media: marvel-ccic: fix some issues when getting pm_runtime Date: Sun, 4 Jul 2021 19:03:00 -0400 Message-Id: <20210704230420.1488358-5-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 e7c617cab7a522fba5b20f9033ee98565b6f3546 ] Calling pm_runtime_get_sync() is bad, since even when it returns an error, pm_runtime_put*() should be called. So, use instead pm_runtime_resume_and_get(). While here, ensure that the error condition will be checked during clock enable an media open() calls. Reviewed-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/marvell-ccic/mcam-core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c index 141bf5d97a04..ea87110d9073 100644 --- a/drivers/media/platform/marvell-ccic/mcam-core.c +++ b/drivers/media/platform/marvell-ccic/mcam-core.c @@ -918,6 +918,7 @@ static int mclk_enable(struct clk_hw *hw) struct mcam_camera *cam = container_of(hw, struct mcam_camera, mclk_hw); int mclk_src; int mclk_div; + int ret; /* * Clock the sensor appropriately. Controller clock should @@ -931,7 +932,9 @@ static int mclk_enable(struct clk_hw *hw) mclk_div = 2; } - pm_runtime_get_sync(cam->dev); + ret = pm_runtime_resume_and_get(cam->dev); + if (ret < 0) + return ret; clk_enable(cam->clk[0]); mcam_reg_write(cam, REG_CLKCTRL, (mclk_src << 29) | mclk_div); mcam_ctlr_power_up(cam); @@ -1611,7 +1614,9 @@ static int mcam_v4l_open(struct file *filp) ret = sensor_call(cam, core, s_power, 1); if (ret) goto out; - pm_runtime_get_sync(cam->dev); + ret = pm_runtime_resume_and_get(cam->dev); + if (ret < 0) + goto out; __mcam_cam_reset(cam); mcam_set_config_needed(cam, 1); } -- 2.30.2