From patchwork Tue Aug 13 12:13:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761927 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 401EEC52D7C for ; Tue, 13 Aug 2024 12:15:17 +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=Q2YaJNxhLs5F8lLYTx7H4r6rahb3C2THbGnEdQxh/xA=; b=Ls5Kmxo7ZU0AErDjlPrc3NBl09 VRP7T8IAy6+cJPqXiWT7eHoVFsX/f9+m+j8DTMJxiNfsAd5cpCWc3/fO/taHYufW/mYPPmVpDCNR1 iJsvW32vWJ7b1Ebz1DB31vKqrYTdftlDhqSEYjYAsmH6OTAJfB3augvFm3uASzSm6nVJJVihR0vjB WN/v/sWh0PbJGB1Ny5hM5/mMxpNg3o0YCZAFxc03ruX5Ld7vVTRNaFgt6Gm1D/Bn3srdStCvWsGZd S9iw2RIrXHUISOag6641qk5DZdozz3GKmju6Ml7LZRGuLpIeXVEO7HGp4FNuGDQXwUO6dE9fsCzG3 fdjn/6eA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdqQe-00000003ePL-1Cu9; Tue, 13 Aug 2024 12:15: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 1sdqPQ-00000003dxO-00ku for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 12:13:54 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-7a1df0a9281so342099185a.1 for ; Tue, 13 Aug 2024 05:13:51 -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=Q2YaJNxhLs5F8lLYTx7H4r6rahb3C2THbGnEdQxh/xA=; b=NdGNnMmYjXTiQhIqrhDTUQt/Y2RwP3Y1mR+FmneTV/+GR7aXSuWcuUure5XspjwV8i ibhhVipNdFf//zW4+CncsBIZ0UjYDkLN1G5ulAVDw02FT1J2VChInCgzHFnXZWu+uqOu 1JR1hJArFyK6tDuq7Fu1usL+H4IyWcuV9f1/0= 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=Q2YaJNxhLs5F8lLYTx7H4r6rahb3C2THbGnEdQxh/xA=; b=tAVvgwECjkzi/eKAhw/QaW0FO3H8/9wHdzXqiCzXKXRLkJ83p1QQKUAg/IBgzP4ejE tuWQIopVfh0df75BH5bt/AZ4xM8OERQ1ir9wURxDOe8PvZo7g7MHcYPDlTPAguYtccLE wFI1JaqnJq231jp58kDvJSzXMTOjngK2QtqrMoR2EqxvbTjT9q+m53f7wDZ51KN/J0El IHebXKUtUWe3qeirC2zd8dZ6C6D53G/hpTb/dUxFlRPg6Uh2QZmEtbT3fpFR5a7y+7UM eNvU/q38rR6fac6rQ+jSF1BWRVbh87DTNJuas+3lMwqeU5hFEfOU1/2P8Y7wUiYuq0jM 5Q9w== X-Forwarded-Encrypted: i=1; AJvYcCXiGpAj79Hpy94OJj8BCaRgMsAJvUFTSGzOIiuUgBUGiOQrm4Cjy/fSydE1F+X0E51V760W4V4ef+NQ+frGsW9VB+IogOjUO66e2xG2LPm+jsmSJjQ= X-Gm-Message-State: AOJu0Yw1fjUhxArLL5MVs5vvYTpRB4gA0oU5v0v+v2FuRzxA5L306IFP g6nCxJ/t9WmX23pqPhqIbmttR6DUOylx6w6NhiNrkrH/fpOWjQHCOhmQ7CvWgw== X-Google-Smtp-Source: AGHT+IEbPwywblqg1PHmJ6WOVqLAFdQNUuhFh7OmJ87lW/f5GlJN4YVEnCjKh12Gxxs2z0IijZihGw== X-Received: by 2002:a05:620a:4109:b0:7a1:e2e0:b3c9 with SMTP id af79cd13be357-7a4e151ba74mr391481985a.24.1723551230715; Tue, 13 Aug 2024 05:13:50 -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:50 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:48 +0000 Subject: [PATCH 1/6] media: ar0521: Refactor ar0521_power_off() MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-1-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_059204_5CA0CF95 X-CRM114-Status: GOOD ( 14.19 ) 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 --- drivers/media/i2c/ar0521.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ar0521.c b/drivers/media/i2c/ar0521.c index 09331cf95c62..2c528db31ba6 100644 --- a/drivers/media/i2c/ar0521.c +++ b/drivers/media/i2c/ar0521.c @@ -835,7 +835,7 @@ 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); @@ -850,6 +850,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 +918,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; }