Re: [PATCH v3] hwmon/pmbus: use simple i2c probe function

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

 



On Fri, 7 Aug 2020 10:32:31 -0700, Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
> On Fri, Aug 07, 2020 at 06:28:01PM +0200, Stephen Kitt wrote:
> >  
> > -static int ltc2978_probe(struct i2c_client *client,
> > -			 const struct i2c_device_id *id)
> > +static int ltc2978_probe(struct i2c_client *client)
> >  {
> >  	int i, chip_id;
> >  	struct ltc2978_data *data;
> > @@ -670,10 +669,10 @@ static int ltc2978_probe(struct i2c_client *client,
> >  		return chip_id;
> >  
> >  	data->id = chip_id;
> > -	if (data->id != id->driver_data)
> > +	if (strcmp(client->name, ltc2978_id[data->id].name) != 0)  
> 
> I was about to apply this patch, but this is problematic: It assumes that
> __stringify(id) == ltc2978_id[id].name and that ltc2978_id[id].driver_data
> == id. While that is curently the case (as far as I can see), it is still
> unsafe. I think it would be much safer to use i2c_match_id() here.

I’m not following the __stringify assumption, but I do get your point about
the driver_data being a valid index into the array; that was already baked
into the code, as

		dev_warn(&client->dev,
			 "Device mismatch: Configured %s, detected %s\n",
			 client->name,
			 ltc2978_id[data->id].name);

but I’ll fix both.

Similar assumptions are present in other drivers here IIRC, I’ll fix those
too.

Regards,

Stephen

Attachment: pgp0Ax1yEiA4q.pgp
Description: OpenPGP digital signature


[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux