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; } From patchwork Fri Aug 16 12:32:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13766043 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 B0636C52D7D for ; Fri, 16 Aug 2024 12:34:16 +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=rfdvYEITLctEiJZFaHWRY9JyibDLYc0ZAVB9q9sxkkI=; b=iWHFQcDR4rJSiERG+7lRpqz5EK 5/2U30G3/VXxtArm8dzDXS5Ii9PPXiiWpy2yVOsuz9CP+dbBcTZuW4de3898ntWQxXVRf6pMHWwsS 68tSW159r1MXfgNdqsYvz+28NrLZXfKFksFb+VAtL//2+p2pSyLa3/4wsCJWQQ4S8/DN6TphwsDWK wq7NczxgTLXaQkKJAlYw2Uy2ddDCborTXGudNARsVMcJhbq3MLnHv7yT0LDqYJzBZm2vhAjO41vws qFB5uSffrG8WOsnLomzDbqJiUkv/fQAtdRB7NWT8JytneMuBn7WMI30O/rMbtQU9ruLDeaKRfz0QH AeMbYEkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sew9g-0000000CtIp-1moY; Fri, 16 Aug 2024 12:34:08 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sew7h-0000000CsdO-3nJg for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 12:32:08 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-7a1d3874c1eso118587185a.2 for ; Fri, 16 Aug 2024 05:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811525; x=1724416325; 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=rfdvYEITLctEiJZFaHWRY9JyibDLYc0ZAVB9q9sxkkI=; b=Hv2T0JrzNkzPE32xhkCsFlKFqhQnzZfjXSHWR981Si7Lq88fT/0h3QfJzvfIpABRsm g38bc+J4X+ESqm5GFhQxD7JuVieJEmJAMloiKenlbhu7JwsoNjuhQGjjWHI2JbXy9YAU rZA7WkAY8QzS5qTnPsxDpomejy3y2xlocFbHs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811525; x=1724416325; 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=rfdvYEITLctEiJZFaHWRY9JyibDLYc0ZAVB9q9sxkkI=; b=DR8cOT+32SqEixx2McjK/wyuO+KysaCo+lsVJ2s59VYCxaUarvF1/JW+CZzRxN7gtU 9y894OhGxo3qcoBASe8cm/ytDVRonmInjq3I+BPjH6mA6OAAUgwSy5k2PJGFkSatngca Rz/hvXpzLnRIqmMBz/+nkhIqVvNDb3NnfMODMydlAdZKPCMO8Gz42Aj7xGlt/6+ZgnKq iJwCafp1V6M12p7Fb4ntAiq1gNzQAayZrIwQESPP9yZOZzDNJz/gL/8sCY0gqceeTV+F ZoSiB8YK92mB7uUX/YDfztrIta6ZRo9MgNjLb+CgPirYaQg8r/R4Fha93TBplzWnfgZy zQGw== X-Forwarded-Encrypted: i=1; AJvYcCWQl/HTtZvaDDZ1K5x0FYNCQkCPhPVjzztpGaDmqXXCU2OE3I9N1fvVcgH9lLTIZ2SWe4zqjqSLgOpo3fU7gGU4@lists.infradead.org X-Gm-Message-State: AOJu0YxKnv0HPqJA4NB9C2dVIC5V1MpMzcCnqQcbxf4UHt4y+l9goxIT BCh8J0QJY72Yip/nSRBSq+3PHEkQuiYUxLxL9SFIfsv6teAPwXj9P86vHDcWpg== X-Google-Smtp-Source: AGHT+IEykfMYCYnAHIqKejoI5UsxnxEpAhtpapnpWCBE4rLm0ZmyJu5Jr8Cmioy5du0vYTkAoMT82A== X-Received: by 2002:a05:6214:4520:b0:6b7:ae86:e33e with SMTP id 6a1803df08f44-6bf7ce59f5cmr23889246d6.37.1723811524592; Fri, 16 Aug 2024 05:32:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:32:04 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 16 Aug 2024 12:32:00 +0000 Subject: [PATCH v2 2/6] media: i2c: ov5645: Refactor ov5645_set_power_off() MIME-Version: 1.0 Message-Id: <20240816-smatch-clock-v2-2-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_972231_60F809FE X-CRM114-Status: GOOD ( 12.21 ) 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 clk_disable_unprepare(), to a new function __ov5645_set_power_off(). This allows ov5645_set_power_on() to excplicitly clean-out the clock during the error-path. The following smatch warning is fixed: drivers/media/i2c/ov5645.c:690 ov5645_set_power_on() warn: 'ov5645->xclk' from clk_prepare_enable() not released on lines: 690. Signed-off-by: Ricardo Ribalda --- drivers/media/i2c/ov5645.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index 6c2d221f6973..0c32bd2940ec 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -635,7 +635,7 @@ static int ov5645_set_register_array(struct ov5645 *ov5645, return 0; } -static int ov5645_set_power_off(struct device *dev) +static void __ov5645_set_power_off(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct ov5645 *ov5645 = to_ov5645(sd); @@ -643,8 +643,16 @@ static int ov5645_set_power_off(struct device *dev) ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x58); gpiod_set_value_cansleep(ov5645->rst_gpio, 1); gpiod_set_value_cansleep(ov5645->enable_gpio, 0); - clk_disable_unprepare(ov5645->xclk); regulator_bulk_disable(OV5645_NUM_SUPPLIES, ov5645->supplies); +} + +static int ov5645_set_power_off(struct device *dev) +{ + struct v4l2_subdev *sd = dev_get_drvdata(dev); + struct ov5645 *ov5645 = to_ov5645(sd); + + __ov5645_set_power_off(dev); + clk_disable_unprepare(ov5645->xclk); return 0; } @@ -686,7 +694,8 @@ static int ov5645_set_power_on(struct device *dev) return 0; exit: - ov5645_set_power_off(dev); + __ov5645_set_power_off(dev); + clk_disable_unprepare(ov5645->xclk); return ret; } From patchwork Fri Aug 16 12:32:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13766059 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 28A56C52D7D for ; Fri, 16 Aug 2024 12:36:14 +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=zTE0ZAwpLEek+mC97zOMxZoDXTrbmisRlZ9024oJ1x4=; b=31CTtzQTwpZ+wVUsdf4geadbNV u5PEANoBYZBpY17ceiWbiW0VmCx8/xZS4rVoJueiIG/39qVZIaKFb9sRC5DVUfTmpeI+TCidZlyLc 4yO5dvwSR65spGL46oJPzQj30vgHP9mHj4oe9Eg6/RPVq21ai93qGDuMLaE8n5Xmx1RU0tGll7HiS 8vKEw3lCNtfJgJdjSzF0ZGiYm7kUi7vdtSn6fzcjHrg9dQutfk/IqyvI2VD6EdmfNco4nNl9mA5Pi co5WYlwTaSAPRD1N1g8zkvO3yvCm82/gubKdS6dw7YrC0MtVQAluoxiewmu4qFPUCMZRFd6ccF0Gk RIBObuoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sewBW-0000000Ctah-1ppA; Fri, 16 Aug 2024 12:36:02 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sew7q-0000000Csiz-1XEv for linux-arm-kernel@bombadil.infradead.org; Fri, 16 Aug 2024 12:32:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=zTE0ZAwpLEek+mC97zOMxZoDXTrbmisRlZ9024oJ1x4=; b=AjzScYMMp/QcjauXyvjcCJ1hq1 sAdWbN5D4UM+1PhvXN1JMoHZQjMpTtsHT5VsgUMh1kkbWCukg/VeUhKBptIIFZLSTYSQrj69YtJZx cV0EdVpMiT+5vXOEEjMeQKOpTOEliHfs/cGpPPfcFyye3yjxGeoF/AW9xPvOerf42x1O3p34zfwWD yPbaHy2lEW3Xc9kfbih5nxgr2NuKYEukFuye3drYdz3md3181flxAbNcMWmddmsojR1oJv6r9DptG D07caqvL4QwTafJPNp596+kY+uWGdovOtM2F3cfjBUCXIkcgNZqTaemxPX2eSBGbOVvJNIi7HnzjJ CXMuJ4vw==; Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sew7l-00000008eGn-1XpX for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 12:32:11 +0000 Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-70940c9657dso947010a34.1 for ; Fri, 16 Aug 2024 05:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811525; x=1724416325; 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=zTE0ZAwpLEek+mC97zOMxZoDXTrbmisRlZ9024oJ1x4=; b=Q+0G3KguCePek+UOGUII+wqaJRg5MAQ4uupAs+nhPvczvPcGYNK2UBY+q0vthSCYBw r469Z5NzAF19o1G3438arb9VXRfOLMk7anXCvd7yLXRSt9hbwqtLuhSOxh83QP1/C4fe RL4eURSWqv01ziuE5J4VDP9VYQIP8GzrD9TuA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811525; x=1724416325; 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=zTE0ZAwpLEek+mC97zOMxZoDXTrbmisRlZ9024oJ1x4=; b=ERrFqOiv+G0JoP1XmU4H3s/zXlXg6fMgeqDxGRQbPcL5c+zEBuBO+4mbnubgP9rCth ic80j6qF9ePCoSCtSfAIndUHM9QwrJb2A4VINYLlhoPTfKswx4zC24o5+7qhFLTq5xUX quYfdiC3S6lGhU61+73/4rdJralpBfkOW2RsYgnUDP5vFim34w3r4GZN96gZBzrwq2oU yots6KmHOJtZegv8uoCbV1dmrId6uSH8L5LFxNlr9qC71zgbKS4RZUiI3efjYExHuULw gDgjZLPN0P8Y8yHjkCEPZ/4KVIP0PsIMeUHeOOGipInUAaa5jLUy+5NYyZU4RGYATzB2 Bl3Q== X-Forwarded-Encrypted: i=1; AJvYcCW3QUg0eeH+b9rvy8Za14SNYagfnUtl/jhofDyyh4B3VF/uIgeyco/vS+dhzvnY5NMV739mRFkHZI7BxiZBSDye@lists.infradead.org X-Gm-Message-State: AOJu0YwIqWMDKcYrnNq7Ot7CMJwqYwL+GqlHd30p1fC+A+KwHVOugR8v Z4mQTtNeXwxoCQkkwbtB7yLtANoaYGqdmM+rYizvQr6AmgBoDao6eArT1mfN3Q== X-Google-Smtp-Source: AGHT+IF/lV0FO6kyi+dWBfhad0hlEJtndvHJ5Sx3xQGXBIEu/XLpM3FeOaUjff8fbn0cH1v4QPeYnA== X-Received: by 2002:a05:6830:3109:b0:709:3462:a4b6 with SMTP id 46e09a7af769-70cac84216fmr2835025a34.9.1723811525644; Fri, 16 Aug 2024 05:32:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:32:05 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 16 Aug 2024 12:32:01 +0000 Subject: [PATCH v2 3/6] media: i2c: s5c73m3: Move clk_prepare to its own function MIME-Version: 1.0 Message-Id: <20240816-smatch-clock-v2-3-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_133209_848497_2DB9A198 X-CRM114-Status: GOOD ( 12.56 ) 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 Smatch is very confused by a clk_prepare_enable() being called in an error-path. Fix this warning by moving the clk_prepare_enable() to its own function. drivers/media/i2c/s5c73m3/s5c73m3-core.c:1425 __s5c73m3_power_off() warn: 'state->clock' from clk_prepare_enable() not released on lines: 1425. Signed-off-by: Ricardo Ribalda --- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index e89e888f028e..7716dfe2b8c9 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -1392,6 +1392,16 @@ static int __s5c73m3_power_on(struct s5c73m3 *state) return ret; } +/* + * This function has been created just to avoid a smatch warning, + * please do not merge into __s5c73m3_power_off() until you have + * confirmed that it does not introduce a new warning. + */ +static void s5c73m3_enable_clk(struct s5c73m3 *state) +{ + clk_prepare_enable(state->clock); +} + static int __s5c73m3_power_off(struct s5c73m3 *state) { int i, ret; @@ -1421,7 +1431,8 @@ static int __s5c73m3_power_off(struct s5c73m3 *state) state->supplies[i].supply, r); } - clk_prepare_enable(state->clock); + s5c73m3_enable_clk(state); + return ret; } From patchwork Fri Aug 16 12:32:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13766057 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 C84D6C52D7D for ; Fri, 16 Aug 2024 12:34:58 +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=mnNFu46JmywYP9gLg0BBlkiX4LJAIV8Vvr47+Nzo0m8=; b=jb1nS2/a6JNyyeiqyOeuVqfocx AZJ+OMf76RTe+QwQBvIHmgdnX6CMec0eMRzdlJhJDROqPJ+60zkrvca70xlnAR1dOqbYXh7Por1ep 11b2G8v+1ALloMjlMgshA7/OZqqv+QVQf3OPdnu8q6KDVLNOb5AFD9pkeRUlXNTnRJrNQ/Ms9Yv0O z4wIiqICp6U+3cU7aqNUHkJ/0tcr+ok6vvzYFfkTcNq6sXAZCTpSrnzo04R2vB6w/yoxYf1GLa1Ui GHGTllN/Du4jhD4HGYAh+u0hUuBz+vPwKtBc5yB1AXJKEtZraNBKOTaFqkrxe7+60JAkxJrKv57bq MuIrAKzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sewAI-0000000CtO3-0kbr; Fri, 16 Aug 2024 12:34:46 +0000 Received: from mail-qv1-f44.google.com ([209.85.219.44]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sew7k-0000000CsfW-3Ubv for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 12:32:11 +0000 Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-6b78c980981so9612486d6.2 for ; Fri, 16 Aug 2024 05:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811527; x=1724416327; 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=mnNFu46JmywYP9gLg0BBlkiX4LJAIV8Vvr47+Nzo0m8=; b=N26n4DgTqQ5pwzh214O2DcF1o5v9x4tG5VCfh2gEY+XJyJnJN/LKIKi3ISEGWGnFnz 6nYG1yD4q+KGNrGYZVCKUeNb6ADBk0kEajnSB/x1Ofe/pcl9AE3OHh8/LzxZyRD2ps9y cXAYvStUOTtsPbix5IF93GjB/bLYsjvbXV2RA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811527; x=1724416327; 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=mnNFu46JmywYP9gLg0BBlkiX4LJAIV8Vvr47+Nzo0m8=; b=Ug2yfj4YHg+KXUDQOZfNuEQPHWTnG3CYZibJBg6ay7ZJgaZLCOn8M629grU7Ho209h Nyrj8qLZjDk+EdCwUamS7dRLy3N+vcJO59EX+kdO2FiyAGIZcm4qCRnIGXzlb3zRt5co uaHDVI2QZz0u9c7q/YvzvYkN3ILJNVywmuReEdNoCaOxvoozF/J2o4nv1UG4NKEjy5SF U7MEnIWqZ+TUCMBeIYPwqDlEEYbFeP4FgCRqjD2CsoIcEEPk3xLASpmSKPLG616Ye1Gr QDhzmKylQUiWpgLroZYfbhOOigczEZ4E8kMZOZ7M2tOIy2+bsclUTHnjxm9txykGjDSo gkLg== X-Forwarded-Encrypted: i=1; AJvYcCVUZz5lKaz9Z5+Lx83kuQEhu7m5RWV966BQ9LEZSW8BrQps2VXq2kKXyFXJdwu2M20VWWLlCuzXAZ81DV7xn9qTSynnysgIwLy/Xxtgcmu/aQNcBxU= X-Gm-Message-State: AOJu0YxDkp2uXUc2lc3IWf07H0ileGRg7GIspB0q3oR3hEDbVBB+r0hN miimDFt9xi5gELwJbeiLQ8isKrjzNu42K+kp0uJYmfnnWnpN+44Rpc/gBSv1Tg== X-Google-Smtp-Source: AGHT+IEXSYQZCNIKPB9LFR6rX4AtZ6JNPVrFndATYre1U0wDC52xZRkYWs1UJ+Wy8jMyb2SytEJSUQ== X-Received: by 2002:a05:6214:a67:b0:6bf:7f5b:1d3 with SMTP id 6a1803df08f44-6bf7f5b0255mr17407566d6.16.1723811526538; Fri, 16 Aug 2024 05:32:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:32:06 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 16 Aug 2024 12:32:02 +0000 Subject: [PATCH v2 4/6] media: tc358746: Move clk_prepare to its own function MIME-Version: 1.0 Message-Id: <20240816-smatch-clock-v2-4-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_053209_081609_D2B8761B X-CRM114-Status: GOOD ( 13.29 ) 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 Smatch is very confused by a clk_prepare_enable() being called in an error-path. Fix this warning by moving the clk_prepare_enable() to its own function. drivers/media/i2c/tc358746.c:1631 tc358746_suspend() warn: 'tc358746->refclk' from clk_prepare_enable() not released on lines: 1631. Signed-off-by: Ricardo Ribalda --- drivers/media/i2c/tc358746.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c index edf79107adc5..389582420ba7 100644 --- a/drivers/media/i2c/tc358746.c +++ b/drivers/media/i2c/tc358746.c @@ -1616,6 +1616,16 @@ static void tc358746_remove(struct i2c_client *client) pm_runtime_dont_use_autosuspend(sd->dev); } +/* + * This function has been created just to avoid a smatch warning, + * please do not merge it into tc358746_suspend until you have + * confirmed that it does not introduce a new warning. + */ +static void tc358746_clk_enable(struct tc358746 *tc358746) +{ + clk_prepare_enable(tc358746->refclk); +} + static int tc358746_suspend(struct device *dev) { struct tc358746 *tc358746 = dev_get_drvdata(dev); @@ -1626,7 +1636,7 @@ static int tc358746_suspend(struct device *dev) err = regulator_bulk_disable(ARRAY_SIZE(tc358746_supplies), tc358746->supplies); if (err) - clk_prepare_enable(tc358746->refclk); + tc358746_clk_enable(tc358746); return err; } From patchwork Fri Aug 16 12:32:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13766060 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 1EA05C52D7D for ; Fri, 16 Aug 2024 12:36:51 +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=M3LNSQjxs6knu07oTqqXD2vtqpOl0khzecMqHctA770=; b=SiNtFe67H3WS4crKBgwq5j11pX mRtqm0kAwBZtWUEH52PPdQlkjdOTLCmKpAiQ+GxYk0yr7yRMlMrUDyLfvp+31QE5dJqKSEOl+TQGQ aQ6BUt78WOXyUO98jMwjIT3lT/NGpATUwAUG8zxHPQt5WdbFN0P0ugI1WBY4LA+Z6Q70FiRavX472 xOk5SbdlYSC642Jp+ArJSoiS3eSqc+LrfT6+g9gIKzinqDVDCZQ4hVW+YhvoJNSQojQMdrWprQBNL YoKp2BEyMXoj0i3obwszRrbANmJbx/q1ReJ18FZr75cwDPnU58UQ1TubvKlIlqw2WwMtBGK3VD9Kv r0uS/C+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sewCA-0000000CtjY-1r3c; Fri, 16 Aug 2024 12:36:42 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sew7r-0000000CsjB-1ReB for linux-arm-kernel@bombadil.infradead.org; Fri, 16 Aug 2024 12:32:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=M3LNSQjxs6knu07oTqqXD2vtqpOl0khzecMqHctA770=; b=JE8E3X0HX8uKAd7yx5/qFGHOdX mTk6dWV27uW+lbbMdd8iSRneKUJlMs0AmXlC/ad8rZ9LvkyRXG9ZIJjDGB+vrRVftlnD//4Uac75D 1g+njBuy1QMGZULw7C7VD94cpsHmSHCfb0kBOe2hyG7PGHtB41iHe8ZjnQnZZ9eo4EA8LwK1C+Ti2 fnshO7WBpUO/CfO8vAVr4qf0wY/5FZiH11t9qevIFdUFolfRcjSwt2jTl9i4oTaNSmC6xUalliewF emgyyEeCdD7AofNbvA9BEsjgsNLJQrWLaTJubdDfaS2ZrLguaqy06JYbfXdC3MREXH1Nd7Xp872eY 6Y97MoLw==; Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sew7m-00000008eGq-2DNj for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 12:32:13 +0000 Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-6bf7ad1ec3aso6789626d6.0 for ; Fri, 16 Aug 2024 05:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811527; x=1724416327; 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=M3LNSQjxs6knu07oTqqXD2vtqpOl0khzecMqHctA770=; b=RB3mXAzWStMJvAojlIVaK/I8l7uWB7lfAEB5efGGoRcyF0x3REPD9fFlyaI5siGziW Ja9fbeXvIdICEmwzAFeBICtsKE7SFb94I/A8R4cKM8Z6ZtDeukHTjVm75KFnmfnmp971 rMwR237TxnYC0j6z7QhkE2DpiEHEB3VOdl7MI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811527; x=1724416327; 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=M3LNSQjxs6knu07oTqqXD2vtqpOl0khzecMqHctA770=; b=t5rjDIymVHfHR74qqa7LFAa4E96pdgthIcjEd8mP0kXCYtnyQYP14Y4SQV3oisBmpY S0988euubknvwZItyN1GGlMC/8zVjMcsCZ3Ef4PeytML4uVccukspDU4SSJ4tC6sVUsE QXjjQfaHZ1uOhUMLOTX0plONR/2JpywiCzLw+QtvzRTrN7U4+fsDWtKiDMAN3kMJhLjZ epugwjBLP/R+zEHfN0XqOItcFd6y0DEEYt+Bkd6UcGgsWltJBDUy5n9JxcnR6mY8ggiZ Wk3Wu336nMyutE+028IUXuisdy8gcdZY7jrODbhghKLD7bON4EyFciRgyh9tkK64vby2 b7pw== X-Forwarded-Encrypted: i=1; AJvYcCXXHBWqM7IQzkg+vv6N0jztjoFYddmy2v5eTVwDIPjLnE2CJFCoNrJ0LgCuhYpkD2o0TJg+4KKHuJzUsRU2AjagFqrgYdIjx+/fhDnJLZb/rBiH2B4= X-Gm-Message-State: AOJu0YyxjlyJdAXSLRLrMgw5NK2nCPKVWDeQX+h1iJytQDDHhLWvK5f4 Eyti6WfyAKDarozTQ0omAxQAiwVSRWI/1nifmH1lNXQeki2ckYlYgLq9dHDGig== X-Google-Smtp-Source: AGHT+IHYD7aRmKGXgp+t/Ifehq3d65H0DR+M710hdZy/In2eSfy3ZYdXCjNDHAYDxXFnFLaObLyDlQ== X-Received: by 2002:a05:6214:3d9c:b0:6bd:83cb:1b8f with SMTP id 6a1803df08f44-6bf7ce5a411mr36042536d6.36.1723811527255; Fri, 16 Aug 2024 05:32:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:32:06 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 16 Aug 2024 12:32:03 +0000 Subject: [PATCH v2 5/6] media: meson: vdec_1: Refactor vdec_1_stop() MIME-Version: 1.0 Message-Id: <20240816-smatch-clock-v2-5-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_133211_164897_E31D0439 X-CRM114-Status: GOOD ( 12.58 ) 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 __vdec_1_stop(). This allows vdec_1_start() to explicitly clean-out the clock during the error-path. The following smatch warning is fixed: drivers/staging/media/meson/vdec/vdec_1.c:239 vdec_1_start() warn: 'core->vdec_1_clk' from clk_prepare_enable() not released on lines: 239. Signed-off-by: Ricardo Ribalda --- drivers/staging/media/meson/vdec/vdec_1.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/meson/vdec/vdec_1.c b/drivers/staging/media/meson/vdec/vdec_1.c index 3fe2de0c9331..a65cb4959446 100644 --- a/drivers/staging/media/meson/vdec/vdec_1.c +++ b/drivers/staging/media/meson/vdec/vdec_1.c @@ -129,7 +129,7 @@ static u32 vdec_1_vififo_level(struct amvdec_session *sess) return amvdec_read_dos(core, VLD_MEM_VIFIFO_LEVEL); } -static int vdec_1_stop(struct amvdec_session *sess) +static void __vdec_1_stop(struct amvdec_session *sess) { struct amvdec_core *core = sess->core; struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops; @@ -158,10 +158,17 @@ static int vdec_1_stop(struct amvdec_session *sess) regmap_update_bits(core->regmap_ao, AO_RTI_GEN_PWR_SLEEP0, GEN_PWR_VDEC_1, GEN_PWR_VDEC_1); - clk_disable_unprepare(core->vdec_1_clk); - if (sess->priv) codec_ops->stop(sess); +} + +static int vdec_1_stop(struct amvdec_session *sess) +{ + struct amvdec_core *core = sess->core; + + __vdec_1_stop(sess); + + clk_disable_unprepare(core->vdec_1_clk); return 0; } @@ -235,7 +242,8 @@ static int vdec_1_start(struct amvdec_session *sess) return 0; stop: - vdec_1_stop(sess); + __vdec_1_stop(sess); + clk_disable_unprepare(core->vdec_1_clk); return ret; } From patchwork Fri Aug 16 12:32:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13766058 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 55F2FC3DA4A for ; Fri, 16 Aug 2024 12:35:32 +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=yVxZXuTJqaJ10E0yGjjv9nH2alidPK1Y4VYj7sM9de4=; b=wdeQR8MznFJEgNLe/lcL+mhlXy vDRc6quXCzP5yNkulOjvDgHAZvXD/Ir9VvO6Pr9cSMgUFZkGSmdLyBRKEUeFXmlQyTUwThjbx3604 KL+etaK41AcvePBBnboGGDUxEX4DlDnkGgzmIrXsY8B3VxELpUpPihZIU3nQKv7bwlm1MUoFOlZt8 CjqT53ScyLbj8hu5S8mGO05VC3pnlZPadLywHOTOfK4mQtTiIotdLuFMgJSUdjgKLovHHO1N/BXAh 4t93n1KR7LBEVytZilmx2pm0wxU8I6HWv+fHGJ6/hsIcThtZ0VCLl9ypOEReorRFuObz5zElSfYev 97PBXJIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sewAt-0000000CtVC-3qUU; Fri, 16 Aug 2024 12:35:23 +0000 Received: from mail-qv1-xf2e.google.com ([2607:f8b0:4864:20::f2e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sew7m-0000000CsgE-0iGa for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 12:32:12 +0000 Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-6bf7ec5c837so3636396d6.1 for ; Fri, 16 Aug 2024 05:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811528; x=1724416328; 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=yVxZXuTJqaJ10E0yGjjv9nH2alidPK1Y4VYj7sM9de4=; b=FwBLhip8Yu+p2AgovlMOSnKoYxBZjV0DDmHC/JSvQF/ftyg23URYqZ6DEAM3TVJMYh +Nbxkbwh2Mt5yDhoFYYqZwJ6BUQqReD0F83bY4tgUc98TLjOJ4Rm15y1j6p5beeQU3ak FYwu2in/wG1Ebipsf83VtdaQ9GERqBpE1EMLU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811528; x=1724416328; 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=yVxZXuTJqaJ10E0yGjjv9nH2alidPK1Y4VYj7sM9de4=; b=e6YrcaMmldsk4iY3/BH+80Z7Uk8pLk4ku/bR0v7IE0frCgAkl1pjFfkEU9JdrPj3qF uA9QWPn2DBEUAdg4ZPMLGAuTMJK8mNbRUvLOxEC2+BB7CnPQSecvk6wMC6kDGwYjNMHb hxMcW22n65DNnyHyiR70kaWW+JGR+YFW7fSVrOxQP/GyvA/R1oMk2YfkkQV2DRM2WWJ/ dVKpeHQ44AWwdMTK3svM/XkHwWQPRYrojm5cGS+QAF6jvQsXQQjh3DoQMQ9tGgAElgd8 OKsEb0Z70oECBAbm3+mKvNBqEWa9iS9kQ5mgkrpzb4STr9Yr2/h9XVKy1deMDu5b5lGR +62A== X-Forwarded-Encrypted: i=1; AJvYcCV/AGAr2H4Di3kn6V07VJ2uke0XRrubCn7aSUyXEA9mXhZRNgZb0s7v2B//sN9chOclRoOAuAGKX7gJtmUHnZohAPZUI/GX08tuZqn1AqhsTRgZilM= X-Gm-Message-State: AOJu0YxdTbSn+LQ70mSoEOauRHYzAie9TGzILjtPu7TTaJrtQ7U72/ZM jMClUsnItEomSQqpAUkz0e7xGUXx/5a+Xpu4tsu2jcdHZtALsgyxQIAP9tWhNg== X-Google-Smtp-Source: AGHT+IHxo1lFSQMX1cM/4MwpLU2TEtbVsyk63XfQG/g27+OnQuVnbh1zDXFyHf9x2ZFHVGoE5m/EQQ== X-Received: by 2002:a05:6214:540a:b0:6bf:700f:a3b7 with SMTP id 6a1803df08f44-6bf7cd7ac78mr23067056d6.9.1723811528290; Fri, 16 Aug 2024 05:32:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:32:07 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 16 Aug 2024 12:32:04 +0000 Subject: [PATCH v2 6/6] media: meson: vdec: hevc: Refactor vdec_hevc_start and vdec_hevc_stop MIME-Version: 1.0 Message-Id: <20240816-smatch-clock-v2-6-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_053210_221991_8EAE46F9 X-CRM114-Status: GOOD ( 15.17 ) 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 Make a new function __vdec_hevc_start(), that does all the initialization, except the clock initialization for G12A and SM1. Factor out all the stop logic, except the clk_disable_unprepare(), to a new function __vdec_hevc_stop. This allows vdec_hevc_start() to explicitly celan-out the clock during the error-path. The following smatch warnings are fixed: drivers/staging/media/meson/vdec/vdec_hevc.c:227 vdec_hevc_start() warn: 'core->vdec_hevc_clk' from clk_prepare_enable() not released on lines: 227. drivers/staging/media/meson/vdec/vdec_hevc.c:227 vdec_hevc_start() warn: 'core->vdec_hevcf_clk' from clk_prepare_enable() not released on lines: 227. Signed-off-by: Ricardo Ribalda --- drivers/staging/media/meson/vdec/vdec_hevc.c | 43 +++++++++++++++++++++------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/meson/vdec/vdec_hevc.c b/drivers/staging/media/meson/vdec/vdec_hevc.c index afced435c907..1939c47def58 100644 --- a/drivers/staging/media/meson/vdec/vdec_hevc.c +++ b/drivers/staging/media/meson/vdec/vdec_hevc.c @@ -110,7 +110,7 @@ static u32 vdec_hevc_vififo_level(struct amvdec_session *sess) return readl_relaxed(sess->core->dos_base + HEVC_STREAM_LEVEL); } -static int vdec_hevc_stop(struct amvdec_session *sess) +static void __vdec_hevc_stop(struct amvdec_session *sess) { struct amvdec_core *core = sess->core; struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops; @@ -142,6 +142,13 @@ static int vdec_hevc_stop(struct amvdec_session *sess) else regmap_update_bits(core->regmap_ao, AO_RTI_GEN_PWR_SLEEP0, GEN_PWR_VDEC_HEVC, GEN_PWR_VDEC_HEVC); +} + +static int vdec_hevc_stop(struct amvdec_session *sess) +{ + struct amvdec_core *core = sess->core; + + __vdec_hevc_stop(sess); clk_disable_unprepare(core->vdec_hevc_clk); if (core->platform->revision == VDEC_REVISION_G12A || @@ -151,20 +158,12 @@ static int vdec_hevc_stop(struct amvdec_session *sess) return 0; } -static int vdec_hevc_start(struct amvdec_session *sess) +static int __vdec_hevc_start(struct amvdec_session *sess) { int ret; struct amvdec_core *core = sess->core; struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops; - if (core->platform->revision == VDEC_REVISION_G12A || - core->platform->revision == VDEC_REVISION_SM1) { - clk_set_rate(core->vdec_hevcf_clk, 666666666); - ret = clk_prepare_enable(core->vdec_hevcf_clk); - if (ret) - return ret; - } - clk_set_rate(core->vdec_hevc_clk, 666666666); ret = clk_prepare_enable(core->vdec_hevc_clk); if (ret) { @@ -223,10 +222,32 @@ static int vdec_hevc_start(struct amvdec_session *sess) return 0; stop: - vdec_hevc_stop(sess); + __vdec_hevc_stop(sess); + clk_disable_unprepare(core->vdec_hevc_clk); return ret; } +static int vdec_hevc_start(struct amvdec_session *sess) +{ + struct amvdec_core *core = sess->core; + int ret; + + if (core->platform->revision == VDEC_REVISION_G12A || + core->platform->revision == VDEC_REVISION_SM1) { + clk_set_rate(core->vdec_hevcf_clk, 666666666); + ret = clk_prepare_enable(core->vdec_hevcf_clk); + if (ret) + return ret; + + ret = __vdec_hevc_start(sess); + if (ret) + clk_disable_unprepare(core->vdec_hevcf_clk); + return ret; + } + + return __vdec_hevc_start(sess); +} + struct amvdec_ops vdec_hevc_ops = { .start = vdec_hevc_start, .stop = vdec_hevc_stop,