From: Dan Carpenter <dan.carpenter@linaro.org>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: "Sakari Ailus" <sakari.ailus@linux.intel.com>,
"Krzysztof Hałasa" <khalasa@piap.pl>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Sylwester Nawrocki" <s.nawrocki@samsung.com>,
"Andrzej Hajda" <andrzej.hajda@intel.com>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Kevin Hilman" <khilman@baylibre.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>,
"Hans Verkuil" <hverkuil-cisco@xs4all.nl>,
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
Subject: Re: [PATCH 1/6] media: ar0521: Refactor ar0521_power_off()
Date: Tue, 13 Aug 2024 15:54:35 +0300 [thread overview]
Message-ID: <ce0ed949-5e57-4193-8190-9e4aa9cb62be@stanley.mountain> (raw)
In-Reply-To: <20240813-smatch-clock-v1-1-664c84295b1c@chromium.org>
On Tue, Aug 13, 2024 at 12:13:48PM +0000, Ricardo Ribalda wrote:
> 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 <ribalda@chromium.org>
> ---
It's better to just ignore false positives... The problem here is that
Smatch can't track that to_ar0521_dev(dev_get_drvdata(dev))->sensor is the same
as sensor. What I could do is say that "this frees *something* unknown" so
let's silence the warning."
The problem is that check_unwind.c is not very granular. It just marks things
as allocated and freed. I could make it more granular so the free and the
alloc have to match. Or we could match based on the type. This frees a
"struct ar0521_dev" so mark all those as freed in the caller.
> 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);
You had intended to remove the clk_disable_unprepare() from __ar0521_power_off()
but forgot so these are double unprepares.
regards,
dan carpenter
> +
> 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;
> }
>
>
> --
> 2.46.0.76.ge559c4bf1a-goog
>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2024-08-13 12:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 12:13 [PATCH 0/6] media: Fix last smatch warnings Ricardo Ribalda
2024-08-13 12:13 ` [PATCH 1/6] media: ar0521: Refactor ar0521_power_off() Ricardo Ribalda
2024-08-13 12:54 ` Dan Carpenter [this message]
2024-08-13 13:01 ` Ricardo Ribalda
2024-08-13 12:13 ` [PATCH 2/6] media: i2c: ov5645: Refactor ov5645_set_power_off() Ricardo Ribalda
2024-08-13 12:13 ` [PATCH 3/6] media: i2c: s5c73m3: Move clk_prepare to its own function Ricardo Ribalda
2024-08-13 12:56 ` Dan Carpenter
2024-08-13 12:13 ` [PATCH 4/6] media: tc358746: " Ricardo Ribalda
2024-08-13 12:13 ` [PATCH 5/6] media: meson: vdec_1: Refactor vdec_1_stop() Ricardo Ribalda
2024-08-13 12:13 ` [PATCH 6/6] media: meson: vdec: hevc: Refactor vdec_hevc_start and vdec_hevc_stop Ricardo Ribalda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ce0ed949-5e57-4193-8190-9e4aa9cb62be@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=andrzej.hajda@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jbrunet@baylibre.com \
--cc=khalasa@piap.pl \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=martin.blumenstingl@googlemail.com \
--cc=mchehab@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=ribalda@chromium.org \
--cc=s.nawrocki@samsung.com \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®