Re: [PATCH v3] i2c: Add i2c_get_match_data()

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

 



Hi Biju,

On Wed, Jun 7, 2023 at 9:21 AM Biju Das <biju.das.jz@xxxxxxxxxxxxxx> wrote:
> Do we need to enhance the logic to use device_get_match_data
> to support OF/ACPI/I2C match like below [1].

Why not?

>
> Or
>
> Are we happy with the current one?

I don't mind.

> +const void *i2c_get_match_data(const struct i2c_client *client) {
> +       struct device_driver *drv = client->dev.driver;
> +       struct i2c_driver *driver = to_i2c_driver(drv);
> +       const struct i2c_device_id *match;
> +       const void *data;
> +
> +       data = device_get_match_data(&client->dev);

    if (data)
            return data;

> +       if (!data) {
> +               match = i2c_match_id(driver->id_table, client);
> +               if (!match)
> +                       return NULL;
> +
> +               data = (const void *)match->driver_data;
> +       }
> +
> > +     return data;
> > +}
> > +EXPORT_SYMBOL(i2c_get_match_data);

> > From: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>

> > --- a/drivers/i2c/i2c-core-base.c
> > +++ b/drivers/i2c/i2c-core-base.c
> > @@ -114,6 +114,27 @@ const struct i2c_device_id *i2c_match_id(const
> > struct i2c_device_id *id,  }  EXPORT_SYMBOL_GPL(i2c_match_id);
> >
> > +const void *i2c_get_match_data(const struct i2c_client *client) {
> > +     struct device_driver *drv = client->dev.driver;
> > +     struct i2c_driver *driver = to_i2c_driver(drv);
> > +     const struct i2c_device_id *match;
> > +     const void *data;
> > +
> > +     if (client->dev.of_node) {
> > +             data = of_device_get_match_data(&client->dev);

return of_device_get_match_data(&client->dev);

> > +     } else {
> > +             match = i2c_match_id(driver->id_table, client);
> > +             if (!match)
> > +                     return NULL;
> > +
> > +             data = (const void *)match->driver_data;

return ...

> > +     }
> > +
> > +     return data;
> > +}
> > +EXPORT_SYMBOL(i2c_get_match_data);

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 GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux