From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: rodrigo.alencar@analog.com
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org,
Michael Hennerich <Michael.Hennerich@analog.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Subject: Re: [PATCH v3 7/9] iio: amplifiers: ad8366: add device tree support
Date: Wed, 4 Feb 2026 04:07:29 +0200 [thread overview]
Message-ID: <aYKp4UrEhLInNNZZ@smile.fi.intel.com> (raw)
In-Reply-To: <20260203-iio-ad8366-update-v3-7-5d5636b5181a@analog.com>
On Tue, Feb 03, 2026 at 11:24:13AM +0000, Rodrigo Alencar via B4 Relay wrote:
> Add device-tree support by dropping the enum ID in favor of extended
> chip info table, containing:
> - gain_step, indicating with sign the start of the code range;
> - num_channels, to indicate the number IIO channels;
> - pack_code() function to describe how SPI buffer is populated;
>
> With this, switch cases on the device type were dropped:
> - probe() function adjusted accordingly;
> - Simplified read_raw() and write_raw() callbacks;
...
> +static size_t ad8366_pack_code(struct ad8366_state *st)
> +{
> + u8 ch_a = bitrev8(st->ch[0]) >> 2;
> + u8 ch_b = bitrev8(st->ch[1]) >> 2;
> +
> + put_unaligned_be16((ch_b << 6) | ch_a, &st->data[0]);
> + return 2;
With this return it will look better as
return sizeof(__be16);
Alternatively it can be done via array:
u8 ch[] = { bitrev8(st->ch[0]) >> 2, bitrev8(st->ch[1]) >> 2 };
but I find it uglier than the original approach.
> +}
...
> + const struct ad8366_info *inf = st->info;
> + size_t len = 1;
>
> + if (inf->pack_code)
> + len = inf->pack_code(st);
> + else
> + st->data[0] = st->ch[0];
>
> + return spi_write(st->spi, st->data, len);
Hmm... What about
const struct ad8366_info *inf = st->info;
if (inf->pack_code)
return spi_write(st->spi, st->data, inf->pack_code(st));
st->data[0] = st->ch[0];
return spi_write(st->spi, st->data, 1);
?
...
> struct ad8366_state *st = iio_priv(indio_dev);
> + const struct ad8366_info *inf = st->info;
> int ret;
> + int gain = inf->gain_step > 0 ? inf->gain_min : inf->gain_max;
Please, preserve reversed xmas tree order.
...
> - {"ada4961", ID_ADA4961},
> - {"adl5240", ID_ADL5240},
> - {"hmc792a", ID_HMC792},
> - {"hmc1119", ID_HMC1119},
> + {"ad8366", (kernel_ulong_t)&ad8366_chip_info},
> + {"ada4961", (kernel_ulong_t)&ada4961_chip_info},
> + {"adl5240", (kernel_ulong_t)&adl5240_chip_info},
> + {"hmc792a", (kernel_ulong_t)&hmc792_chip_info},
> + {"hmc1119", (kernel_ulong_t)&hmc1119_chip_info},
The conversion to chip_info may be split to a separate patch.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-02-04 2:07 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 11:24 [PATCH v3 0/9] iio: amplifiers: ad8366: driver update and dt support Rodrigo Alencar
2026-02-03 11:24 ` Rodrigo Alencar via B4 Relay
2026-02-03 11:24 ` [PATCH v3 1/9] MAINTAINERS: Add missing maintainer entry for AD8366 driver Rodrigo Alencar
2026-02-03 11:24 ` Rodrigo Alencar via B4 Relay
2026-02-03 11:24 ` [PATCH v3 2/9] dt-bindings: iio: amplifiers: Add AD8366 support Rodrigo Alencar
2026-02-03 11:24 ` Rodrigo Alencar via B4 Relay
2026-02-04 17:59 ` Conor Dooley
2026-02-03 11:24 ` [PATCH v3 3/9] iio: amplifiers: ad8366: use devm_mutex_init() and drop mutex_init() Rodrigo Alencar
2026-02-03 11:24 ` Rodrigo Alencar via B4 Relay
2026-02-04 1:53 ` Andy Shevchenko
2026-02-05 20:32 ` Jonathan Cameron
2026-02-03 11:24 ` [PATCH v3 4/9] iio: amplifiers: ad8366: drop reset_gpio from private struct Rodrigo Alencar
2026-02-03 11:24 ` Rodrigo Alencar via B4 Relay
2026-02-04 1:55 ` Andy Shevchenko
2026-02-05 18:12 ` Rodrigo Alencar
2026-02-06 7:32 ` Andy Shevchenko
2026-02-03 11:24 ` [PATCH v3 5/9] iio: amplifiers: ad8366: refactor device resource management Rodrigo Alencar
2026-02-03 11:24 ` Rodrigo Alencar via B4 Relay
2026-02-03 11:24 ` [PATCH v3 6/9] iio: amplifiers: ad8366: sort header includes Rodrigo Alencar
2026-02-03 11:24 ` Rodrigo Alencar via B4 Relay
2026-02-04 1:58 ` Andy Shevchenko
2026-02-03 11:24 ` [PATCH v3 7/9] iio: amplifiers: ad8366: add device tree support Rodrigo Alencar
2026-02-03 11:24 ` Rodrigo Alencar via B4 Relay
2026-02-04 2:07 ` Andy Shevchenko [this message]
2026-02-03 11:24 ` [PATCH v3 8/9] iio: amplifiers: ad8366: consume enable gpio Rodrigo Alencar
2026-02-03 11:24 ` Rodrigo Alencar via B4 Relay
2026-02-04 2:22 ` Andy Shevchenko
2026-02-03 11:24 ` [PATCH v3 9/9] iio: amplifiers: ad8366: Update device support Rodrigo Alencar
2026-02-03 11:24 ` Rodrigo Alencar via B4 Relay
2026-02-04 2:23 ` Andy Shevchenko
2026-02-05 20:37 ` [PATCH v3 0/9] iio: amplifiers: ad8366: driver update and dt support 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=aYKp4UrEhLInNNZZ@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rodrigo.alencar@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.