[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sat, 8 Aug 2020 06:46:15 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Stephen Kitt <steve@....org>
Cc: Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org,
linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
Wolfram Sang <wsa@...nel.org>
Subject: Re: [PATCH v3] hwmon/pmbus: use simple i2c probe function
On 8/7/20 11:53 PM, Stephen Kitt wrote:
> On Fri, 7 Aug 2020 21:07:07 +0200, Stephen Kitt <steve@....org> wrote:
>
>> On Fri, 7 Aug 2020 10:32:31 -0700, Guenter Roeck <linux@...ck-us.net> 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
> [...]
>
> I get it, the code assumes there’s a bijection between the set of names and
> the set of driver_data values. So effectively we can’t log the detected name
> based on the chip_id...
Exactly.
Thanks,
Guenter
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists