Re: [PATCH] iio: adc: at91-sama5d2_adc: explain why indio_dev->name = dev_name() is wrong

From: Jonathan Cameron

Date: Sat Sep 27 2025 - 11:58:40 EST


On Sun, 21 Sep 2025 21:33:02 +0300
Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:

> On Sat, Sep 20, 2025 at 7:44 PM David Lechner <dlechner@xxxxxxxxxxxx> wrote:
> >
> > 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.
>
> ...
>
> > + /*
> > + * 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.
>
> Please, use the full path from the root of the source tree, i.e.
> drivers/iio/adc/ltc2497-core.c. IIRC the Sphynx might even render the
> links properly (if it ever goes to this deep comment, which is not
> marked as kernel-doc).

Other than that this looks like a good approach to me.
I was thinking maybe a reference to central doc, but that might be a bit fragile
so I think I prefer this approach of stating it fully at each place it matters.

Thanks,

Jonathan

>
> > + */
> > indio_dev->name = dev_name(&pdev->dev);
>