Re: [PATCH RFC] i2c: Add a void pointer to i2c_device_id

From: Uwe Kleine-König
Date: Mon Apr 29 2024 - 09:59:34 EST


Hello Andy,

On Mon, Apr 29, 2024 at 01:28:32PM +0300, Andy Shevchenko wrote:
> On Mon, Apr 29, 2024 at 12:21:05PM +0200, Uwe Kleine-König wrote:
> > On Mon, Apr 29, 2024 at 11:54:29AM +0300, Andy Shevchenko wrote:
> > > On Fri, Apr 26, 2024 at 11:38:33PM +0200, Uwe Kleine-König wrote:
>
> ...
>
> > > > static const struct i2c_device_id wlf_gf_module_id[] = {
> > > > - { "wlf-gf-module", 0 },
> > > > + { "wlf-gf-module", },
> > >
> > > In such cases the inner comma is redundant as well.
> >
> > I would tend to keep the comma, but no strong opinion on my side.
>
> It's just a confusing leftover in my opinion.
>
> > If another member init is added later, the line has to be touched
> > anyhow, but in the layout:
> >
> > ... = {
> > {
> > "wlf-gf-module",
> > },
> > { }
> > }
> >
> > I'd keep it for sure.
>
> That's not what I object. Here I am 100% with you.

OK, agreed. I'm not sure yet if I prefer

static const struct i2c_device_id wlf_gf_module_id[] = {
{ "wlf-gf-module" },
{ }
};

or

static const struct i2c_device_id wlf_gf_module_id[] = {
{ .name = "wlf-gf-module" },
{ }
};

> > > In general idea might be okay, but I always have the same Q (do we have it
> > > being clarified in the documentation, btw): is an ID table the ABI or not?
> > > In another word, how should we treat the changes there, because ID tables
> > > are being used by the user space tools.
> >
> > Note that the layout doesn't change and the traditional interpretation
> > of the data still works fine. Or do you see something that I miss?
>
> Do we have any configurations / architectures / etc when
> sizeof(kernel_ulong_t) != sizeof(void *) ? If not, we are fine.

According to https://wiki.debian.org/ArchitectureSpecificsMemo (my goto
address for such questions) we have sizeof(void *) == sizeof(long) on
all archs. Also storing a pointer in today's struct
i2c_device_id::driver_data is so common that it should be safe to assume
that sizeof(void *) <= sizeof(kernel_ulong_t). And that <= is enough
that the union doesn't get bigger.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature