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 v7 4/4] iio: cdc: add Texas Instruments FDC1004 driver
Date: Tue, 10 Nov 2026 11:51:12 +0200 [thread overview]
Message-ID: <avLpEA6CoZvicvDN@ashevche-desk.local> (raw)
In-Reply-To: <SN1PR12MB2528754241E5C6271A02734FA5722@SN1PR12MB2528.namprd12.prod.outlook.com>
On Mon, Nov 09, 2026 at 09:56:44PM -0600, Victor Chernyakin wrote:
...
> > > + return regmap_write(map, FDC1004_REG_OFFSET_CAL_CINn(chan->channel),
> > > + (u16)DIV_S64_ROUND_CLOSEST(val64, fdc1004_calibbias[1]));
> >
> > Why casting? Shouldn't it be handled on the regmap_write() stage based on
> > the register / field description?
>
> This was prompted by this sashiko review:
>
> https://lore.kernel.org/SN1PR12MB252888B43D53AB1723952D21A5742@SN1PR12MB2528.namprd12.prod.outlook.com
>
> TLDR I'm not certain the cast is necessary, but I'm also not certain
> it's not necessary (if regmap does handle it, I couldn't figure out
> where), so I've added it out of caution.
Yes, regmap core code is tricky in many places. So, as far as I read it,
the I2C default bus with val_bits == 16 (if you have no custom regmap IO
accessors) uses internal format operation regmap_format_16_be() along
with format_write kept at NULL and hence defer_cache set to true (cache
after formatting). The default working buffer for the data is work_buf,
to which the above formatter puts the data, it doesn't put anything outside
16 LSBs.
Since the code is tricky, please double check my way of understanding the code
and confirm or point out any mistakes I made.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-11-10 9:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 20:08 [PATCH v7 0/4] " Victor Chernyakin
2026-11-08 20:08 ` [PATCH v7 1/4] iio: prepare iio_format_value to handle higher-precision IIO_VAL_DECIMAL64_* formats Victor Chernyakin
2026-11-08 20:08 ` [PATCH v7 2/4] iio: add IIO_VAL_DECIMAL64_{ATTO,ZEPTO,YOCTO} formats Victor Chernyakin
2026-11-08 20:08 ` [PATCH v7 3/4] dt-bindings: iio: cdc: add Texas Instruments FDC1004 Victor Chernyakin
2026-11-08 20:08 ` [PATCH v7 4/4] iio: cdc: add Texas Instruments FDC1004 driver Victor Chernyakin
2026-11-09 23:39 ` Andy Shevchenko
2026-11-10 3:56 ` Victor Chernyakin
2026-11-10 9:51 ` Andy Shevchenko [this message]
2026-11-10 11:54 ` 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=avLpEA6CoZvicvDN@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®