From: George Stark <gnstark@sberdevices.ru>
To: <jic23@kernel.org>, <lars@metafoo.de>,
<neil.armstrong@linaro.org>, <khilman@baylibre.com>,
<jbrunet@baylibre.com>, <martin.blumenstingl@googlemail.com>,
<andriy.shevchenko@linux.intel.com>, <nuno.sa@analog.com>,
<gnstark@sberdevices.ru>
Cc: <linux-iio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
<linux-amlogic@lists.infradead.org>, <kernel@sberdevices.ru>,
George Stark <GNStark@sberdevices.ru>
Subject: [PATCH v2 3/6] meson saradc: unite iio channel array definitions
Date: Fri, 23 Jun 2023 05:20:11 +0300 [thread overview]
Message-ID: <20230623022334.791026-4-gnstark@sberdevices.ru> (raw)
In-Reply-To: <20230623022334.791026-1-gnstark@sberdevices.ru>
Instead of having several similar channel arrays which are different
only by one item unite the arrays and put the unique item in the end.
Signed-off-by: George Stark <GNStark@sberdevices.ru>
---
drivers/iio/adc/meson_saradc.c | 31 +++++++------------------------
1 file changed, 7 insertions(+), 24 deletions(-)
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 6e69b40b3309..ffd4de950a63 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -189,9 +189,8 @@
.datasheet_name = "SAR_ADC_CH"#_chan, \
}
-#define MESON_SAR_ADC_TEMP_CHAN(_chan) { \
+#define MESON_SAR_ADC_TEMP_CHAN() { \
.type = IIO_TEMP, \
- .channel = _chan, \
.address = MESON_SAR_ADC_VOLTAGE_AND_TEMP_CHANNEL, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
BIT(IIO_CHAN_INFO_AVERAGE_RAW), \
@@ -234,19 +233,7 @@ static const struct iio_chan_spec meson_sar_adc_iio_channels[] = {
MESON_SAR_ADC_CHAN(6),
MESON_SAR_ADC_CHAN(7),
IIO_CHAN_SOFT_TIMESTAMP(8),
-};
-
-static const struct iio_chan_spec meson_sar_adc_and_temp_iio_channels[] = {
- MESON_SAR_ADC_CHAN(0),
- MESON_SAR_ADC_CHAN(1),
- MESON_SAR_ADC_CHAN(2),
- MESON_SAR_ADC_CHAN(3),
- MESON_SAR_ADC_CHAN(4),
- MESON_SAR_ADC_CHAN(5),
- MESON_SAR_ADC_CHAN(6),
- MESON_SAR_ADC_CHAN(7),
- MESON_SAR_ADC_TEMP_CHAN(8),
- IIO_CHAN_SOFT_TIMESTAMP(9),
+ MESON_SAR_ADC_TEMP_CHAN(), /* must be the last item */
};
struct meson_sar_adc_param {
@@ -1242,15 +1229,11 @@ static int meson_sar_adc_probe(struct platform_device *pdev)
return ret;
}
- if (priv->temperature_sensor_calibrated) {
- indio_dev->channels = meson_sar_adc_and_temp_iio_channels;
- indio_dev->num_channels =
- ARRAY_SIZE(meson_sar_adc_and_temp_iio_channels);
- } else {
- indio_dev->channels = meson_sar_adc_iio_channels;
- indio_dev->num_channels =
- ARRAY_SIZE(meson_sar_adc_iio_channels);
- }
+ indio_dev->channels = meson_sar_adc_iio_channels;
+ indio_dev->num_channels = ARRAY_SIZE(meson_sar_adc_iio_channels);
+ /* last item is temp channel */
+ if (!priv->temperature_sensor_calibrated)
+ indio_dev->num_channels--;
ret = meson_sar_adc_init(indio_dev);
if (ret)
--
2.38.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-06-23 2:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 2:20 [PATCH v2 0/6] meson saradc: add iio channels to read channel 7 mux inputs George Stark
2023-06-23 2:20 ` [PATCH v2 1/6] meson saradc: move enums declaration before variables declaration George Stark
2023-06-23 2:20 ` [PATCH v2 2/6] meson saradc: move meson_sar_adc_set_chan7_mux routine upper George Stark
2023-06-23 2:20 ` George Stark [this message]
2023-06-23 2:20 ` [PATCH v2 4/6] meson saradc: add enum for iio channel array indexes George Stark
2023-06-23 2:20 ` [PATCH v2 5/6] meson saradc: add channel labels George Stark
2023-06-23 2:20 ` [PATCH v2 6/6] meson saradc: support reading from channel7 mux inputs George Stark
2023-06-23 6:16 ` Martin Blumenstingl
2023-06-24 15:59 ` George Stark
2023-06-25 11:19 ` Jonathan Cameron
[not found] ` <67d2a9b7-ac7b-57f7-d053-cff4bf0f9d2e@sberdevices.ru>
2023-06-25 20:37 ` Martin Blumenstingl
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=20230623022334.791026-4-gnstark@sberdevices.ru \
--to=gnstark@sberdevices.ru \
--cc=andriy.shevchenko@linux.intel.com \
--cc=jbrunet@baylibre.com \
--cc=jic23@kernel.org \
--cc=kernel@sberdevices.ru \
--cc=khilman@baylibre.com \
--cc=lars@metafoo.de \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.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