From: Guenter Roeck <linux@roeck-us.net>
To: Peter Rosin <peda@axentia.se>
Cc: Wolfram Sang <wsa@the-dreams.de>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
Guenter Roeck <linux@roeck-us.net>
Subject: [RFC PATCH 2/2] i2c: mux: pca954x: Use API function to verify device ID
Date: Mon, 19 Mar 2018 09:10:59 -0700 [thread overview]
Message-ID: <1521475859-16765-2-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1521475859-16765-1-git-send-email-linux@roeck-us.net>
Use i2c_verify_device_id() to verify the device ID in the probe function.
Cc: Peter Rosin <peda@axentia.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
RFC: Compile tested only
drivers/i2c/muxes/i2c-mux-pca954x.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index 09bafd3e68fa..80b7db26b02a 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -148,6 +148,7 @@ static const struct chip_desc chips[] = {
.id = {
.manufacturer_id = I2C_DEVICE_ID_NXP_SEMICONDUCTORS,
.part_id = 0x10b,
+ .die_revision = I2C_DEVICE_DIE_REVISION_ANY,
},
},
[pca_9847] = {
@@ -157,6 +158,7 @@ static const struct chip_desc chips[] = {
.id = {
.manufacturer_id = I2C_DEVICE_ID_NXP_SEMICONDUCTORS,
.part_id = 0x108,
+ .die_revision = I2C_DEVICE_DIE_REVISION_ANY,
},
},
[pca_9848] = {
@@ -165,6 +167,7 @@ static const struct chip_desc chips[] = {
.id = {
.manufacturer_id = I2C_DEVICE_ID_NXP_SEMICONDUCTORS,
.part_id = 0x10a,
+ .die_revision = I2C_DEVICE_DIE_REVISION_ANY,
},
},
[pca_9849] = {
@@ -174,6 +177,7 @@ static const struct chip_desc chips[] = {
.id = {
.manufacturer_id = I2C_DEVICE_ID_NXP_SEMICONDUCTORS,
.part_id = 0x109,
+ .die_revision = I2C_DEVICE_DIE_REVISION_ANY,
},
},
};
@@ -400,23 +404,9 @@ static int pca954x_probe(struct i2c_client *client,
else
data->chip = &chips[id->driver_data];
- if (data->chip->id.manufacturer_id != I2C_DEVICE_ID_NONE) {
- struct i2c_device_identity id;
-
- ret = i2c_get_device_id(client, &id);
- if (ret && ret != -EOPNOTSUPP)
- return ret;
-
- if (!ret &&
- (id.manufacturer_id != data->chip->id.manufacturer_id ||
- id.part_id != data->chip->id.part_id)) {
- dev_warn(&client->dev,
- "unexpected device id %03x-%03x-%x\n",
- id.manufacturer_id, id.part_id,
- id.die_revision);
- return -ENODEV;
- }
- }
+ ret = i2c_verify_device_id(client, &data->chip->id);
+ if (ret < 0 && ret != -EOPNOTSUPP)
+ return ret;
/* Write the mux register at addr to verify
* that the mux is in fact present. This also
--
2.7.4
next prev parent reply other threads:[~2018-03-19 16:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-19 16:10 [RFC PATCH 1/2] i2c: Add i2c_verify_device_id() to verify device id Guenter Roeck
2018-03-19 16:10 ` Guenter Roeck [this message]
2018-03-19 16:47 ` Peter Rosin
2018-03-19 18:48 ` Guenter Roeck
2018-03-19 19:55 ` Peter Rosin
2018-03-19 20:50 ` Guenter Roeck
2018-03-19 23:09 ` Peter Rosin
2018-04-08 7:34 ` Wolfram Sang
2018-04-08 9:08 ` Peter Rosin
2018-04-08 10:28 ` Peter Rosin
2018-04-09 18:29 ` Guenter Roeck
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=1521475859-16765-2-git-send-email-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=wsa@the-dreams.de \
/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).