From patchwork Fri Aug 16 12:31:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13766042 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 243FCC3DA4A for ; Fri, 16 Aug 2024 12:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=16nB20lne5nZUXu6hYGLNV1RBZ9sfyRh8sah/xieHmI=; b=g3sXbeeKO+B7L0runYtloUW8zU qWih4sIcbZZypEqbM3L0ThIx7ZXpZ+9ccqBiwOcA2dGidIZg3b8gcEaWGedD9pPkV3IwkZb0tmvSe dsHuMReAWZqK9iSmk/rAKRZmaHHMZ/jve32Emb6DTFBB1bHSNdHv+kvDZtMafkLnLqsRfI1c7JdV0 ydf7lbrX+S84cuItjxJFar6BudgHzwyIN72DUhOWP7POB8G7MKpvNkXkvRzaZV5kASed4gKzzdfyF H8LlBnlb48/KI3K2551UiltYU1fcWpdG3Igh61sSTDstcHB8Fg/Ho2aDpEPoDESJzuTfpGT08IOdP JT3WHRbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sew93-0000000Ct7x-08oj; Fri, 16 Aug 2024 12:33:29 +0000 Received: from mail-qv1-xf35.google.com ([2607:f8b0:4864:20::f35]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sew7h-0000000CsdL-37t8 for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 12:32:08 +0000 Received: by mail-qv1-xf35.google.com with SMTP id 6a1803df08f44-6bf7f4a1334so2804846d6.2 for ; Fri, 16 Aug 2024 05:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811524; x=1724416324; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=16nB20lne5nZUXu6hYGLNV1RBZ9sfyRh8sah/xieHmI=; b=AR8UYWYsGo2pNvBGrlk/a71dV6YV6r5edv+cQKGT26A2wNyC9qhhheKNt1cQNtU+dQ GmVtWcwUj0pAXX/tbzEVmdSeNGc3mv0h8zjuz7G3UAfmAW6DmxhzJamgrnPMcBYWtVTH l47SIcVDDr+Xieafq69K8HHaR/iZHpBR3Iwi8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811524; x=1724416324; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=16nB20lne5nZUXu6hYGLNV1RBZ9sfyRh8sah/xieHmI=; b=ZC6iSEAgXn+yxl24ksQlXtsoCepP+w0Gl+WtZ94fbp+Xq7TkOOq8Ppj2xmf3o//woJ 0xYi/UvPacKon3XOlCGnvC1akF5R0v6GxbVAvvKfQLiaUNwjO333gJLU2PyK1nmU3hJi YEAYTvyIRagehXpB0Iv6tAi04kxRJtYCjV+6jzl11GIDIuUNg17qtdlihoGxcZZC6QV6 ZBG+YAiPle/oiTdSKWSXkFkSHWv7C+mcG0K6/mWuaLb66/PAzuKZUdydQr5AJsFTht30 +1T2P69594S4Cj4WNKRUdLU52dD2n7FAqfWhJRIbh61NWTOX8UsONs0up1EFoMJb//5P +8Sw== X-Forwarded-Encrypted: i=1; AJvYcCV7E7L6NQWxWtBqyv+FT5PaBZo39gxKvHsHf+uDxhrvfJurPhGJ7E5s/S/APdkJudENAZqgtDStRky/MmjEjnJhyy//mky9Ege6CVKtNsf3queKYsQ= X-Gm-Message-State: AOJu0YyQFN+GHkZ0njJVYKsV70y+coXKfW7X3+SDFfkgDF980YctdIAk c8z7QO2/Cz3f7dGe7QHd8TQrfgyo0gvnNpdhlNZSJDrUhDmUJGmbdCLBCyhM4A== X-Google-Smtp-Source: AGHT+IEc/DNqda2J9XQ7o/We+y3QlRxp9UtmD1+ZU6guILT/Q3NfuJJCxXcnUIyCC+eWr3aG9Ceo3Q== X-Received: by 2002:a05:6214:5892:b0:6b4:fde8:8688 with SMTP id 6a1803df08f44-6bf7cebc8d0mr28626046d6.53.1723811523632; Fri, 16 Aug 2024 05:32:03 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bf6fef3107sm16881426d6.121.2024.08.16.05.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:32:02 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 16 Aug 2024 12:31:59 +0000 Subject: [PATCH v2 1/6] media: ar0521: Refactor ar0521_power_off() MIME-Version: 1.0 Message-Id: <20240816-smatch-clock-v2-1-c63105db07e8@chromium.org> References: <20240816-smatch-clock-v2-0-c63105db07e8@chromium.org> In-Reply-To: <20240816-smatch-clock-v2-0-c63105db07e8@chromium.org> To: Sakari Ailus , =?utf-8?q?Krzysztof_Ha?= =?utf-8?q?=C5=82asa?= , Mauro Carvalho Chehab , Sylwester Nawrocki , Andrzej Hajda , Neil Armstrong , Greg Kroah-Hartman , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Ricardo Ribalda X-Mailer: b4 0.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_053205_860102_F67030B4 X-CRM114-Status: GOOD ( 13.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Factor out all the power off logic, except the clk_disable_unprepare(), to a new function __ar0521_power_off(). This allows ar0521_power_on() to explicitly clean-out the clock during the error-path. The following smatch warning is fixed: drivers/media/i2c/ar0521.c:912 ar0521_power_on() warn: 'sensor->extclk' from clk_prepare_enable() not released on lines: 912. Signed-off-by: Ricardo Ribalda Acked-by: Krzysztof HaƂasa --- drivers/media/i2c/ar0521.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ar0521.c b/drivers/media/i2c/ar0521.c index 09331cf95c62..56a724b4d47e 100644 --- a/drivers/media/i2c/ar0521.c +++ b/drivers/media/i2c/ar0521.c @@ -835,14 +835,12 @@ static const struct initial_reg { be(0x0707)), /* 3F44: couple k factor 2 */ }; -static int ar0521_power_off(struct device *dev) +static void __ar0521_power_off(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct ar0521_dev *sensor = to_ar0521_dev(sd); int i; - clk_disable_unprepare(sensor->extclk); - if (sensor->reset_gpio) gpiod_set_value(sensor->reset_gpio, 1); /* assert RESET signal */ @@ -850,6 +848,16 @@ static int ar0521_power_off(struct device *dev) if (sensor->supplies[i]) regulator_disable(sensor->supplies[i]); } +} + +static int ar0521_power_off(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ar0521_dev *sensor = to_ar0521_dev(sd); + + clk_disable_unprepare(sensor->extclk); + __ar0521_power_off(dev); + return 0; } @@ -908,7 +916,8 @@ static int ar0521_power_on(struct device *dev) return 0; off: - ar0521_power_off(dev); + clk_disable_unprepare(sensor->extclk); + __ar0521_power_off(dev); return ret; }