From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Boris Brezillon" <bbrezillon@kernel.org>,
"Przemysław Gaj" <pgaj@cadence.com>,
"Vitor Soares" <Vitor.Soares@synopsys.com>,
linux-i3c@lists.infradead.org
Cc: linux-kernel@vger.kernel.org,
Boris Brezillon <boris.brezillon@collabora.com>
Subject: [PATCH 3/3] i3c: Simplify i3c_device_match_id()
Date: Sat, 22 Feb 2020 11:27:11 +0100 [thread overview]
Message-ID: <20200222102711.1352006-4-boris.brezillon@collabora.com> (raw)
In-Reply-To: <20200222102711.1352006-1-boris.brezillon@collabora.com>
Simply match against ->match_flags instead of trying to be smart and
fix drivers inconsistent ID tables.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
drivers/i3c/device.c | 50 +++++++++++++++++++-------------------------
1 file changed, 22 insertions(+), 28 deletions(-)
diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
index 9e2e1406f85e..bb8e60dff988 100644
--- a/drivers/i3c/device.c
+++ b/drivers/i3c/device.c
@@ -213,40 +213,34 @@ i3c_device_match_id(struct i3c_device *i3cdev,
{
struct i3c_device_info devinfo;
const struct i3c_device_id *id;
+ u16 manuf, part, ext_info;
+ bool rndpid;
i3c_device_get_info(i3cdev, &devinfo);
- /*
- * The lower 32bits of the provisional ID is just filled with a random
- * value, try to match using DCR info.
- */
- if (!I3C_PID_RND_LOWER_32BITS(devinfo.pid)) {
- u16 manuf = I3C_PID_MANUF_ID(devinfo.pid);
- u16 part = I3C_PID_PART_ID(devinfo.pid);
- u16 ext_info = I3C_PID_EXTRA_INFO(devinfo.pid);
-
- /* First try to match by manufacturer/part ID. */
- for (id = id_table; id->match_flags != 0; id++) {
- if ((id->match_flags & I3C_MATCH_MANUF_AND_PART) !=
- I3C_MATCH_MANUF_AND_PART)
- continue;
-
- if (manuf != id->manuf_id || part != id->part_id)
- continue;
-
- if ((id->match_flags & I3C_MATCH_EXTRA_INFO) &&
- ext_info != id->extra_info)
- continue;
-
- return id;
- }
- }
+ manuf = I3C_PID_MANUF_ID(devinfo.pid);
+ part = I3C_PID_PART_ID(devinfo.pid);
+ ext_info = I3C_PID_EXTRA_INFO(devinfo.pid);
+ rndpid = I3C_PID_RND_LOWER_32BITS(devinfo.pid);
- /* Fallback to DCR match. */
for (id = id_table; id->match_flags != 0; id++) {
if ((id->match_flags & I3C_MATCH_DCR) &&
- id->dcr == devinfo.dcr)
- return id;
+ id->dcr != devinfo.dcr)
+ continue;
+
+ if ((id->match_flags & I3C_MATCH_MANUF) &&
+ id->manuf_id != manuf)
+ continue;
+
+ if ((id->match_flags & I3C_MATCH_PART) &&
+ (rndpid || id->part_id != part))
+ continue;
+
+ if ((id->match_flags & I3C_MATCH_EXTRA_INFO) &&
+ (rndpid || id->extra_info != ext_info))
+ continue;
+
+ return id;
}
return NULL;
--
2.24.1
next prev parent reply other threads:[~2020-02-22 10:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-22 10:27 [PATCH 0/3] i3c: Address i3c_device_id related issues Boris Brezillon
2020-02-22 10:27 ` [PATCH 1/3] i3c: Fix MODALIAS uevents Boris Brezillon
2020-02-22 10:27 ` [PATCH 2/3] i3c: Generate aliases for i3c modules Boris Brezillon
2020-02-26 11:50 ` Boris Brezillon
2020-02-22 10:27 ` Boris Brezillon [this message]
2020-02-26 17:37 ` [PATCH 0/3] i3c: Address i3c_device_id related issues Boris Brezillon
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=20200222102711.1352006-4-boris.brezillon@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=Vitor.Soares@synopsys.com \
--cc=bbrezillon@kernel.org \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pgaj@cadence.com \
/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).