From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Victor Chernyakin <chernyakin.victor.j@outlook.com>
Cc: andy@kernel.org, dlechner@baylibre.com, jic23@kernel.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
nuno.sa@analog.com
Subject: Re: [PATCH v3 4/4] iio: cdc: add Texas Instruments FDC1004 driver
Date: Tue, 3 Nov 2026 11:40:59 +0200 [thread overview]
Message-ID: <aumsKylMrxSOC0XD@ashevche-desk.local> (raw)
In-Reply-To: <SN1PR12MB2528C775582FEF9B200A1FBCA56C2@SN1PR12MB2528.namprd12.prod.outlook.com>
On Sat, Oct 31, 2026 at 10:22:34AM -0500, Victor Chernyakin wrote:
...
> > > > + /*
> > > > + * Now read the two registers making up the measurement.
> > > > + * The datasheet says to read MSB first, LSB second.
> > > > + */
> > > > // also note in this case we don't need to have _MSB in the name
> > > > ret = regmap_bulk_read(map, FDC1004_REG_MEASn(0), reg_val, sizeof(reg_val));
> > >
> > > I agree we could drop the _MSB if this was the only use
> > > of FDC1004_REG_MEASn_MSB, but we use both _MSB and _LSB macros in the
> > > volatile register table definition, and it would be weird to have one
> > > macro with _LSB but the other without _MSB.
> >
> > You can have three!
>
> I suppose, but I would prefer to avoid duplicating the macro, and
> I think having _MSB here helps to confirm what the comment is saying,
> that we should be reading MSB first.
>
> > > > if (ret)
> > > > return ret;
> > > >
> > > > #ifdef __LITTLE_ENDIAN
> > > > reg_val = swahw32(reg_val);
> > > > #endif
> > > >
> > > > *val = sign_extend32(reg_val >> 8, 23);
> > > >
> > > > // I assume the following is also possible in this case
> > > > // *val = (int)reg_val >> 8;
> > > > // but usually we use sign_extend32() in IIO even when simple
> > > > // casting is okay
> > > >
> > > > This also reduces stack usage.
> > >
> > > AFAIK a good optimizer should be able to see that reg_val and reg_vals are
> > > never live at the same time and reuse the same stack slot for both (whether
> > > GCC or Clang actually do that for this function, I can't be bothered to check).
> > >
> > > If you and Jonathan prefer that version for other reasons though, I can
> > > switch to it.
> >
> > I gave an idea, I would wait for Jonathan to judge on it.
>
> Since we're waiting for an answer, I've posted v4 without this change
> so that the other parts of the patch can move forward, but I can
> always add it to v5, etc.
Generally it's not recommended to post without waiting for the resolution.
If you do so, at least make sure you have mentioned the opens.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-11-03 9:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 16:51 [PATCH v3 0/4] " Victor Chernyakin
2026-10-26 16:51 ` [PATCH v3 1/4] iio: prepare iio_format_value to handle higher-precision IIO_VAL_DECIMAL64_* formats Victor Chernyakin
2026-10-26 20:17 ` Andy Shevchenko
2026-10-27 1:51 ` Victor Chernyakin
2026-10-27 7:29 ` Andy Shevchenko
2026-10-27 8:36 ` Victor Chernyakin
2026-10-27 18:56 ` Rodrigo Alencar
2026-10-28 8:11 ` Andy Shevchenko
2026-10-28 10:31 ` David Laight
2026-10-28 11:16 ` David Laight
2026-10-26 16:51 ` [PATCH v3 2/4] iio: add IIO_VAL_DECIMAL64_{ATTO,ZEPTO,YOCTO} formats Victor Chernyakin
2026-10-26 16:51 ` [PATCH v3 3/4] dt-bindings: iio: cdc: add Texas Instruments FDC1004 Victor Chernyakin
2026-10-26 16:51 ` [PATCH v3 4/4] iio: cdc: add Texas Instruments FDC1004 driver Victor Chernyakin
2026-10-26 20:13 ` Andy Shevchenko
2026-10-27 2:13 ` Victor Chernyakin
2026-10-27 7:33 ` Andy Shevchenko
2026-10-27 10:04 ` Victor Chernyakin
2026-11-01 18:53 ` Jonathan Cameron
2026-10-31 15:22 ` Victor Chernyakin
2026-11-03 9:40 ` Andy Shevchenko [this message]
2026-11-01 18:35 ` Jonathan Cameron
2026-10-27 8:17 ` Joshua Crofts
2026-10-27 10:06 ` Victor Chernyakin
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=aumsKylMrxSOC0XD@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=chernyakin.victor.j@outlook.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.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®