Skip to contentSkip to conversation

rpmsg: add match optional callback to rpmsg_driver

PATCH New Xiang Xiao 1 participant 1 message Feb 1, 2019 Remote processor messaging (rpmsg)

lore
Share & tools
lore

Xiang Xiao

author
#0 lore raw

PATCH 1/1 rpmsg: add match optional callback to rpmsg_driver

so the driver could decide whether support a particular device at runtime

---
 drivers/rpmsg/rpmsg_core.c | 3 +++
 include/linux/rpmsg.h      | 1 +
 2 files changed, 4 insertions(+)
drivers/rpmsg/rpmsg_core.c +3 -0
index ea88fd4..afdd1c6 100644
@@ -413,6 +413,9 @@ static int rpmsg_dev_match(struct device *dev, struct device_driver *drv)
 	if (rpdev->driver_override)
 		return !strcmp(rpdev->driver_override, drv->name);
 
+	if (rpdrv->match)
+		return rpdrv->match(rpdev, rpdrv);
+
 	if (ids)
 		for (i = 0; ids[i].name[0]; i++)
 			if (rpmsg_id_match(rpdev, &ids[i]))
include/linux/rpmsg.h +1 -0
index 9fe156d..7a5a342 100644
@@ -109,6 +109,7 @@ struct rpmsg_driver {
 	int (*probe)(struct rpmsg_device *dev);
 	void (*remove)(struct rpmsg_device *dev);
 	int (*callback)(struct rpmsg_device *, void *, int, void *, u32);
+	int (*match)(struct rpmsg_device *dev, struct rpmsg_driver *drv);
 };
 
 #if IS_ENABLED(CONFIG_RPMSG)
Signature · 1 line
2.7.4