[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250611162507.6868c8c6@jic23-huawei>
Date: Wed, 11 Jun 2025 16:25:07 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: "Ioan-daniel, Pop" <Pop.Ioan-daniel@...log.com>
Cc: Lars-Peter Clausen <lars@...afoo.de>, "Hennerich, Michael"
<Michael.Hennerich@...log.com>, David Lechner <dlechner@...libre.com>, "Sa,
Nuno" <Nuno.Sa@...log.com>, Andy Shevchenko <andy@...nel.org>, Rob Herring
<robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, "Cuciurean, Sergiu" <Sergiu.Cuciurean@...log.com>,
"Bogdan, Dragos" <Dragos.Bogdan@...log.com>, "Miclaus, Antoniu"
<Antoniu.Miclaus@...log.com>, Olivier Moysan <olivier.moysan@...s.st.com>,
Javier Carrasco <javier.carrasco.cruz@...il.com>, Matti Vaittinen
<mazziesaccount@...il.com>, adureghello <adureghello@...libre.com>,
Guillaume Stols <gstols@...libre.com>, Tobias Sperling
<tobias.sperling@...ting.com>, "Schmitt, Marcelo"
<Marcelo.Schmitt@...log.com>, Trevor Gamblin <tgamblin@...libre.com>,
Alisa-Dariana Roman <alisadariana@...il.com>, "Nechita, Ramona"
<Ramona.Nechita@...log.com>, Herve Codina <herve.codina@...tlin.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
Thomas Bonnefille <thomas.bonnefille@...tlin.com>, João
Paulo Gonçalves <joao.goncalves@...adex.com>,
"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v7 5/5] iio: adc: ad7405: add ad7405 driver
On Tue, 10 Jun 2025 12:09:22 +0000
"Ioan-daniel, Pop" <Pop.Ioan-daniel@...log.com> wrote:
> >
> > Why do we need this .channel element if all instances use the same one? If you
> > are are shortly going to add support for more devices where this will change
> > then this is ok. If not, just have one static const channel and use that without
> > looking it up via these chip_info structures.
> >
>
> Hi! I'm not aware of any other parts that use different channel types. It's true that all parts use the same .channel.
> Should I submit a new patch version with the requested change?
No need - it's an easy tweak (hopefully). I fixed up the owner thing Nuno noticed
and applied this diff whilst picking this up.
diff --git a/drivers/iio/adc/ad7405.c b/drivers/iio/adc/ad7405.c
index 487d661f9050..9adf85a732ce 100644
--- a/drivers/iio/adc/ad7405.c
+++ b/drivers/iio/adc/ad7405.c
@@ -25,7 +25,6 @@ static const unsigned int ad7405_dec_rates_range[] = {
struct ad7405_chip_info {
const char *name;
- struct iio_chan_spec channel;
const unsigned int full_scale_mv;
};
@@ -69,7 +68,7 @@ static int ad7405_read_raw(struct iio_dev *indio_dev,
switch (info) {
case IIO_CHAN_INFO_SCALE:
*val = st->info->full_scale_mv;
- *val2 = st->info->channel.scan_type.realbits - 1;
+ *val2 = indio_dev->channels[0].scan_type.realbits - 1;
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
*val = st->dec_rate;
@@ -78,7 +77,7 @@ static int ad7405_read_raw(struct iio_dev *indio_dev,
*val = DIV_ROUND_CLOSEST_ULL(st->ref_frequency, st->dec_rate);
return IIO_VAL_INT;
case IIO_CHAN_INFO_OFFSET:
- *val = -(1 << (st->info->channel.scan_type.realbits - 1));
+ *val = -(1 << (indio_dev->channels[0].scan_type.realbits - 1));
return IIO_VAL_INT;
default:
return -EINVAL;
@@ -120,48 +119,44 @@ static const struct iio_info ad7405_iio_info = {
.read_avail = &ad7405_read_avail,
};
-#define AD7405_IIO_CHANNEL { \
- .type = IIO_VOLTAGE, \
- .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
- BIT(IIO_CHAN_INFO_OFFSET), \
- .info_mask_shared_by_all = IIO_CHAN_INFO_SAMP_FREQ | \
- BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \
- .info_mask_shared_by_all_available = \
- BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \
- .indexed = 1, \
- .channel = 0, \
- .channel2 = 1, \
- .differential = 1, \
- .scan_index = 0, \
- .scan_type = { \
- .sign = 'u', \
- .realbits = 16, \
- .storagebits = 16, \
- }, \
-}
+static const struct iio_chan_spec ad7405_channel = {
+ .type = IIO_VOLTAGE,
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) |
+ BIT(IIO_CHAN_INFO_OFFSET),
+ .info_mask_shared_by_all = IIO_CHAN_INFO_SAMP_FREQ |
+ BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),
+ .info_mask_shared_by_all_available =
+ BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),
+ .indexed = 1,
+ .channel = 0,
+ .channel2 = 1,
+ .differential = 1,
+ .scan_index = 0,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 16,
+ .storagebits = 16,
+ },
+};
static const struct ad7405_chip_info ad7405_chip_info = {
.name = "ad7405",
.full_scale_mv = 320,
- .channel = AD7405_IIO_CHANNEL,
};
static const struct ad7405_chip_info adum7701_chip_info = {
.name = "adum7701",
.full_scale_mv = 320,
- .channel = AD7405_IIO_CHANNEL,
};
static const struct ad7405_chip_info adum7702_chip_info = {
.name = "adum7702",
.full_scale_mv = 64,
- .channel = AD7405_IIO_CHANNEL,
};
static const struct ad7405_chip_info adum7703_chip_info = {
.name = "adum7703",
.full_scale_mv = 320,
- .channel = AD7405_IIO_CHANNEL,
};
static const char * const ad7405_power_supplies[] = {
@@ -200,7 +195,7 @@ static int ad7405_probe(struct platform_device *pdev)
return -EINVAL;
indio_dev->name = st->info->name;
- indio_dev->channels = &st->info->channel;
+ indio_dev->channels = &ad7405_channel;
indio_dev->num_channels = 1;
indio_dev->info = &ad7405_iio_info;
Let me know if I messed it up. Pushed out as testing for now.
Thanks,
Jonathan
Powered by blists - more mailing lists