Commit 65ec1d0d authored by Boris Brezillon's avatar Boris Brezillon

i3c: Simplify i3c_device_match_id()

Simply match against ->match_flags instead of trying to be smart and
fix drivers inconsistent ID tables.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: default avatarVitor Soares <vitor.soares@synopsys.com>
Link: https://lore.kernel.org/linux-i3c/8c5d6523e1c161783db834a3447954f7fd6267e6.1582796652.git.vitor.soares@synopsys.com
parent 1ce589ad
...@@ -213,39 +213,33 @@ i3c_device_match_id(struct i3c_device *i3cdev, ...@@ -213,39 +213,33 @@ i3c_device_match_id(struct i3c_device *i3cdev,
{ {
struct i3c_device_info devinfo; struct i3c_device_info devinfo;
const struct i3c_device_id *id; const struct i3c_device_id *id;
u16 manuf, part, ext_info;
bool rndpid;
i3c_device_get_info(i3cdev, &devinfo); i3c_device_get_info(i3cdev, &devinfo);
/* manuf = I3C_PID_MANUF_ID(devinfo.pid);
* The lower 32bits of the provisional ID is just filled with a random part = I3C_PID_PART_ID(devinfo.pid);
* value, try to match using DCR info. ext_info = I3C_PID_EXTRA_INFO(devinfo.pid);
*/ rndpid = I3C_PID_RND_LOWER_32BITS(devinfo.pid);
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++) { for (id = id_table; id->match_flags != 0; id++) {
if ((id->match_flags & I3C_MATCH_MANUF_AND_PART) != if ((id->match_flags & I3C_MATCH_DCR) &&
I3C_MATCH_MANUF_AND_PART) id->dcr != devinfo.dcr)
continue; continue;
if (manuf != id->manuf_id || part != id->part_id) if ((id->match_flags & I3C_MATCH_MANUF) &&
id->manuf_id != manuf)
continue; continue;
if ((id->match_flags & I3C_MATCH_EXTRA_INFO) && if ((id->match_flags & I3C_MATCH_PART) &&
ext_info != id->extra_info) (rndpid || id->part_id != part))
continue; continue;
return id; if ((id->match_flags & I3C_MATCH_EXTRA_INFO) &&
} (rndpid || id->extra_info != ext_info))
} continue;
/* 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; return id;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment