Re: [PATCH v2 4/4] i2c: allow specify device properties in i2c_board_info

Dmitry Torokhov
2017-02-01T17:10:42Z

On Wed, Feb 01, 2017 at 05:24:18PM +0200, Mika Westerberg wrote:
> On Tue, Jan 31, 2017 at 06:11:30PM -0800, Dmitry Torokhov wrote:
> > With many drivers converting to using generic device properties, it is
> > useful to provide array of device properties when instantiating new i2c
> > client via i2c_board_info and have them automatically added to the device
> > in question.
> >
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> > drivers/i2c/i2c-core.c | 16 +++++++++++++++-
> > include/linux/i2c.h | 3 +++
> > 2 files changed, 18 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> > index f009549f86a5..3897e78e5e9a 100644
> > --- a/drivers/i2c/i2c-core.c
> > +++ b/drivers/i2c/i2c-core.c
> > @@ -1335,15 +1335,29 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
> > client->dev.fwnode = info->fwnode;
> >
> > i2c_dev_set_name(adap, client);
> > +
> > + if (info->properties) {
> > + status = device_add_properties(&client->dev, info->properties);
>
> I don't remember anymore how it was but is the driver core supposed to
> free this automatically when the device is removed or should we deal
> this in the i2c-core instead?
>

It is done as part of device_del().

Thanks.

--
Dmitry