lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y5IoRdxle8nbrK4U@smile.fi.intel.com>
Date:   Thu, 8 Dec 2022 20:09:09 +0200
From:   Andy Shevchenko <andriy.shevchenko@...el.com>
To:     Tomi Valkeinen <tomi.valkeinen@...asonboard.com>
Cc:     linux-media@...r.kernel.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-i2c@...r.kernel.org,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Wolfram Sang <wsa@...nel.org>,
        Luca Ceresoli <luca.ceresoli@...tlin.com>,
        Matti Vaittinen <Matti.Vaittinen@...rohmeurope.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Peter Rosin <peda@...ntia.se>,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>,
        Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
        Michael Tretter <m.tretter@...gutronix.de>,
        Shawn Tu <shawnx.tu@...el.com>,
        Hans Verkuil <hverkuil@...all.nl>,
        Mike Pagano <mpagano@...too.org>,
        Krzysztof HaƂasa <khalasa@...p.pl>,
        Marek Vasut <marex@...x.de>,
        Luca Ceresoli <luca@...aceresoli.net>
Subject: Re: [PATCH v5 2/8] i2c: add I2C Address Translator (ATR) support

On Thu, Dec 08, 2022 at 06:01:19PM +0200, Tomi Valkeinen wrote:
> On 08/12/2022 14:53, Andy Shevchenko wrote:
> > On Thu, Dec 08, 2022 at 12:40:00PM +0200, Tomi Valkeinen wrote:

...

> > > +	if (bus_handle) {
> > > +		device_set_node(&chan->adap.dev, fwnode_handle_get(bus_handle));
> > 
> > I believe the correct way, while above still works, is
> > 
> > 		device_set_node(&chan->adap.dev, bus_handle);
> > 		fwnode_handle_get(dev_fwnode(&chan->adap.dev));
> 
> Hmm, why is that correct? Shouldn't you give device_set_node() an fwnode
> that has been referenced?

You take a reference on the adap->dev and not on input. It's just a logical,
But as I said your variant still works.

> > But I agree that this looks a bit verbose. And...
> > 
> > > +	} else {
> > > +		struct fwnode_handle *atr_node;
> > > +		struct fwnode_handle *child;
> > > +		u32 reg;
> > > +
> > > +		atr_node = device_get_named_child_node(dev, "i2c-atr");
> > > +
> > > +		fwnode_for_each_child_node(atr_node, child) {
> > > +			ret = fwnode_property_read_u32(child, "reg", &reg);
> > > +			if (ret)
> > > +				continue;
> > > +			if (chan_id == reg)
> > > +				break;
> > > +		}
> > > +
> > > +		device_set_node(&chan->adap.dev, child);
> > 
> > ...OTOH, you set node with bumped reference here. So I leave all this to
> > the maintainers.
> > 
> > > +		fwnode_handle_put(atr_node);
> > > +	}

...

> > > +static inline void i2c_atr_set_clientdata(struct i2c_atr *atr, void *data)
> > > +{
> > > +	atr->priv = data;
> > > +}
> > > +
> > > +static inline void *i2c_atr_get_clientdata(struct i2c_atr *atr)
> > > +{
> > > +	return atr->priv;
> > > +}
> > 
> > The function names are misleading, because I would think this is about driver
> > data that has been set.
> > 
> > I would rather use name like
> > 
> > 	i2c_atr_get_priv()
> > 	i2c_atr_set_priv()
> 
> Indeed, set_clientdata is probably wrong. But i2c_atr_set_priv() sounds like
> it's private to the i2c-atr itself. Maybe i2c_atr_set_driver_data?

Works for me.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ