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: Fri, 7 Aug 2020 10:32:31 -0700 [thread overview]
Message-ID: <20200807173231.GA47449@roeck-us.net> (raw)
On Fri, Aug 07, 2020 at 06:28:01PM +0200, Stephen Kitt wrote:
> pmbus_do_probe doesn't use the id information provided in its second
> argument, so this can be removed, which then allows using the
> single-parameter i2c probe function ("probe_new") for probes.
>
> This avoids scanning the identifier tables during probes.
>
> Drivers which didn't use the id are converted as-is; drivers which did
> are modified as follows:
>
> * if the information in i2c_client is sufficient, that's used instead
> (client->name);
> * configured v. probed comparisons are performed by comparing the
> configured name to the detected name, instead of the ids; this
> involves strcmp but is still cheaper than comparing all the device
> names when scanning the tables;
> * anything else is handled by calling i2c_match_id() with the same
> level of error-handling (if any) as before.
>
> Signed-off-by: Stephen Kitt <steve@sk2.org>
> ---
> Changes since v1:
> - i2c_device_id declarations are left unchanged;
> - all drivers are converted, using client info or i2c_match_id().
> Changes since v2:
> - updated the documentation;
> - fixed unbalanced braces around the modified else in ibm-cffps.c.
>
[ ... ]
>
> -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.
Thanks,
Guenter
next reply other threads:[~2020-08-07 17:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-07 17:32 Guenter Roeck [this message]
2020-08-07 19:07 ` [PATCH v3] hwmon/pmbus: use simple i2c probe function Stephen Kitt
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=20200807173231.GA47449@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