Linux-i3c Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/3] i3c: Address i3c_device_id related issues
@ 2020-02-22 10:27 Boris Brezillon
  2020-02-22 10:27 ` [PATCH 1/3] i3c: Fix MODALIAS uevents Boris Brezillon
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Boris Brezillon @ 2020-02-22 10:27 UTC (permalink / raw)
  To: Boris Brezillon, Przemysław Gaj, Vitor Soares, linux-i3c
  Cc: Boris Brezillon, linux-kernel

Hello,

When the I3C subsystem was introduced part of the modalias generation
logic was missing (modalias generation based on i3c_device_id tables).
This patch series addresses that limitation and simplifies our match
function along the way.

Regards,

Boris

Boris Brezillon (3):
  i3c: Fix MODALIAS uevents
  i3c: Generate aliases for i3c modules
  i3c: Simplify i3c_device_match_id()

 drivers/i3c/device.c              | 50 ++++++++++++++-----------------
 drivers/i3c/master.c              |  2 +-
 scripts/mod/devicetable-offsets.c |  7 +++++
 scripts/mod/file2alias.c          | 19 ++++++++++++
 4 files changed, 49 insertions(+), 29 deletions(-)

-- 
2.24.1


_______________________________________________
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] i3c: Fix MODALIAS uevents
  2020-02-22 10:27 [PATCH 0/3] i3c: Address i3c_device_id related issues Boris Brezillon
@ 2020-02-22 10:27 ` Boris Brezillon
  2020-02-22 10:27 ` [PATCH 2/3] i3c: Generate aliases for i3c modules Boris Brezillon
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2020-02-22 10:27 UTC (permalink / raw)
  To: Boris Brezillon, Przemysław Gaj, Vitor Soares, linux-i3c
  Cc: Boris Brezillon, linux-kernel

file2alias uses %X formatters. Fix typos in the MODALIAS uevent to print
the part and ext IDs in uppercase.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 drivers/i3c/master.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index b56207bbed2b..b6db82862a63 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -267,7 +267,7 @@ static int i3c_device_uevent(struct device *dev, struct kobj_uevent_env *env)
 				      devinfo.dcr, manuf);
 
 	return add_uevent_var(env,
-			      "MODALIAS=i3c:dcr%02Xmanuf%04Xpart%04xext%04x",
+			      "MODALIAS=i3c:dcr%02Xmanuf%04Xpart%04Xext%04X",
 			      devinfo.dcr, manuf, part, ext);
 }
 
-- 
2.24.1


_______________________________________________
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/3] i3c: Generate aliases for i3c modules
  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 ` Boris Brezillon
  2020-02-26 11:50   ` Boris Brezillon
  2020-02-22 10:27 ` [PATCH 3/3] i3c: Simplify i3c_device_match_id() Boris Brezillon
  2020-02-26 17:37 ` [PATCH 0/3] i3c: Address i3c_device_id related issues Boris Brezillon
  3 siblings, 1 reply; 6+ messages in thread
From: Boris Brezillon @ 2020-02-22 10:27 UTC (permalink / raw)
  To: Boris Brezillon, Przemysław Gaj, Vitor Soares, linux-i3c
  Cc: Boris Brezillon, linux-kernel

This part was missing, thus preventing user space from loading modules
automatically when MODALIAS uevents are received.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
---
 scripts/mod/devicetable-offsets.c |  7 +++++++
 scripts/mod/file2alias.c          | 19 +++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
index 054405b90ba4..d3c237b9b7c0 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -145,6 +145,13 @@ int main(void)
 	DEVID(i2c_device_id);
 	DEVID_FIELD(i2c_device_id, name);
 
+	DEVID(i3c_device_id);
+	DEVID_FIELD(i3c_device_id, match_flags);
+	DEVID_FIELD(i3c_device_id, dcr);
+	DEVID_FIELD(i3c_device_id, manuf_id);
+	DEVID_FIELD(i3c_device_id, part_id);
+	DEVID_FIELD(i3c_device_id, extra_info);
+
 	DEVID(spi_device_id);
 	DEVID_FIELD(spi_device_id, name);
 
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index c91eba751804..1754de3f119f 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -919,6 +919,24 @@ static int do_i2c_entry(const char *filename, void *symval,
 	return 1;
 }
 
+static int do_i3c_entry(const char *filename, void *symval,
+			char *alias)
+{
+	DEF_FIELD(symval, i3c_device_id, match_flags);
+	DEF_FIELD(symval, i3c_device_id, dcr);
+	DEF_FIELD(symval, i3c_device_id, manuf_id);
+	DEF_FIELD(symval, i3c_device_id, part_id);
+	DEF_FIELD(symval, i3c_device_id, extra_info);
+
+	strcpy(alias, "i3c:");
+	ADD(alias, "dcr", match_flags & I3C_MATCH_DCR, dcr);
+	ADD(alias, "manuf", match_flags & I3C_MATCH_MANUF, dcr);
+	ADD(alias, "part", match_flags & I3C_MATCH_PART, dcr);
+	ADD(alias, "ext", match_flags & I3C_MATCH_EXTRA_INFO, dcr);
+
+	return 1;
+}
+
 /* Looks like: spi:S */
 static int do_spi_entry(const char *filename, void *symval,
 			char *alias)
@@ -1386,6 +1404,7 @@ static const struct devtable devtable[] = {
 	{"vmbus", SIZE_hv_vmbus_device_id, do_vmbus_entry},
 	{"rpmsg", SIZE_rpmsg_device_id, do_rpmsg_entry},
 	{"i2c", SIZE_i2c_device_id, do_i2c_entry},
+	{"i3c", SIZE_i3c_device_id, do_i3c_entry},
 	{"spi", SIZE_spi_device_id, do_spi_entry},
 	{"dmi", SIZE_dmi_system_id, do_dmi_entry},
 	{"platform", SIZE_platform_device_id, do_platform_entry},
-- 
2.24.1


_______________________________________________
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/3] i3c: Simplify i3c_device_match_id()
  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-22 10:27 ` Boris Brezillon
  2020-02-26 17:37 ` [PATCH 0/3] i3c: Address i3c_device_id related issues Boris Brezillon
  3 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2020-02-22 10:27 UTC (permalink / raw)
  To: Boris Brezillon, Przemysław Gaj, Vitor Soares, linux-i3c
  Cc: Boris Brezillon, linux-kernel

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


_______________________________________________
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] i3c: Generate aliases for i3c modules
  2020-02-22 10:27 ` [PATCH 2/3] i3c: Generate aliases for i3c modules Boris Brezillon
@ 2020-02-26 11:50   ` Boris Brezillon
  0 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2020-02-26 11:50 UTC (permalink / raw)
  To: Boris Brezillon, Przemysław Gaj, Vitor Soares, linux-i3c
  Cc: linux-kernel

On Sat, 22 Feb 2020 11:27:10 +0100
Boris Brezillon <boris.brezillon@collabora.com> wrote:

> +static int do_i3c_entry(const char *filename, void *symval,
> +			char *alias)
> +{
> +	DEF_FIELD(symval, i3c_device_id, match_flags);
> +	DEF_FIELD(symval, i3c_device_id, dcr);
> +	DEF_FIELD(symval, i3c_device_id, manuf_id);
> +	DEF_FIELD(symval, i3c_device_id, part_id);
> +	DEF_FIELD(symval, i3c_device_id, extra_info);
> +
> +	strcpy(alias, "i3c:");
> +	ADD(alias, "dcr", match_flags & I3C_MATCH_DCR, dcr);
> +	ADD(alias, "manuf", match_flags & I3C_MATCH_MANUF, dcr);

							    ^manuf_id

> +	ADD(alias, "part", match_flags & I3C_MATCH_PART, dcr);

							  ^part_id

> +	ADD(alias, "ext", match_flags & I3C_MATCH_EXTRA_INFO, dcr);

								^extra_info


_______________________________________________
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] i3c: Address i3c_device_id related issues
  2020-02-22 10:27 [PATCH 0/3] i3c: Address i3c_device_id related issues Boris Brezillon
                   ` (2 preceding siblings ...)
  2020-02-22 10:27 ` [PATCH 3/3] i3c: Simplify i3c_device_match_id() Boris Brezillon
@ 2020-02-26 17:37 ` Boris Brezillon
  3 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2020-02-26 17:37 UTC (permalink / raw)
  To: Boris Brezillon, Przemysław Gaj, Vitor Soares, linux-i3c
  Cc: linux-kernel

On Sat, 22 Feb 2020 11:27:08 +0100
Boris Brezillon <boris.brezillon@collabora.com> wrote:

> Hello,
> 
> When the I3C subsystem was introduced part of the modalias generation
> logic was missing (modalias generation based on i3c_device_id tables).
> This patch series addresses that limitation and simplifies our match
> function along the way.
> 
> Regards,
> 
> Boris
> 
> Boris Brezillon (3):
>   i3c: Fix MODALIAS uevents

We also lack a modalias sysfs attribute.

>   i3c: Generate aliases for i3c modules
>   i3c: Simplify i3c_device_match_id()
> 
>  drivers/i3c/device.c              | 50 ++++++++++++++-----------------
>  drivers/i3c/master.c              |  2 +-
>  scripts/mod/devicetable-offsets.c |  7 +++++
>  scripts/mod/file2alias.c          | 19 ++++++++++++
>  4 files changed, 49 insertions(+), 29 deletions(-)
> 


_______________________________________________
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 3/3] i3c: Simplify i3c_device_match_id() Boris Brezillon
2020-02-26 17:37 ` [PATCH 0/3] i3c: Address i3c_device_id related issues Boris Brezillon

Linux-i3c Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-i3c/0 linux-i3c/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-i3c linux-i3c/ https://lore.kernel.org/linux-i3c \
		linux-i3c@lists.infradead.org
	public-inbox-index linux-i3c

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-i3c


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git