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

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

 



Hi Geert,

Thanks for the feedback.

> Subject: Re: [PATCH v3] i2c: Add i2c_get_match_data()
> 
> Hi Biju,
> 
> On Wed, Jun 7, 2023 at 9:21 AM Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> wrote:

Wolfram,

What is your preference in supporting OF/ACPI/I2C match-data as in [A]?

Or

Just support OF/i2C match-data as in [B]?

> > 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.
> 

[A]

> > +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);
> > >

[B]

> > > +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);
> 

Cheers,
Biju




[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux