From: "Regus, Ciprian" <Ciprian.Regus@analog.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Rob Herring" <robh+dt@kernel.org>,
linux-iio <linux-iio@vger.kernel.org>,
devicetree <devicetree@vger.kernel.org>,
"Jonathan Cameron" <jic23@kernel.org>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: RE: [PATCH 2/3] drivers: iio: adc: LTC2499 support
Date: Mon, 29 Aug 2022 06:30:52 +0000 [thread overview]
Message-ID: <e13827526235412585f8b7d60257c5a2@analog.com> (raw)
In-Reply-To: <CAHp75Vft2pvXtxZcpvyV38cR9gOdDxDfCae8g5Uf2q6npWpb+Q@mail.gmail.com>
In reply to one of Andy's questions.
> On Mon, Aug 22, 2022 at 11:13 PM Jonathan Cameron <jic23@kernel.org>
> wrote:
> > On Mon, 22 Aug 2022 15:51:05 +0300
> > Ciprian Regus <ciprian.regus@analog.com> wrote:
>
> In reply to Jonathan's comments to answer his question and add more
> comments from me.
>
> ...
>
> > > Datasheet: https://www.analog.com/media/en/technical-
> documentation/data-sheets/2499fe.pdf
> > >
> > > Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
>
> Tag block mustn't have the blank line(s).
>
> ...
>
> > > #include <linux/iio/iio.h>
> > > #include <linux/iio/driver.h>
> > > #include <linux/module.h>
> > > +#include <linux/property.h>
> > why?
>
> device_get_match_data() requires it.
>
> But why not sort them?
>
> > > #include <linux/mod_devicetable.h>
>
> ...
>
> > > - *val = (be32_to_cpu(st->buf) >> 14) - (1 << 17);
> >
> > Old code here is less than ideal, should be reading into 3 bytes then using
> > the be24 accesors. Please fix whilst here. You will need multiple paths here
> > depending on size.
> >
> > > + *val = (be32_to_cpu(st->buf) >> st->sub_lsb) -
> > > + BIT(ddata->chip_info->resolution + 1);
>
> Shouldn't this use some kind of sign_extend()?
The BIT(ddata->chip_info->resolution + 1) subtraction part is already doing the sign extension,
since that bit (which is the most significant one) will be 0 if the result is < 0, and 1 otherwise.
Regards,
Ciprian
>
> Also with a temporary variable for chip info this line can be single.
>
> struct ... *ci = ddata->chip_info;
>
> ...BIT(ci->resolution + 1)
>
> ...
>
> > > + u32 resolution;
>
> Keep this in a way that the "longer lines go first".
>
> ...
>
> > > + resolution = st->common_ddata.chip_info->resolution;
> > > + st->sub_lsb = 31 - (resolution + 1);
> > > + st->recv_size = resolution / BITS_PER_BYTE + 1;
>
> BITS_TO_BYTES()
>
> ...
>
> > > static const struct i2c_device_id ltc2497_id[] = {
> > > - { "ltc2497", 0 },
> > > + { "ltc2497", TYPE_LTC2497 },
> > > + { "ltc2499", TYPE_LTC2499 },
>
> Use pointers here like you have done for the OF table.
>
> > > { }
> > > };
>
> ...
>
> > > +enum chip_type {
> > > + TYPE_LTC2496,
> > > + TYPE_LTC2497,
> > > + TYPE_LTC2499
>
> Keep trailing comma.
>
> > > +};
>
> --
> With Best Regards,
> Andy Shevchenko
next prev parent reply other threads:[~2022-08-29 6:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-22 12:51 [PATCH 0/3] Add support for LTC2499 ADC Ciprian Regus
2022-08-22 12:51 ` [PATCH 1/3] dt-bindings: iio: adc: Add docs for LTC2499 Ciprian Regus
2022-08-22 19:24 ` Jonathan Cameron
2022-08-22 19:39 ` Jonathan Cameron
2022-08-22 19:40 ` Rob Herring
2022-08-22 12:51 ` [PATCH 2/3] drivers: iio: adc: LTC2499 support Ciprian Regus
2022-08-22 19:37 ` Jonathan Cameron
2022-08-23 15:21 ` Andy Shevchenko
2022-08-24 12:15 ` Jonathan Cameron
2022-08-29 6:30 ` Regus, Ciprian [this message]
2022-08-29 16:47 ` Jonathan Cameron
2022-08-22 12:51 ` [PATCH 3/3] drivers: iio: adc: Rename the LTC249x iio device Ciprian Regus
2022-08-22 14:08 ` Lars-Peter Clausen
2022-08-22 19:17 ` Jonathan Cameron
2022-08-29 6:13 ` Regus, Ciprian
2022-08-29 16:03 ` Jonathan Cameron
2022-08-23 11:09 ` Krzysztof Kozlowski
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=e13827526235412585f8b7d60257c5a2@analog.com \
--to=ciprian.regus@analog.com \
--cc=andy.shevchenko@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/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