From: David Lechner <dlechner@baylibre.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
David Lechner <dlechner@baylibre.com>
Subject: [PATCH] iio: adc: at91-sama5d2_adc: explain why indio_dev->name = dev_name() is wrong
Date: Sat, 20 Sep 2025 11:44:26 -0500 [thread overview]
Message-ID: <20250920-iio-indio_dev-name-wrong-v1-1-d376436abbb6@baylibre.com> (raw)
Add an explanatory comment on why indio_dev->name = dev_name(dev) is
wrong, and that we can't fix it without breaking userspace.
The idea is to prevent future drivers from making the same mistake by
copying this code. And if this driver is ever modified again, we can
at least make sure any new compatible IDs use the correct name.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
It came up in a recent review that there are some (mostly older) IIO
drivers that are incorrectly setting indio_dev->name = dev_name()
instead of the "part number" of the device and that we can't fix these
without breaking userspace.
There are actually about 40 instances of this that I found, so it is
likely that these will be copied to new drivers and we don't catch it
like happened somewhat recently with magnetometer/si7210.
I'm just submitting a single patch for now to see if this is looks like
the right approach. After we refine it, then I can make a series that
fixes it everywhere. I assume we would want one patch per file for this?
---
drivers/iio/adc/at91-sama5d2_adc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index b4c36e6a7490aa9002a702e70a8b37ee3eae6324..cac408fda8eb6f45ab79531a71d5ad868115d735 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -2318,6 +2318,13 @@ static int at91_adc_probe(struct platform_device *pdev)
else
num_channels = st->soc_info.platform->max_channels;
+ /*
+ * The device name is supposed to be the "part number", not the kobject
+ * name. Do not copy this code for new drivers. We can't "fix" this
+ * without breaking userspace, so we have to live with it. However, if
+ * any new compatible IDs are added, please do something similar to
+ * adc/ltc2497-core.c so that at least the new part numbers are correct.
+ */
indio_dev->name = dev_name(&pdev->dev);
indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
indio_dev->info = &at91_adc_info;
---
base-commit: 411e8b72c181e4f49352c12ced0fd8426eb683aa
change-id: 20250912-iio-indio_dev-name-wrong-f5098d2447f1
Best regards,
--
David Lechner <dlechner@baylibre.com>
next reply other threads:[~2025-09-20 16:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-20 16:44 David Lechner [this message]
2025-09-21 18:33 ` [PATCH] iio: adc: at91-sama5d2_adc: explain why indio_dev->name = dev_name() is wrong Andy Shevchenko
2025-09-27 15:58 ` 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=20250920-iio-indio_dev-name-wrong-v1-1-d376436abbb6@baylibre.com \
--to=dlechner@baylibre.com \
--cc=andy@kernel.org \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).