From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: "João Paulo Gonçalves" <jpaulo.silvagoncalves@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"Francesco Dolcini" <francesco@dolcini.it>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"João Paulo Gonçalves" <joao.goncalves@toradex.com>,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
"Francesco Dolcini" <francesco.dolcini@toradex.com>
Subject: Re: [PATCH v2 2/2] iio: adc: ti-ads1119: Add driver
Date: Tue, 11 Jun 2024 18:29:10 +0100 [thread overview]
Message-ID: <20240611182910.000008f1@Huawei.com> (raw)
In-Reply-To: <20240610132629.xjj32vzrekpl356w@joaog-nb>
On Mon, 10 Jun 2024 10:26:29 -0300
João Paulo Gonçalves <jpaulo.silvagoncalves@gmail.com> wrote:
> Hi Jonathan,
>
> Thanks for the review!
>
> > > +
> > > +static int ads1119_validate_gain(struct ads1119_state *st, int scale, int uscale)
> > > +{
> > > + int gain = 1000000 / ((scale * 1000000) + uscale);
> > > +
> > > + switch (gain) {
> > > + case 1:
> > > + case 4:
> > > + return gain;
> > Odd to calculate it if we don't need it
> > return MICRO / (scale * MICRO + uscale);
> > use constants as it's easy to drop a 0 in these without anyone noticing.
> >
> > > + default:
> > > + return -EINVAL;
> > > + }
> > > +}
> > > +
>
> Just a minor. I do use the calculated value on write_raw() by storing it as the
> new channel gain and would still need to validate it as scale/uscale comes from
> userspace. Maybe I can just remove the validate_gain function and do the check
> directly on write_raw(). What do you think?
If that's the only caller, sure, move it to write raw.
Jonathan
>
> Regards,
> João Paulo Gonçalves
>
prev parent reply other threads:[~2024-06-11 17:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 16:35 [PATCH v2 0/2] iio: adc: ti-ads1119: Add driver Francesco Dolcini
2024-06-06 16:35 ` [PATCH v2 1/2] dt-bindings: iio: adc: add ti,ads1119 Francesco Dolcini
2024-06-06 17:07 ` Conor Dooley
2024-06-06 20:49 ` Rob Herring
2024-06-06 22:11 ` Francesco Dolcini
2024-06-09 10:17 ` Jonathan Cameron
2024-06-06 16:35 ` [PATCH v2 2/2] iio: adc: ti-ads1119: Add driver Francesco Dolcini
2024-06-09 10:52 ` Jonathan Cameron
2024-06-10 11:59 ` Francesco Dolcini
2024-06-11 17:26 ` Jonathan Cameron
2024-06-10 13:26 ` João Paulo Gonçalves
2024-06-11 17:29 ` 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=20240611182910.000008f1@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=broonie@kernel.org \
--cc=francesco.dolcini@toradex.com \
--cc=francesco@dolcini.it \
--cc=jic23@kernel.org \
--cc=joao.goncalves@toradex.com \
--cc=jpaulo.silvagoncalves@gmail.com \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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