From: David Lechner <dlechner@baylibre.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Chris Hall" <c-hall@ti.com>, "Patrick Edwards" <pedwards@ti.com>,
"Kurt Borja" <kuurtb@gmail.com>,
"Nguyen Minh Tien" <zizuzacker@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 8/8] iio: adc: ti-ads112c14: add measurement channel support
Date: Mon, 13 Jul 2026 14:40:27 -0500 [thread overview]
Message-ID: <f8bb35a6-a898-497a-96eb-7a76a1fba16c@baylibre.com> (raw)
In-Reply-To: <alI-a6nkGvXp6sDo@ashevche-desk.local>
On 7/11/26 8:00 AM, Andy Shevchenko wrote:
> On Fri, Jul 10, 2026 at 05:50:41PM -0500, David Lechner (TI) wrote:
>> Add support for parsing devicetree properties for measurement channels
>> and doing direct reads on these.
>>
>> There are quite a lot of conditions that have to be met for each
>> measurement to be made, so quite a bit of state and algorithms are
>> required to handle it.
>>
>> Channels are created dynamically since the number of possibilities is
>> unreasonably large.
>
> ...
>
>> +struct ads112c14_measurement {
>> + const char *label;
>> + u32 vref_source;
>> + u8 iunit;
>> + u8 idac1_mag;
>> + u8 idac2_mag;
>> + u8 idac1_mux;
>> + u8 idac2_mux;
>
> I would group this slightly differently:
>
> u8 idac1_mag;
> u8 idac2_mag;
> u8 idac1_mux;
> u8 idac2_mux;
> u8 iunit;
>
> I haven't seen the code, but names suggest that most likely one would read
> *[12] together or close enough, and less probably mixed with 'iunit' reads.
> Current layout might lead to interesting code generation complications on
> the unaligned-intolerable architectures.
iunit is scaling factor for *_mag, so logically gets grouped with
those. (These are all datasheet register field names.)
>
>> + u8 iadc_count;
>> + u8 gain_val;
>> + u8 burnout;
>> + bool global_chop;
>> + bool bipolar;
>
>> + s64 scale_available[ARRAY_SIZE(ads112c14_pga_gains_x10)];
>
> Also this can be moved upper, but I think it won't save any bytes in this
> layout.
>
>> +};
>
> ...
>
>> struct ads112c14_data {
>> const struct ads112c14_chip_info *chip_info;
>> struct regmap *regmap;
>> + u32 avdd_uV;
>> + u32 ext_ref_uV;
>
>> + bool refp_is_avdd;
>> + bool refn_is_gnd;
>
> Here is a definite gain in memory if booleans combined with u8 below
>
>> + u32 ext_ref_ohms;
>> + struct ads112c14_measurement *measurements;
>> + u32 num_measurements;
>
> Something like
>
> struct ads112c14_measurement *measurements;
> u32 num_measurements;
> u32 avdd_uV;
> u32 ext_ref_uV;
> u32 ext_ref_ohms;
> bool refp_is_avdd;
> bool refn_is_gnd;
>
> ? (Don't forget to run `pahole`.)
We've had the discussion before [1]. I don't think it is worth the effort for
structs that only get used once and doesn't have performance implications.
[1]: https://lore.kernel.org/linux-iio/20240318124041.0000032d@Huawei.com/
>
>> u8 sys_mon_chan_short_gain_val;
>> s64 sys_mon_chan_short_scale_available[ARRAY_SIZE(ads112c14_pga_gains_x10)];
>> };
>
next prev parent reply other threads:[~2026-07-13 19:40 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 22:50 [PATCH v3 0/8] iio: adc: new ti-ads112c14 driver David Lechner
2026-07-10 22:50 ` [PATCH v3 1/8] dt-bindings: iio: adc: Add reference-sources property David Lechner
2026-07-10 22:50 ` [PATCH v3 2/8] dt-bindings: iio: adc: Add excitation current sources properties David Lechner
2026-07-13 1:32 ` Jonathan Cameron
2026-07-10 22:50 ` [PATCH v3 3/8] dt-bindings: iio: adc: Add burn-out current properties David Lechner
2026-07-10 22:50 ` [PATCH v3 4/8] dt-bindings: iio: adc: add input-chopping property David Lechner (TI)
2026-07-13 1:34 ` Jonathan Cameron
2026-07-13 14:55 ` David Lechner
2026-07-13 15:24 ` Jonathan Cameron
2026-07-13 16:29 ` Conor Dooley
2026-07-10 22:50 ` [PATCH v3 5/8] dt-bindings: iio: adc: add ti,ads122c14 David Lechner (TI)
2026-07-10 22:59 ` sashiko-bot
2026-07-10 23:12 ` David Lechner
2026-07-13 1:54 ` Jonathan Cameron
2026-07-13 16:28 ` Conor Dooley
2026-07-10 22:50 ` [PATCH v3 6/8] iio: adc: add ti-ads112c14 driver David Lechner (TI)
2026-07-10 23:00 ` sashiko-bot
2026-07-12 9:42 ` Andy Shevchenko
2026-07-12 16:30 ` David Lechner
2026-07-13 2:11 ` Jonathan Cameron
2026-07-13 14:03 ` David Lechner
2026-07-10 22:50 ` [PATCH v3 7/8] iio: adc: ti-ads112c14: implement gain on internal short SYS_MON channel David Lechner (TI)
2026-07-10 23:04 ` sashiko-bot
2026-07-11 9:11 ` Andy Shevchenko
2026-07-13 2:21 ` Jonathan Cameron
2026-07-10 22:50 ` [PATCH v3 8/8] iio: adc: ti-ads112c14: add measurement channel support David Lechner (TI)
2026-07-10 23:08 ` sashiko-bot
2026-07-11 13:00 ` Andy Shevchenko
2026-07-13 19:40 ` David Lechner [this message]
2026-07-14 1:04 ` Andy Shevchenko
2026-07-13 2:35 ` Jonathan Cameron
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=f8bb35a6-a898-497a-96eb-7a76a1fba16c@baylibre.com \
--to=dlechner@baylibre.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=c-hall@ti.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuurtb@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=pedwards@ti.com \
--cc=robh@kernel.org \
--cc=zizuzacker@gmail.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