From: Stephen Kitt <steve@sk2.org>
To: Guenter Roeck <linux@roeck-us.net>
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: Fri, 7 Aug 2020 21:07:07 +0200 [thread overview]
Message-ID: <20200807210707.7dd1d9b9@heffalump.sk2.org> (raw)
In-Reply-To: <20200807173231.GA47449@roeck-us.net>
[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]
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, 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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-08-07 19:33 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 [this message]
2020-08-08 6:53 ` Stephen Kitt
2020-08-08 13:46 ` Guenter Roeck
-- 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=20200807210707.7dd1d9b9@heffalump.sk2.org \
--to=steve@sk2.org \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--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