From patchwork Tue Aug 13 12:13:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761928 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 D0BCEC52D7C for ; Tue, 13 Aug 2024 12:15:56 +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=1NN4I3pMa1z6u3JhFybH/YMr+WwEfsG16l3i3ACZ6OI=; b=L5UPELBl9uULU4rJatJdB5rQ/n W+XpDU1bD5PYipYoA/RMSvI4Awx9oDUz6zd8jsn+GpZ6bQLUMQZKZPEr2KbYzP0o40suVB/d9oiTD +AhpAmuMByO7UY8LctdhDTBP0P4MC33oBnikp2C9o4iSKXbKRk3xKy9nCDK8/+kDEydzvzcza1fz9 Z7oqTv7oSFE/LAFy6qMBEci8BulKw8FoLxsQS6bhzi0sD9ReH67kZkU+WSL/z9F8i3aq95pvdhX1j 3KKN7pgGPeaoX74EzlVMW6pczgOwK4+Aj8egyBwUNUpCGv5V986v7FE8D11xN2VDkGnmAD51LArYf YVdzkHXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdqRE-00000003ec1-44J8; Tue, 13 Aug 2024 12:15:44 +0000 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdqPQ-00000003dyB-1Nsc for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 12:13:54 +0000 Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-7a1dd2004e1so337971585a.3 for ; Tue, 13 Aug 2024 05:13:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723551231; x=1724156031; 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=1NN4I3pMa1z6u3JhFybH/YMr+WwEfsG16l3i3ACZ6OI=; b=m4CT+x6rZqT/TorFNXeP+l01jIxOsxklij4CODEm97J8cXw4Rxoc+ZodcE2SjGA5Xh b59KNVlO22ELQBim+dX15hnnIMwP1BWYgtWvILhInQenIiYvvZTpUb266u6le9xUNb2J O6Z6WJx/KxmgEGOjQyYclrnQlfSVSpcPBucbk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723551231; x=1724156031; 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=1NN4I3pMa1z6u3JhFybH/YMr+WwEfsG16l3i3ACZ6OI=; b=JeS8zL2ixkX84J4th5ErpQF3OkHxGElMBgk9Zr7mGvn1dOXygDA5Fp/U0hUfjhPDE+ a4Nsx7lga46faHZ7YP3qjnglbdOz214/F6Ur2qx5beRbFfo1HSzQQ9+2kkRyQHFRSIHz x/CYADZWcbYP6Jyns3gku6PdHY01MsGI5Ksw4xZS3P4xYX6m6ao0IIxSBfBPpX9QutKh JXm1GHbzoJFTGy7pef8a/JbcM3YGwDk8y+rHV5kUZKS9TWvo9bR3w6szQ8rp2k2VOKT+ x/Xu5fo8pvDfM9jVSSJMGE+duTMKdq+VJoamLJ8jQQ5ckxiqa78BCJULJQaEJERILhxi iMfw== X-Forwarded-Encrypted: i=1; AJvYcCU6rcrlHykxDLIA686qjliIvX1k11w7hYQ4IHsY1G2b+BuddzaCAi2Q/FvxX6eQcCujnHa/c7JlqyG34bvIBveRhgVrZo4GXfPoWbMEoG67mg4yZdk= X-Gm-Message-State: AOJu0Ywz946zVgwPGST1AIu+iGcNXwIecC+FyTz4HXurA57v9J0dcUN+ Pu5uylMKmm2OAV6UemFO6e0yxpzi1j09wE7HZJbL0hmVRHUOlQncotz4Nt103Q== X-Google-Smtp-Source: AGHT+IEbzzCLxiIWDetpY/N6kglqi3rroSN+bG6y6yQxlctkjM/b9mCaiLCXSWS8MVpF1YKtj23MkQ== X-Received: by 2002:a05:620a:4451:b0:79d:76e5:be76 with SMTP id af79cd13be357-7a4e15afa64mr377756785a.41.1723551231504; Tue, 13 Aug 2024 05:13:51 -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 af79cd13be357-7a4c7d71ca8sm331765485a.50.2024.08.13.05.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 05:13:51 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:49 +0000 Subject: [PATCH 2/6] media: i2c: ov5645: Refactor ov5645_set_power_off() MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-2-664c84295b1c@chromium.org> References: <20240813-smatch-clock-v1-0-664c84295b1c@chromium.org> In-Reply-To: <20240813-smatch-clock-v1-0-664c84295b1c@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-20240813_051352_438546_1C41C012 X-CRM114-Status: GOOD ( 12.55 ) 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; }