Re: [PATCH 2/4] usb: typec: tcpci_rt1711h: Convert enum->pointer for data in the match tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andy,

On Mon, Aug 21, 2023 at 3:04 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> On Sun, Aug 20, 2023 at 07:44:00PM +0100, Biju Das wrote:
> > Convert enum->pointer for data in the match tables, so that
> > device_get_match_data() can do match against OF/ACPI/I2C tables, once i2c
> > bus type match support added to it and it returns NULL for non-match.
> >
> > Therefore it is better to convert enum->pointer for data match and extend
> > match support for both ID and OF tables by using i2c_get_match_data() by
> > adding struct rt1711h_chip_info with did variable and replacing did->info
> > in struct rt1711h_chip. Later patches will add more hw differences to
> > struct rt1711h_chip_info and avoid checking did for HW differences.
>
> ...
>
> > +struct rt1711h_chip_info {
> > +     u16 did;
> > +};
> > +
> >  struct rt1711h_chip {
> >       struct tcpci_data data;
> >       struct tcpci *tcpci;
> >       struct device *dev;
> >       struct regulator *vbus;
> >       bool src_en;
> > -     u16 did;
> > +     const struct rt1711h_chip_info *info;
>
> Have you run pahole? I believe now you wasting a few more bytes
> (besides the pointer requirement) due to (mis)placing a new member.

Unfortunately you cannot really improve by reordering the members.
The old u16 fit in the hole after sr_en.
The new pointer info cannot fit in a hole anyway.

> For all your work likes this as I noted in the reply to Guenter that
> the couple of the selling points here are:
> 1) avoidance of the pointer abuse in OF table
>    (we need that to be a valid pointer);

There is no pointer abuse: both const void * (in e.g. of_device_id)
and kernel_ulong_t (in e.g. i2c_device_id) can be used by drivers
to store a magic cookie, being either a pointer, or an integer value.
The same is true for the various unsigned long and void * "driver_data"
fields in subsystem-specific driver structures.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux