Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Thorsten Blum" <thorsten.blum@linux.dev>,
	"Marius Cristea" <marius.cristea@microchip.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	stable@vger.kernel.org,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: PAC1934: Fix clamped value in pac1934_reg_snapshot
Date: Sun, 7 Dec 2025 13:46:00 +0000	[thread overview]
Message-ID: <20251207134600.1afee57e@jic23-huawei> (raw)
In-Reply-To: <CAHp75VebjUo2JH49tmuOvgjKUbsUmZg0C461wwvL-bRaDd5C9Q@mail.gmail.com>

On Tue, 2 Dec 2025 20:47:37 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Tue, Dec 2, 2025 at 8:13 PM Thorsten Blum <thorsten.blum@linux.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

> 
> ?
> 


      reply	other threads:[~2025-12-07 13:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-02 18:13 [PATCH] iio: adc: PAC1934: Fix clamped value in pac1934_reg_snapshot Thorsten Blum
2025-12-02 18:47 ` Andy Shevchenko
2025-12-07 13:46   ` Jonathan Cameron [this message]

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=20251207134600.1afee57e@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marius.cristea@microchip.com \
    --cc=nuno.sa@analog.com \
    --cc=stable@vger.kernel.org \
    --cc=thorsten.blum@linux.dev \
    /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