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: 13766045 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7DC02E859 for ; Fri, 16 Aug 2024 12:32:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811526; cv=none; b=S+okqHHN4Mh2JBtsLfqfkd3TRovvEI+DS3phaUG7p/ptskDsRjGOEWrMmkL1r6aV+CD+uYYYupRlj7f7Q5+0BQqmE/L3atNsKF23QzqGTRjis0L9NJfJ9xzsEbTawa/XH0b4yphotPT2of4rSBQdz2X+7DG/4MeN3pLrfrOUrY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811526; c=relaxed/simple; bh=gLudReYyvC4mUmRJU8EVa/JKuPaZK02zBMk37qmw3do=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WrPk8JhcSNT8BUwkb2PSU/DuDR2I5IHMWZcPIdkOBqbVyalOQN+tqvEVUJqzldw1NJ3w87135l/oYTSuzHLaEFhG4BfoFfW78AbEoYYv5qHh6gr1OgwnKhXZgEY4URnvx82RkSQ2suoCwh4ykSu2hx8R1frezlXch4WYO02yFyQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=n8mSQ4n/; arc=none smtp.client-ip=209.85.219.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="n8mSQ4n/" Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-6bf7f4a1334so2804826d6.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=1723811523; x=1724416323; darn=vger.kernel.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=n8mSQ4n/7LHiSKhajLsfcX9t+rzuq3sgpKKfuRDclRSNYE+bbvXLaOvp2htsE1D5wV Nd/lTvMe75sE4onL1OIMAoREpAqmySL5Ruqga/ygnm29GHRNxBCWASFKYQ6jFJlM8lJs YCVL7q4j1eh12ivt4r9YHNJHmKyr1/uFZnU3I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811523; x=1724416323; 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=Wr4od/spzWu8g6BplGF7awJZnRMfgsVYd38sPvt7BdBKWziCV1mE2YuU7KQ3RTrJSR boOqkfd4Nmhy0OjpTTZR2fCdQcFmRGKQQDZFmD78+mLXdwEJDw750478fYkfgtLhsZzC 3Z4IBBwy0lyPAF/Kt25W+yZ1bCRXghRLmPcSqa9jtAxriTGVID0lyIjq91Ga0iX01C84 1ai2lf0+DvYaag8NzARH7EvAkx9/+pisMX9waiM0naA1eih0CXX/cV+ltvAhECXo1RPI 4RVZd9pifSyzshRnGKEdV7r41C2M6jLA7QMV5CHUiNnVCvW45aXX8Z0em0CFXlLli5Ts MTOQ== X-Forwarded-Encrypted: i=1; AJvYcCUX4Cdb3TE8TL5CaOhHesWFKYkaYJEYQhEpHR8hLcMMWaAXR/wJ3DjMDeH3x78OU2lIaGnPFswFclv02XPqej1Sm+WFAQo8AX6ut8s= X-Gm-Message-State: AOJu0YxkxXl+W6VVSjFKRPeARegjq4EePn6K2pC0IGDIXBMdM6dNg754 Wq+SmokcoqcP/SIkg0ziX3Mi8tfnZaPJ5XLxKb5bfu+Oj6ooyI349HarYYtqyw5vYGuiMXaVDz1 rqA== 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() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13766046 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D81FD1AC425 for ; Fri, 16 Aug 2024 12:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811527; cv=none; b=eevnPdgpjHghVrTKKEt40u1WhFRu43DxHY8oYB7Z/ok+17k48N2xDh8oBhS8EI6YrqaQ0JrVEC0RYTlBE3GzPM6RKyL4rLwg0JO4r7qLBeNj6EQb7fBxsCRfBnto1Y/YPvGstcDosu6JrPARq15g22nD+iOs1X79z3SH44gxXwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811527; c=relaxed/simple; bh=/6WcXSLwFpxkzdTierJx9NQnI7bszU0POONTE1m0oX4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DVqaX3GkCtRS/DWGoNmuP7g9fZV/7lY0jGSXxCrQBPG0THuNeyFqtwG+Xs0FPRPwwRpyiLniDZo+fuVVCjcugXWrh5JxKpBQDhvBxmMKSgpSoGisRYhN3ZxUr8Tghltz2uAvBoDdxyJlVREeHKCKBUsAG5GXt/3YvZlikdqcpq4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=IqFnCpGA; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="IqFnCpGA" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-7a1d984ed52so125825885a.0 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=vger.kernel.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=IqFnCpGAjZieWm+d2U018WgTAp9eNP3PcJzwfE4Wwej/mDkSSNwXVOE14/njNEIb/X hMeikCmHBn11tMrR3S8rOhn280jsSPnnceAUotJQD2i0ar8RC7gOu3/gSZnNSK2BeinN BKo/AL3SxsWfYB5vAdgBlRxfoablys9fEh1pI= 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=Oee8IyzpvV/wOJKEJI1/BZh3nhtwMhBXWvGn9HQOL2bvn9Y1O7WajzsR0J9SvR6nW+ XpKlI6SPgaxiRwsUpSCncJbLpnOfzXBhI5YoV2y45Mw/FrxC3YTzTnv+hWahfB5CdkXL dxlLmQnFG1b4S8sFWj9tj/8+kPCzO+x9ZbDG9VLFEUInsw2KxQN7CUgtuevth/xAP5qH LfxGrrMG7QtxGbrRYAMj1SDStFYl0LKVaP9VNRSUIjrQrVelb88kxs5t7yFi1IS7SQ6n +ASRxLU+agHSBQ54Fvwsfpl5wpBv1tFWH0MD2yQ8kRl2RqBFg6/8uVVv5D7XgIRHylxl 8CxQ== X-Forwarded-Encrypted: i=1; AJvYcCUVwTJMTzxIr4hL77FqZNVOU3r3+VUMutNForOOFFmyqKoElE4L8dEocarrBE24c9VwEUg6EnJ3HSMflg==@vger.kernel.org X-Gm-Message-State: AOJu0YyCLi50nd8NUoSvJPwW9Zr2YTlbpcBXWyBZnwqNIf0Tp6XHJuDx AyMb8hhxEZREWt966hBFk0uV87W8WSMiXM3aFgzgPgQkMlK2c5CcyVPIBQk4dztLS/KgRryLINt 8IQ== 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() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13766047 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CC5419DF4F for ; Fri, 16 Aug 2024 12:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811528; cv=none; b=mrdnPFYx8yL/7VqOLLJgt2Ge6sd5yC06dNUKylSWKQvW+mFHiN4oJaqXD4bqTn5SfJzOsfu41JFzzr8V/LwS9xJTbwmf0yHLS8Yy3UbqQyLyXr6hQW2+Dw81yYdv8jfKuc8nZBbniGM2q0Gu0Bj5gX8Zksk+MmQLvnVEzlSsVmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811528; c=relaxed/simple; bh=t0EHg6F/f2g7yIhpSYl+j42nBCmMMjiSjxuqYf5Mqqk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WMcw+QUUKC9KIez0zG/zlrCPVcATJcmztnsUujYWME/d9V6WbOIhn97lZWvo7GtcsfzZ0q3MWrFivfTf0R3jxoWZSvjOLL2Oy1DATn1gjeXJIasm00Uj72yu7Kf97QzmhowSqtDo9AXCffU7NPhNIx4xf4XlNqu/u8CSxIyJyOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=iU3/pKSe; arc=none smtp.client-ip=209.85.210.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iU3/pKSe" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-709339c91f9so976925a34.0 for ; Fri, 16 Aug 2024 05:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811525; x=1724416325; darn=vger.kernel.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=iU3/pKSeL6Gv/q9j4X/OpEipj8b+fOJw5SfJQ0NcL7QsdxE4RiqYoJTQ7Ys+/M8ZU2 C9SJ043k+nGp7UWlNVo8m6YmLHo49f/lWRDarhJ/XJMN8gKDhCsB+MHosCfyO9al/fJA X8xTartc/DoqoCINIRebDJRvkkIbVreItH77w= 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=pCMtw3l2HOKzUvd5+qzMijgiQ+r2kGGW2rWw9UzyITS7v6S7lRK5WczZhJj9GJEI1J 8Pmu+z16jjq9adQlHeOe6izjofZp7MSVtAbIbeepaFdSpBZfFpOe9LZaktiUDDkIVNgo 5rIJ3aM4Rg7Z43AL8dylDnhaXiYNzXf6GBUKuoVNpLK2BiAHeRYkeIZNcn9yoXzQH7QW njYkMBnDx7uSGyNrEgKemHPxU0wYGQLlYLrvsorWUiLlS5ktstUOrJS++r5gmGpPpT6x 9hsOXmcsOYcm9qbWzpe1irZxfRmpqavRcGz2ya6qlvx0f6/ap94WxwCIEl9faqn0yL0K iPnA== X-Forwarded-Encrypted: i=1; AJvYcCVR1j5ISTnOe2K9tmszDDwkhrlIWPA65eWWRuusZ30hDp3GhwYhZD/cU7Sj4Lj2y8lT5zL2rqNvdR4bZg==@vger.kernel.org X-Gm-Message-State: AOJu0Yz8Meb1flDnLJD54zMUBUpC0b1QGRNTd7n4O79ngg3ZuGEB8Z4u +5Cry0kL/TSabyruxLmaKXrQkX0t8CvLVWjNF4JWA9JichlL2k8hebEBn9Oavw== 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 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13766048 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9BD81B86EB for ; Fri, 16 Aug 2024 12:32:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811529; cv=none; b=tODhFjT6CFHeEZ5pPVkclu2jX0psC7okxvSsTGTMR6gQ72PM+9OD6CUDZxCEDV0Ku1g/nqIN+ZutdMT4oIWVgYbb0aLubGB1gMo2cmK3AH72sQwjTSzpBgYbWOrNrjbob3f89am2w0hoGxQ+yBl3uKRclaQAyQFlmNQQ7dePuH8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811529; c=relaxed/simple; bh=/us7e90fGibDZ7iRi3+d7f5fxC4Ub6dpRW24VMBvk0w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pSFx+9tb+4JBJHP1SfgwBCDTjrIUEXErejOpuLbEqhTkw/Nb3ccXROcuTFcwaUqUUkqrAIAm/lXkRJX4Sb/Txk/RL5IhESEzL2pXP2IRX1z/LppOGefU66Pz1F577SJPzGCnu42ErrU0YAFdwEN7Y26ivPgmWWLNs8oFN1uF28A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=jzXEh/oC; arc=none smtp.client-ip=209.85.219.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="jzXEh/oC" Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-6bd777e6623so10256846d6.3 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=vger.kernel.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=jzXEh/oCCzUXUp2+i/7PzG2iVdVqJP0FXXpnjDK3t3X5gVpccDMF+Gi6ODZHuvtVKj 6i0vXiFBxeWoOK7jtCEJQmjLxkR4MXWTqNHMbL656EidFKXKIpJxHDirDXtD9wyJzdj0 iiFMKoYRR31+f44X27hbzdx21b0SZintQjW/o= 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=hRY9UOzOdP2ub1YERLuDMbMWTr1N6pGK6YzShxmyztGuWscDSTd5F3K2X5F+u/IbYM MBKbqfrU0j8HbNl51wM/P9DK+JWPAdJZ1jjvVe9DuGD0/fOVXgBKtfZd2LCeFKvvmmJi +PeDpMaIhfLwmQhhsmuboX8c5pyh7MtbYoNQMaH34M7urrH5nH6lTBX1jDfANluzuAqy a6ETDGJ/FLsoa2c27htT2+VIx7xg18dxBZ4JdXJ5cBSFPE5nZyyop2twEqBYoluCtax/ 0vwwzth1MCrE+iQ0tHVOQm3xGIapOzOiU4zqtB7MfhPz3+JaTGkL4uvYNdTS/2bNZRCd l/hw== X-Forwarded-Encrypted: i=1; AJvYcCVb8zg/K5Zx06IeUyCcT48fQqRAWOtsxMSFR+kROILPprMoN/ieWOrwbRC9j/9FjoPtlsqsRDXr1n/glz3f6qGa0BgNU0gcspO0mp4= X-Gm-Message-State: AOJu0YzD8PtvHdsQ1umK/rB70AhzC9n6aSdzGy3lVi0lMWmQIGw8ug5/ Pp1M3nOMsLGvSf5g9OTxiy/45hbw5Ev1/JPEo+cydp62IXVyaPvBeMFsP/z7ew== 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 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13766049 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59BA31AC425 for ; Fri, 16 Aug 2024 12:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811530; cv=none; b=ElNh6wJURnS/QjTMPHs/jjJcfj6V2LkI90Iv3JnvsREVUxgLQ7GbZF2M8W5Ar8qc2uDSl1BMeWGr9w9h1xtEmKpHoGJ1mXXeppHaUkNGNxWXPVV1hTTC2+5XJHNGJBX1tUP5SibEk3lrOZomrFZHSnIRJCHtjK4KTmD59x84QBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811530; c=relaxed/simple; bh=EucDhSv61CuFfP11sjE8SXVP+6M/bqH4uWFxl+dPrlw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GCBH+rQFa89ZX+tuxWwsORDprs2hA9v0Jhbry8yQdo8nJ87uAg3CMs1khC8rbiMklFp+FhgSHo+eZLvdFUZ9mKAYovLwxiSTkO+1kgShWomrTxPy9G0qrmDjMpJ2oUyBI4vFYoL5TwMtfbFNxVMTqZfHBo6NIEuxSzn0D6kk/xM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=RxoY7XtA; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="RxoY7XtA" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6bf6beda038so11430406d6.2 for ; Fri, 16 Aug 2024 05:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811527; x=1724416327; darn=vger.kernel.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=RxoY7XtApnJKWlHkPGcL5/0zb29zp/BcEtSQnI1OwybBUIi3FPhv5NY31knAw6AMSg TUNyw9wd+iMR65blqSWmSxe4PC4d8tZjQaGHbgcXB3InmDAQoDNKA06GdEY0QqyAAKuK 0iWJIG9tJPQjLmaHr6M96GWqX86ERko0wY8HI= 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=mhxAMNxScMl/vKjWsENK/BMOApTfCY4txHwmzZ1P4oQFRDJWmFy6x03HYNPzrzUY4z loTdFU5oQ/AAhJeuETb//+cIaxNP+AW3q1SJnG/Hde+nosujH4gVJ1XEbS69B51Z8E+L KK7jC/BkZ/SdjamhW/EBEbUyy6/n8IBAw7vOaj+VHSUISe171Z8yTH1sM8m5vZQSvAv2 9lH78Dcf3IjQtXrJcIsTETfludJkt6reZMcuK1iUtE7LuBSROfR/8eLJG2eF6EbIoy7r witLnLcQr0ntS0zMTtrKwaG463Owsc1f4trMhGp2iIdiFteSJLsoa48+3qaCu2G+voP8 caSg== X-Forwarded-Encrypted: i=1; AJvYcCULmJwjmE8ml7MZB9vIWMXb04lcZd3KnqTAieRTuksFYa5rV8bh1Au/7TFdrgUUDQMc+QmdmJGy9HVhBo4YtAuM02zR603nnD8hj2Y= X-Gm-Message-State: AOJu0YzU4Ej8WJfZ2ZV+cqJVI4y0Z9sdMbqalAo9dJ36cHcqDiLemVFs unnpqaqGpwL5LaRLgdN0GtTVrM4hZDuM6ii/rVuYG2+enEfPPTQDal2WUMdzLw== 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() Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13766050 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 662B81BB68E for ; Fri, 16 Aug 2024 12:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811531; cv=none; b=CXnj9DdwGb/BZqWCCuRZTbHKyMlkJQAZwPEbQCWE5uDRrXm6DlsAa9XMi2JG9tXwGsJhmuQCKhhDRolZj2nKf/YwoDV1U+nJF8U10wu6gzRmYyaq4SeFNiOA3RHJCAGYTM7SkL/KePzXz9mmiN3P0aq0qmqWPg+w2vzIuMGRgPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723811531; c=relaxed/simple; bh=SXKvsjbb6kOB2MdaooRMUXOmM0k8Y5hLTe9Sfpiqp9o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RMbn1UpClCC9zeC5qe+06RjAodFU4dhwS4/zPLLWRF+0Ncq20NqyKvRx04oaWlIdcmbJyP1iT1/DV7CEkiwc30pZMwR9ubkeigZ/wggOvaK1ZZa4Ahc6XHC9D28KhK2G2IZ3OfADHhORuz/8lfN9+5VUn93gzAyGx+U0QN6bMg8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=bjIVjfix; arc=none smtp.client-ip=209.85.219.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="bjIVjfix" Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-6b7a3773a95so10619076d6.2 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=vger.kernel.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=bjIVjfixAjoNTOBjf1pxaMlk+ojJ7ZT1vD1I2XAZYYKr8Z1II1+/Jp154BtHHatZN1 bb0sSVeKztDB8h3aNQrNokYafwn65w/2slYNlXXL46f8McD4z8y/BV6+/YSrLHxU5fbz unqfLSLCsr7kWyVOvSmvtJcsKB3pilCQ6sGxo= 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=AFsNNfxVod5pNsG8qcN4oZpKTFAYNAfzPJ2TksIMMkd501xgZkAPuGXYVhbNjzDOCd wYL2+l+WfBiceCMreuuy2qY53lzhaRnbhpAGYz8XdD0L4kt7Rh/v+fLmkSh8DWwacv79 hiGF6bBZTtEG4WlcIg3tZiZpr2yk2kd2RC7gnOFanynhV0vR8daA4NppyihKeQjosRVz T8ulmaaMj/spUcfrWP0xDXm8WdVIjDPRfl51pjD9ozOPTNUlvvqueKouNWKeKAkm18Lx vnnW/nJGjJRN425JhMadU7eRxCM7wgCHlpKVbfJgW+Zd1hZeY7VPGbCVUB4N8FxJhald tl+Q== X-Forwarded-Encrypted: i=1; AJvYcCU2yNYLE6glszNmJMj37wO8kFwNlugFRtW1zhdPND+N5bLcTIc3I+uPwMFh6W7t579Q90fl5vpRQxPr53wjkqZoswYssNbdV5IHcn0= X-Gm-Message-State: AOJu0Yw6UK15EkS8N1D7L4uw0uREMaoA1xfHub6hahYYsHGbvBMZQG+C BrP4gQn3lyPWqcDA1sNaWHCQ9bqxr8kt4T+PfkI99rdwjRroRzwTSYhdCYWX6g== 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 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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,