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; } 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; } From patchwork Tue Aug 13 12:13:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761929 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 3A587C52D7B for ; Tue, 13 Aug 2024 12:16:36 +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=LrZdtpz/qyn21riVVQ3i7W1bl9boREamJ7f5SQNbyMY=; b=zRLVUBifDGMlOpHiBY8wX7KcsL L9t6bipSE8O2lyM2r7QTBRaattxkanlevkXZ/KzhI7856eq4zale/kM8HN7AwgBY9RuftyEsljZyI dcpaM1CIdpIhZcAtURS2K+JsLvc9bqcyK4FFtu5Ty704Js2f02OcT2OZyZX+v62beq8jYwaTZD4At WgxFXtJ5Yh9y50jNVb2sKBQvdKJz+TD9+12vz1G5PF3605OILY9ghJ9nKtrry0X5pfedjK9n60Kuv X8994gwtsuLUEv3MjRYV3IOBkBhpTX0fOo9nRmo5zLPgNZ7Q3SpiqKHS7cJIPV74RXtkB+DcBOAEa b1gl/iHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdqRu-00000003ewM-40t2; Tue, 13 Aug 2024 12:16:26 +0000 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdqPS-00000003dzK-32Ts for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 12:13:56 +0000 Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-7a1d7a544e7so365189085a.3 for ; Tue, 13 Aug 2024 05:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723551233; x=1724156033; 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=LrZdtpz/qyn21riVVQ3i7W1bl9boREamJ7f5SQNbyMY=; b=UN7r3H0/jIaJzWQL8+jiaZ0bqBOdrIpgiaASNM9LcYsrTZ6lJPS4WhwMMiYb18okWh lK3FaSez170wTAHC/Px2I8qn89In8ds/4JzgCfBYCNR6G1lOdkQgWkJxI9zl1hts70ER PnVTX5BsuzzUK7emV6R6OCgzp7M0B9DkEvxeA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723551233; x=1724156033; 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=LrZdtpz/qyn21riVVQ3i7W1bl9boREamJ7f5SQNbyMY=; b=XOIQN4ugbO1wRzTSEYf9fVvKNS6iBi4k3EQnUbtKS+x6HNhYPv+Wz+V4tFyinJUIXY m1vGOz+MkOD09cbuNuJLi6DjJASARet1l4vqZbI6G2S3xV4jsvHt8yc1Wiv9rs2RmfeY 4JPj/dMnu5ehGdlWSML9qBYAewPiHLUK8QAzdhAdUbZB9tqpiI2C3Th7h8FHaVXPs7n/ esJCFH5bE+fP90js1N+3tBZ26k/Ur23falNeiCCDNxwEhMyGrVjD6Slx0MzlVQ80wHNy Q0p8Q0J2xHceFM2mEWHHAoriPIAfYBDJ7BLbCBMiRbu8NAffGcXn+ljS4+I8TAtRxoLa 6MBA== X-Forwarded-Encrypted: i=1; AJvYcCV0dfzK5vyoOP9KufpKGXByNRHDueCVCFmBdWzKpZItN9648PT5lYeQFoz6Rb4dsRHoZLvHGgJxSfiUhrwxdiOi@lists.infradead.org X-Gm-Message-State: AOJu0YzNwPA5zFktyBvCGkWO1ZpHmXbzLwTSI5IDWelljU6N24+Qp3S+ 2q/OpoMIN60o3k6D3ulhV1JdiXdif4EBci6aZPXlA9MAjFluwAnO+41/i0gkpw== X-Google-Smtp-Source: AGHT+IFw/fFUPyShPG2/Ze40YU4KamjQKDfYMrBvg1bfZRKNcTmejJtMfWfYfhDU5SD5ItOdKzwbXQ== X-Received: by 2002:a05:620a:4043:b0:79f:515:e211 with SMTP id af79cd13be357-7a4e15bdc69mr410951685a.46.1723551233113; Tue, 13 Aug 2024 05:13:53 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 05:13:52 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:50 +0000 Subject: [PATCH 3/6] media: i2c: s5c73m3: Move clk_prepare to its own function MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-3-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_051354_800298_A262391B X-CRM114-Status: GOOD ( 12.95 ) 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 Tue Aug 13 12:13:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761930 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 DC815C52D7B for ; Tue, 13 Aug 2024 12:17: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=9Etl9GyPmdRz22pfGaoR8C42DApQqo8svGDO8wQI1tI=; b=xwfwd6awsN+18MhHRFI3AiuLSn Mows805f+IBWEkBZ/qepR0YoS6mGx9VXMI9632s59SiqPk/K75MuxSMrCqStapU5PLmRmC9r7DN/x OyAodxZpHpT3IJhwKi6V+dq/mSHuVsfc9f0KnmAb1kFdy4t7yZM4OMiJE12NDo5vkTJjTiDgYlkA0 l+81ecsLL3Idldpwl/MBPouXUkBeh98AOkmZXR5VYDkF/opSM9/4WmLJN710QE1SQC9JAErNEBegP 3Y/E/Nb1U5H1DHs6dTcgpRM7I6IUpC0dn/O6+wipO5Hl0tTWUq6CpjDSw9Y6hKZD9v5pGtF6sJmbx m49oHrRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdqSU-00000003f4B-3Un1; Tue, 13 Aug 2024 12:17:02 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdqPT-00000003dzo-2t7h for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 12:13:57 +0000 Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-7a4df9dc885so86958685a.0 for ; Tue, 13 Aug 2024 05:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723551234; x=1724156034; 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=9Etl9GyPmdRz22pfGaoR8C42DApQqo8svGDO8wQI1tI=; b=atdzlX0faKPxcp23lQW0fu/hpr/18j3+HddgmT0i8uRg2D2K+FphZ8L4+/ke2mIFlH lb3QHEcAqIe6q2C659jnSQh1o6qVHWcipNNpDG8GBDfo/o+A7vOJG3dnj/qDq3pUjhWF ag2AhEiBHGn3+kWMWrdLgcdhHfKHh+3bk5JZs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723551234; x=1724156034; 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=9Etl9GyPmdRz22pfGaoR8C42DApQqo8svGDO8wQI1tI=; b=ZSY1ZzIThHRHOzKhrv876l78Nz0tKRZyAiwTp3+Oaw/Xv/HsHKMdg9Y4R9EqqV8xPK kkNH5Hs8fno3Gbjr1V+/r6iTWoKbBBfdBZZtvG52ptGnT2HvlI8B2GHqZyD5yj9SSC1F X0vPYuHTVU65Sv+Tqp0cSPwxNXhHzRi0gqDDnDlDbmwFTjE+Pya/reracL2IHiFloUwl a9SgGd5h0RUZaB1x/bXlZl/nrwNnRJgtrYqHMU/LQVG63tJdHR5frE0BrfKV4+LDZazC 8QmM0rHh7k7YhN/1QpprWvTYW9XB+gw7c8STRzI7egfcwHeMQGXkyjCcv3mOQrbA6Po2 vT9g== X-Forwarded-Encrypted: i=1; AJvYcCVk4V6FChURP7Vjuak50QAYj49xdru39LGcJcwhhIKvr7lWGVXy/BIKyl/ZkY0jANJWBxZdVkQc8PRelczY9i5OZ5AdjmRiYQsj/d0G3k2dvnDnbWI= X-Gm-Message-State: AOJu0YwoqKOvUCqFf1NiAHezkeLGl7NfRCcc7vRAQrbiPSStCgFC0wpg CcYt1HIwUiYBaiECcPcLCD+R/duhr0mtzdZaEX2CGtI9YFCsC4ekPCsXXKjWLw== X-Google-Smtp-Source: AGHT+IE5trF99pt6yxLy0hVGziVuLU740Yhk23ir8obTxxE56RFdMfq2z26jixLlIL2miIGD5ezz0A== X-Received: by 2002:a05:620a:d82:b0:7a1:da71:e73a with SMTP id af79cd13be357-7a4e37605b0mr498168385a.2.1723551234290; Tue, 13 Aug 2024 05:13:54 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 05:13:53 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:51 +0000 Subject: [PATCH 4/6] media: tc358746: Move clk_prepare to its own function MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-4-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_051355_737513_71F65FBA X-CRM114-Status: GOOD ( 13.52 ) 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 Tue Aug 13 12:13:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761931 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 84A02C531DC for ; Tue, 13 Aug 2024 12:17:49 +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=ryvSTyFRHLyFB4VqqsDZg/Laqqf7RuuAiNN+vKB3Dic=; b=vItBkqdJdHOF5rzk8hz0lju77p rf46KEpx1iT8wUG+LHrmlDxZbbktXqq5DPJ9a1XfPdSULbV4c8JvKEam898M/G8o+aIQw2TcVvgsu sLPmPlr2wKXR1qh88nry/0UPLd5tK5/K02nDZWegil7FrBh4PB7EloF9hiLwKboqvuRO5zXGW9Zsv Iaz8AtgOCGgQ+61piAIAl+VPvp+4LNqvbDULs29KcEIlunhnazkxROjSBrg3AUryWG2/lwzRwgzDg 5SWE3Vce7ZhBa+V+0FM2ipcFAtKSlhUEbZypwLlS/o5/a11SFWUuBDHLXTVfeE249FuOrseX+s+Ru Da/zFgaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdqT4-00000003fBG-3Ph8; Tue, 13 Aug 2024 12:17:39 +0000 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdqPU-00000003e0l-30Vm for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 12:13:58 +0000 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-7a3375015f8so377384485a.1 for ; Tue, 13 Aug 2024 05:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723551235; x=1724156035; 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=ryvSTyFRHLyFB4VqqsDZg/Laqqf7RuuAiNN+vKB3Dic=; b=gWxc94lIw8HFHLT5PFd6I0+fkYjd1k81Kc9IgQGyscvMLyjts/P4TXgcl639Wmw5fT QpMNZR7UjRtuo/X2YI7lQetEF7J5FacZjMg+nkKy770b+ffX7znSMp3jiu8nZKQ8+A7V +BBJXOsY5oFFEm1oWdY3uXp7+e5/LehwPoJJ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723551235; x=1724156035; 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=ryvSTyFRHLyFB4VqqsDZg/Laqqf7RuuAiNN+vKB3Dic=; b=unU7qQAo1/v/QA2SgBORALmnKi68EdHa5BXi7S9rZDhY4s/IR1zgWFCYazjDotIv5a QEC6Rpr5B45cV25DqOXThYITApFOiWCGoaOi19O1W+bYj9B37tHeOCkADujEjV6vpJ9N sY1zbSfEd4fUn4dpRSjj9kfjJdm96Ho4IX7wCPVmXHCcmtdK9tQMUx4k4FzGpBDbcGr5 3Jar5d1bMFR6K/HorFQqsboHXyr8VCtmTf2jPcP0998Mfe2TJsjgqHYjYj1kO8bjJTJZ A2+vBnM1xbuUfPe07OL8moRO9KtQhu7lbs0sDBq6uD1m0Q+LbKlZRoBNbyyndxnZSV5I oM/g== X-Forwarded-Encrypted: i=1; AJvYcCXBLlYzvKEbf+AcsxY7ny1TQFQ4UxJ95gStp5t1VAcvCJNM75tSY51wCWJnBrp9DadYu43bfh67/MNQ+hYJFLkyqInDuDMbO6WGB+CZjBTOTb3f3yI= X-Gm-Message-State: AOJu0Yyj8p+r19CJ9BBkeaJVSKQXGGRtOJILY7n9wSBTUqtFODBm5Ksi Pbg3B8Vb7ITqvonh/JwEITZ4o2jGadwmq+W6MICknEK4oijR0WwoDyH9uKSkmg== X-Google-Smtp-Source: AGHT+IEOX25WNCrWUaMxc3lkZuEvbZq3/dMLr0NrYO2cFstfRrmQqZhk/+W2xbcY25YibUai9xTEGw== X-Received: by 2002:a05:620a:31a9:b0:7a1:6062:ed63 with SMTP id af79cd13be357-7a4e15a434dmr379872785a.29.1723551235139; Tue, 13 Aug 2024 05:13:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 05:13:54 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:52 +0000 Subject: [PATCH 5/6] media: meson: vdec_1: Refactor vdec_1_stop() MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-5-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_051356_830244_49C92796 X-CRM114-Status: GOOD ( 12.97 ) 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 Tue Aug 13 12:13:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13761932 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 30C43C52D7B for ; Tue, 13 Aug 2024 12:18:31 +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=tbox2ZoitlY78mZ2yFdlFoyXWXf8v8pDSpmA621vz/E=; b=UUOMStr6wGjO64RMCNfgwmC7md 8F/mVtidm6fFcSxmP/axkMn2cQLb8tNeDr0dJp2Y06v1uESQIni2bswJJlcKdyAJ7tH4nc+ZOKV6f qpLKAvZRXwUuUlNRZOrW7S3Rbn9PuzbiA7DKrhDnsn9I8otBk+WjwYeOSTwWLifyziB21do7QG0en 8tUVUQONYLByBzuVSh3+C5Sz13g5fNajpOo+/+qCQmw2YpMQ1u/qDJXuz9DWde6Ba6FfxHGh/Iav+ OWADhsgz7NBI9jEgxEdmkAWHSDABhYLeUWF0jmPCvhZRuepAv/0OngALG0I8ao9zQce0saf9pDge5 jCKNcJuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdqTf-00000003fOE-1HIa; Tue, 13 Aug 2024 12:18:15 +0000 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdqPX-00000003e3N-3E0W for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 12:14:01 +0000 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-70944dc8dc6so2767176a34.3 for ; Tue, 13 Aug 2024 05:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723551236; x=1724156036; 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=tbox2ZoitlY78mZ2yFdlFoyXWXf8v8pDSpmA621vz/E=; b=MJ+6WUUq+1vn8hJ6O+W428j8Zsnjd0ikvhqRQOd9LFTNraa6Q+yZHD9Q4uO6TXgUsT oDRCpVUMJYY3OFkKd4CjhEOa3xRBbEb/BsAbB9rZWvETfZWtJAEZHbhF2MRGNVxenmBs 4oPqQNZTXVdZxzepi3UcQdf1EEca1v2FPk1dw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723551236; x=1724156036; 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=tbox2ZoitlY78mZ2yFdlFoyXWXf8v8pDSpmA621vz/E=; b=nfhg/JrfX/5ZBZpqMH9qq8UkrGD8TW4rii7GmDL5XBQB+vLdNOHGukHysAzM0VgLKM VEB2JaUtP3fRYsREkNIYkMzBk4zzrXn3HTtDvUqKDfOgvEObmiTzUnKIusO1fhMscXOy 9+Vwz8BmBGZJaIJfl/2eDbynTJ7iZtZW0zS9RkDDmqjcRF4d76tQP+OkqqRoZEa2fVC9 8nQrpheS3PHm/EAylmhCkNvP8CkEM9lq9apRGejKXgEo2LB3feAtTf8rJ+yg8gSr83PN bK4gh3hzBQasTcMNwQbQGfTptH0FmTLk2kaOoRTcNQAkqGLVfpr7jwQlPX2kC+saJQuh Ocnw== X-Forwarded-Encrypted: i=1; AJvYcCV9lJzn6MwLJCMOhc0BPTgJrkvTPe2Aw1BsrRWeKVjDaWnRCxYYbV7MuIJKks8f+jnLBaIirZGwi4rYlx8KwVxkP51TSQ8+J87VbWbuJS4hjhvLJxM= X-Gm-Message-State: AOJu0YyGoSIs0RjQJLpZPn5K+JUYVJHA2ALBg2EWOkM12mJ/kuaKUb4v Vrvhz/Q8Mcu8EeHdkNJa+eoeVtWRb+AurdQblBbot5zACeGyg3hGIl9ukvy39g== X-Google-Smtp-Source: AGHT+IGgXIJUCN4cjOUkGFgon+WiB2P8zLnuNtMLuoWTLxNw2YXdYtwoDqVO1oPdH1blkel8OnEpNw== X-Received: by 2002:a05:6358:e4a4:b0:1af:1105:49b7 with SMTP id e5c5f4694b2df-1b19d2f4c8fmr402139355d.30.1723551236049; Tue, 13 Aug 2024 05:13:56 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 05:13:55 -0700 (PDT) From: Ricardo Ribalda Date: Tue, 13 Aug 2024 12:13:53 +0000 Subject: [PATCH 6/6] media: meson: vdec: hevc: Refactor vdec_hevc_start and vdec_hevc_stop MIME-Version: 1.0 Message-Id: <20240813-smatch-clock-v1-6-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_051359_836280_74847ADA X-CRM114-Status: GOOD ( 15.61 ) 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,