Re: [PATCH RFC 1/2] i2c: add fwnode APIs

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

 



Hi Mika,

On Thu, Dec 08, 2022 at 12:04:02PM +0200, Mika Westerberg wrote:
> Hi,
> 
> On Wed, Dec 07, 2022 at 11:22:24AM +0000, Russell King (Oracle) wrote:
> > +struct i2c_client *i2c_find_device_by_fwnode(struct fwnode_handle *fwnode)
> > +{
> > +	struct i2c_client *client;
> > +	struct device *dev;
> > +
> > +	if (!fwnode)
> > +		return NULL;
> > +
> > +	dev = bus_find_device_by_fwnode(&i2c_bus_type, fwnode);
> > +	if (!dev)
> > +		return NULL;
> > +
> > +	client = i2c_verify_client(dev);
> > +	if (!client)
> > +		put_device(dev);
> > +
> > +	return client;
> > +}
> > +EXPORT_SYMBOL(i2c_find_device_by_fwnode);
> > +
> 
> Drop this empty line.

The additional empty line was there before, and I guess is something the
I2C maintainer wants to logically separate the i2c device stuff from
the rest of the file.

> > +/* must call put_device() when done with returned i2c_client device */
> > +struct i2c_client *i2c_find_device_by_fwnode(struct fwnode_handle *fwnode);
> 
> With the kernel-docs in place you probably can drop these comments.

It's what is there against the other prototypes - and is very easy to
get wrong, as I've recently noticed in the sfp.c code as a result of
creating this series.

I find the whole _find_ vs _get_ thing a tad confusing, and there
probably should be just one interface with one way of putting
afterwards to avoid subtle long-standing bugs like this.

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux