linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] rpmsg: core: Add wildcard match for name service
@ 2020-03-10 15:50 Mathieu Poirier
  2020-03-26 15:06 ` Suman Anna
  0 siblings, 1 reply; 11+ messages in thread
From: Mathieu Poirier @ 2020-03-10 15:50 UTC (permalink / raw)
  To: ohad, bjorn.andersson; +Cc: linux-remoteproc, linux-kernel

Adding the capability to supplement the base definition published
by an rpmsg_driver with a postfix description so that it is possible
for several entity to use the same service.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
index e330ec4dfc33..bfd25978fa35 100644
--- a/drivers/rpmsg/rpmsg_core.c
+++ b/drivers/rpmsg/rpmsg_core.c
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
 				  const struct rpmsg_device_id *id)
 {
-	return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+	size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+	/*
+	 * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+	 * is:
+	 *
+	 * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+	 *      { .name = "rpmsg-client-sample" },
+	 *      { },
+	 * }
+	 *
+	 * Then it is possible to support "rpmsg-client-sample*", i.e:
+	 *	rpmsg-client-sample
+	 *	rpmsg-client-sample_instance0
+	 *	rpmsg-client-sample_instance1
+	 *	...
+	 *	rpmsg-client-sample_instanceX
+	 */
+	return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */
-- 
2.20.1


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

end of thread, other threads:[~2020-04-09  8:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 15:50 [PATCH v2] rpmsg: core: Add wildcard match for name service Mathieu Poirier
2020-03-26 15:06 ` Suman Anna
2020-03-26 20:21   ` Mathieu Poirier
2020-03-26 20:42     ` Suman Anna
2020-03-26 22:01       ` Mathieu Poirier
2020-03-27  9:35         ` Arnaud POULIQUEN
2020-03-27 19:36           ` Mathieu Poirier
2020-04-07 23:07             ` Suman Anna
2020-04-08 15:59               ` Mathieu Poirier
2020-04-08 20:52                 ` Suman Anna
2020-04-09  8:54                   ` Arnaud POULIQUEN

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).