lkml.org 
[lkml]   [2021]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1 1/1] i2c: core: Do not dereference fwnode in struct device
On Thu, Dec 09, 2021 at 09:44:49AM +0100, Wolfram Sang wrote:
>
> > client->dev.parent = &client->adapter->dev;
> > client->dev.bus = &i2c_bus_type;
> > client->dev.type = &i2c_client_type;
> > - client->dev.of_node = of_node_get(info->of_node);
> > - client->dev.fwnode = info->fwnode;
> >
> > device_enable_async_suspend(&client->dev);
> > i2c_dev_set_name(adap, client, info);
> >
> > + device_set_node(&client->dev, info->fwnode);
> > + client->dev.of_node = of_node_get(info->of_node);
> > +
>
> I am basically OK with this change. I'd just move the code block a
> little to have the same behaviour as before. Something like this
> (hand-edited preview version):

And this is exactly what have been done.

> > client->dev.bus = &i2c_bus_type;
> > client->dev.type = &i2c_client_type;
> > client->dev.of_node = of_node_get(info->of_node);
> > - client->dev.fwnode = info->fwnode;
> >
> > + device_set_node(&client->dev, info->fwnode);
> > device_enable_async_suspend(&client->dev);
> > i2c_dev_set_name(adap, client, info);
>
> Are you okay with that?

It will be broken in this case. There is subtle detail about device_set_node(),
it sets both fwnode and of_node at once. More thinking about this, I admit that
the best strategy now is to drop this change for now.

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2021-12-09 11:09    [W:2.204 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site