From: Guenter Roeck <linux@roeck-us.net>
To: Stephen Kitt <steve@sk2.org>
Cc: Jean Delvare <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org, Wolfram Sang <wsa@kernel.org>
Subject: Re: [PATCH v3] hwmon/pmbus: use simple i2c probe function
Date: Sat, 8 Aug 2020 06:46:15 -0700 [thread overview]
Message-ID: <383af0fb-7eb9-dea8-291c-962c6b9eedd1@roeck-us.net> (raw)
In-Reply-To: <20200808085329.4713bf38@heffalump.sk2.org>
[-- Attachment #1.1: Type: text/plain, Size: 1364 bytes --]
On 8/7/20 11:53 PM, Stephen Kitt wrote:
> On Fri, 7 Aug 2020 21:07:07 +0200, Stephen Kitt <steve@sk2.org> wrote:
>
>> On Fri, 7 Aug 2020 10:32:31 -0700, Guenter Roeck <linux@roeck-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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-08-08 13:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-07 17:32 [PATCH v3] hwmon/pmbus: use simple i2c probe function Guenter Roeck
2020-08-07 19:07 ` Stephen Kitt
2020-08-08 6:53 ` Stephen Kitt
2020-08-08 13:46 ` Guenter Roeck [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-08-07 16:28 Stephen Kitt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=383af0fb-7eb9-dea8-291c-962c6b9eedd1@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=steve@sk2.org \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).