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; }