[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251207134600.1afee57e@jic23-huawei>
Date: Sun, 7 Dec 2025 13:46:00 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Thorsten Blum <thorsten.blum@...ux.dev>, Marius Cristea
<marius.cristea@...rochip.com>, David Lechner <dlechner@...libre.com>, Nuno
Sá <nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>,
stable@...r.kernel.org, Jonathan Cameron <Jonathan.Cameron@...wei.com>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: adc: PAC1934: Fix clamped value in
pac1934_reg_snapshot
On Tue, 2 Dec 2025 20:47:37 +0200
Andy Shevchenko <andy.shevchenko@...il.com> wrote:
> On Tue, Dec 2, 2025 at 8:13 PM Thorsten Blum <thorsten.blum@...ux.dev> wrote:
> >
> > The local variable 'curr_energy' was never clamped to
> > PAC_193X_MIN_POWER_ACC or PAC_193X_MAX_POWER_ACC because the return
> > value of clamp() was not used. Fix this by assigning the clamped value
> > back to 'curr_energy'.
>
> ...
>
> > /* add the power_acc field */
> > curr_energy += inc;
> >
> > - clamp(curr_energy, PAC_193X_MIN_POWER_ACC, PAC_193X_MAX_POWER_ACC);
> > + curr_energy = clamp(curr_energy, PAC_193X_MIN_POWER_ACC,
> > + PAC_193X_MAX_POWER_ACC);
> >
> > reg_data->energy_sec_acc[cnt] = curr_energy;
>
> Hmm... Maybe
>
> reg_data->energy_sec_acc[cnt] = clamp(curr_energy,
> PAC_193X_MIN_POWER_ACC,
> PAC_193X_MAX_POWER_ACC);
I went with aligning after ( and slightly longer than 80 char lines.
other combinations didn't seem to read quite as well to me.
Applied to the fixes-togreg branch of iio.git. I'll probably sit on pushing
that out until I can rebase on rc1 however.
Jonathan
>
> ?
>
Powered by blists - more mailing lists