From: Jonathan Cameron <jic23@kernel.org>
To: "Ioan-daniel, Pop" <Pop.Ioan-daniel@analog.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
"Hennerich, Michael" <Michael.Hennerich@analog.com>,
"David Lechner" <dlechner@baylibre.com>,
"Sa, Nuno" <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>,
"Cuciurean, Sergiu" <Sergiu.Cuciurean@analog.com>,
"Bogdan, Dragos" <Dragos.Bogdan@analog.com>,
"Miclaus, Antoniu" <Antoniu.Miclaus@analog.com>,
"Olivier Moysan" <olivier.moysan@foss.st.com>,
"Javier Carrasco" <javier.carrasco.cruz@gmail.com>,
"Matti Vaittinen" <mazziesaccount@gmail.com>,
adureghello <adureghello@baylibre.com>,
"Guillaume Stols" <gstols@baylibre.com>,
"Tobias Sperling" <tobias.sperling@softing.com>,
"Schmitt, Marcelo" <Marcelo.Schmitt@analog.com>,
"Trevor Gamblin" <tgamblin@baylibre.com>,
"Alisa-Dariana Roman" <alisadariana@gmail.com>,
"Nechita, Ramona" <Ramona.Nechita@analog.com>,
"Herve Codina" <herve.codina@bootlin.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Thomas Bonnefille" <thomas.bonnefille@bootlin.com>,
"João Paulo Gonçalves" <joao.goncalves@toradex.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v7 5/5] iio: adc: ad7405: add ad7405 driver
Date: Wed, 11 Jun 2025 16:25:07 +0100 [thread overview]
Message-ID: <20250611162507.6868c8c6@jic23-huawei> (raw)
In-Reply-To: <PH0PR03MB63351F2AA87604CC10BB6EC8D16AA@PH0PR03MB6335.namprd03.prod.outlook.com>
On Tue, 10 Jun 2025 12:09:22 +0000
"Ioan-daniel, Pop" <Pop.Ioan-daniel@analog.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
next prev parent reply other threads:[~2025-06-11 15:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-05 15:09 [PATCH v7 0/5] Add support for AD7405/ADUM770x Pop Ioan Daniel
2025-06-05 15:09 ` [PATCH v7 1/5] iio: adc: ad4851: ad4851_set_oversampling_ratio parameters update Pop Ioan Daniel
2025-06-05 15:09 ` [PATCH v7 2/5] iio: backend: update iio_backend_oversampling_ratio_set Pop Ioan Daniel
2025-06-05 15:09 ` [PATCH v7 3/5] iio: adc: adi-axi-adc: add axi_adc_oversampling_ratio_set Pop Ioan Daniel
2025-06-05 15:09 ` [PATCH v7 4/5] dt-bindings: iio: adc: add ad7405 Pop Ioan Daniel
2025-06-05 15:09 ` [PATCH v7 5/5] iio: adc: ad7405: add ad7405 driver Pop Ioan Daniel
2025-06-07 15:44 ` Jonathan Cameron
2025-06-10 12:09 ` Ioan-daniel, Pop
2025-06-11 15:25 ` Jonathan Cameron [this message]
2025-06-12 7:38 ` Ioan-daniel, Pop
2025-06-09 8:05 ` Nuno Sá
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=20250611162507.6868c8c6@jic23-huawei \
--to=jic23@kernel.org \
--cc=Antoniu.Miclaus@analog.com \
--cc=Dragos.Bogdan@analog.com \
--cc=Marcelo.Schmitt@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=Nuno.Sa@analog.com \
--cc=Pop.Ioan-daniel@analog.com \
--cc=Ramona.Nechita@analog.com \
--cc=Sergiu.Cuciurean@analog.com \
--cc=adureghello@baylibre.com \
--cc=alisadariana@gmail.com \
--cc=andy@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=gstols@baylibre.com \
--cc=herve.codina@bootlin.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=joao.goncalves@toradex.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=olivier.moysan@foss.st.com \
--cc=robh@kernel.org \
--cc=tgamblin@baylibre.com \
--cc=thomas.bonnefille@bootlin.com \
--cc=tobias.sperling@softing.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