RE: [PATCH v3 2/2] i2c: Add i2c_device_get_match_data() callback

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

 



Hi Andy Shevchenko,

Thanks for the feedback.

> Subject: Re: [PATCH v3 2/2] i2c: Add i2c_device_get_match_data()
> callback
> 
> On Tue, Aug 01, 2023 at 06:03:18PM +0100, Biju Das wrote:
> > Add i2c_device_get_match_data() callback to struct bus_type().
> >
> > While at it, introduced i2c_get_match_data_helper() to avoid code
> > duplication with i2c_get_match_data().
> 
> Have you used --patience when prepared the patch for sending?

Normally, I use "git format-patch -n --subject-prefix="PATCH vY" --cover-letter" for preparing patch.

I see there is a difference with "git format-patch -n --patience *".

I will send this patch series with --patience option.

> 
> ...
> 
> > -const void *i2c_get_match_data(const struct i2c_client *client)
> > +static const void *i2c_get_match_data_helper(const struct i2c_driver
> *driver,
> > +					     const struct i2c_client *client)
> >  {
> 
> > -	struct i2c_driver *driver = to_i2c_driver(client->dev.driver);
> 
> Does it make sense to remove and add an additional parameter? In one
> case it's a copy, in another it probably the same, just hidden in the
> code.

Ok, you mean add the below check in i2c_device_get_match_data() and
drop *driver parameter from i2c_get_match_data_helper().

if (!client || !dev->driver)                                             
 return NULL;

> 
> >  	const struct i2c_device_id *match;
> > +
> > +	match = i2c_match_id(driver->id_table, client);
> > +	if (!match)
> > +		return NULL;
> > +
> > +	return (const void *)match->driver_data; }
> > +
> > +static const void *i2c_device_get_match_data(const struct device
> > +*dev) {
> > +	/* TODO: use i2c_verify_client() when it accepts const pointer */
> > +	const struct i2c_client *client = (dev->type ==
> &i2c_client_type) ?
> > +					  to_i2c_client(dev) : NULL;
> >  	const void *data;
> 
> > +	if (!dev->driver)
> > +		return NULL;
> 
> When can this be true?
> 
> > +	data = i2c_get_match_data_helper(to_i2c_driver(dev->driver),
> client);
> > +	if (data)
> > +		return data;
> >
> > -		data = (const void *)match->driver_data;
> > +	if (dev->driver->of_match_table) {
> > +		const struct of_device_id *match;
> > +
> > +		match = i2c_of_match_device_sysfs(dev->driver-
> >of_match_table,
> > +						  (struct i2c_client *)client);
> > +		if (match)
> > +			data = match->data;
> >  	}
> >
> >  	return data;
> >  }
> 
> ...
> 
> > -static const struct of_device_id*
> > +const struct of_device_id*
> 
> While here, add a missing space after of_device_id.

OK.

> 
> ...
> 
> > +const struct of_device_id*
> 
> Ditto.
> 
> Or use below (weird) style in case it occurs more often than usual one.

It is one of case. So, I will use space after of_device_id.

> 
> > +i2c_of_match_device_sysfs(const struct of_device_id *matches,
> > +			  struct i2c_client *client);
> > +
> >  const struct of_device_id
> >  *i2c_of_match_device(const struct of_device_id *matches,
> >  		     struct i2c_client *client);
> 
> ...
> 
> > +static inline const struct of_device_id *i2c_of_match_device(const
> > +struct of_device_id *matches,
> 
> As per above.

OK, This will be moved to i2c-core.h.


Cheers,
Biju

> 
> > +		     struct i2c_client *client)
> > +{
> > +	return NULL;
> > +}
> 
> --
> With Best Regards,
> Andy Shevchenko
> 





[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux