From: David Lechner <dlechner@baylibre.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>
Cc: Alexandru Ardelean <aardelean@baylibre.com>,
Alisa-Dariana Roman <alisa.roman@analog.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Conor Dooley <conor+dt@kernel.org>,
Dumitru Ceclan <dumitru.ceclan@analog.com>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Nuno Sa <nuno.sa@analog.com>, Rob Herring <robh@kernel.org>,
devicetree@vger.kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH v3 01/10] iio: adc: ad7124: Don't create more channels than the driver can handle
Date: Fri, 22 Nov 2024 09:14:18 -0600 [thread overview]
Message-ID: <afbb5d4d-8715-4544-b372-be23811eebd0@baylibre.com> (raw)
In-Reply-To: <20241122113322.242875-13-u.kleine-koenig@baylibre.com>
On 11/22/24 5:33 AM, Uwe Kleine-König wrote:
> The ad7124-4 and ad7124-8 both support 16 channel registers and assigns
> each channel defined in dt statically such a register. While the driver
> could be a bit more clever about this, it currently isn't and specifying
> more than 16 channels yields broken behaviour. So just refuse to bind in
> this situation.
The ad7124-4 datasheet I am looking at says that it only has registers
CONFIG_0 to CONFIG_7, so do we need to limit those chips to 8 channels?
>
> Fixes: b3af341bbd96 ("iio: adc: Add ad7124 support")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---
> drivers/iio/adc/ad7124.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
> index 8d94bc2b1cac..5352b26bb391 100644
> --- a/drivers/iio/adc/ad7124.c
> +++ b/drivers/iio/adc/ad7124.c
> @@ -821,6 +821,16 @@ static int ad7124_parse_channel_config(struct iio_dev *indio_dev,
> if (!st->num_channels)
> return dev_err_probe(dev, -ENODEV, "no channel children\n");
>
> + /*
> + * The driver assigns each logical channel defined in the device tree
> + * statically one channel register. So only accept 16 such logical
> + * channels to not treat CONFIG_0 (i.e. the register following
> + * CHANNEL_15) as an additional channel register. The driver could be
> + * improved to lift this limitation.
> + */
> + if (st->num_channels > AD7124_MAX_CHANNELS)
> + return dev_err_probe(dev, -EINVAL, "Too many channels defined\n");
> +
> chan = devm_kcalloc(indio_dev->dev.parent, st->num_channels,
> sizeof(*chan), GFP_KERNEL);
> if (!chan)
next prev parent reply other threads:[~2024-11-22 15:14 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 11:33 [PATCH v3 00/10] iio: adc: ad7124: Various fixes Uwe Kleine-König
2024-11-22 11:33 ` [PATCH v3 01/10] iio: adc: ad7124: Don't create more channels than the driver can handle Uwe Kleine-König
2024-11-22 15:14 ` David Lechner [this message]
2024-11-22 15:54 ` Uwe Kleine-König
2024-11-22 16:18 ` David Lechner
2024-11-22 11:33 ` [PATCH v3 02/10] iio: adc: ad7124: Refuse invalid input specifiers Uwe Kleine-König
2024-11-22 11:33 ` [PATCH v3 03/10] dt-bindings: iio: adc: adi,ad7124: Allow specifications of a gpio for irq line Uwe Kleine-König
2024-11-27 13:41 ` Rob Herring
2024-11-27 15:09 ` Uwe Kleine-König
2024-11-22 11:33 ` [PATCH v3 04/10] iio: adc: ad_sigma_delta: Add support for reading irq status using a GPIO Uwe Kleine-König
2024-11-22 19:16 ` Andy Shevchenko
2024-11-25 10:49 ` Uwe Kleine-König
2024-11-22 11:33 ` [PATCH v3 05/10] iio: adc: ad_sigma_delta: Handle CS assertion as intended in ad_sd_read_reg_raw() Uwe Kleine-König
2024-11-22 15:16 ` Trevor Gamblin
2024-11-22 15:55 ` Uwe Kleine-König
2024-11-22 11:33 ` [PATCH v3 06/10] iio: adc: ad_sigma_delta: Fix a race condition Uwe Kleine-König
2024-11-22 19:21 ` Andy Shevchenko
2024-11-22 11:33 ` [PATCH v3 07/10] iio: adc: ad_sigma_delta: Store information about reset sequence length Uwe Kleine-König
2024-11-22 20:07 ` Andy Shevchenko
2024-11-25 10:14 ` kernel test robot
2024-11-22 11:33 ` [PATCH v3 08/10] iio: adc: ad_sigma_delta: Check for previous ready signals Uwe Kleine-König
2024-11-22 20:17 ` Andy Shevchenko
2024-11-25 11:10 ` Uwe Kleine-König
2024-11-22 11:33 ` [PATCH v3 09/10] iio: adc: ad7124: Add error reporting during probe Uwe Kleine-König
2024-11-22 16:44 ` Trevor Gamblin
2024-11-25 11:20 ` Uwe Kleine-König
2024-11-22 20:25 ` Andy Shevchenko
2024-11-25 11:18 ` Uwe Kleine-König
2024-11-22 11:33 ` [PATCH v3 10/10] iio: adc: ad7124: Implement temperature measurement Uwe Kleine-König
2024-11-22 15:46 ` David Lechner
2024-11-22 20:31 ` Andy Shevchenko
2024-11-25 11:27 ` Uwe Kleine-König
2024-11-25 13:47 ` Andy Shevchenko
2024-11-25 14:52 ` Uwe Kleine-König
2024-11-25 19:33 ` Andy Shevchenko
2024-11-27 14:05 ` Nuno Sá
2024-11-27 14:38 ` Uwe Kleine-König
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=afbb5d4d-8715-4544-b372-be23811eebd0@baylibre.com \
--to=dlechner@baylibre.com \
--cc=Michael.Hennerich@analog.com \
--cc=aardelean@baylibre.com \
--cc=alisa.roman@analog.com \
--cc=andy.shevchenko@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dumitru.ceclan@analog.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=u.kleine-koenig@baylibre.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