Skip to contentSkip to conversation

rpmsg: Make modalias work for DeviceTree based devices

PATCH In review Bjorn Andersson 2 participants 2 messages Jun 28, 2017 – Jun 29, 2017 Remote processor messaging (rpmsg)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rpmsg: Make modalias work for DeviceTree based devices

When rpmsg devices are expected to be matched based on their compatible the modalias should reflect this, so that module autoloading has a chance to match and load the appropriate module.

---

Changes since v1:
- Also update rpmsg_uevent()

 drivers/rpmsg/rpmsg_core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/rpmsg/rpmsg_core.c +10 -0
index ad3d2a9df287..067650c5bcb6 100644
@@ -343,6 +343,11 @@ static ssize_t modalias_show(struct device *dev,
 			     struct device_attribute *attr, char *buf)
 {
 	struct rpmsg_device *rpdev = to_rpmsg_device(dev);
+	ssize_t len;
+
+	len = of_device_modalias(dev, buf, PAGE_SIZE);
+	if (len != -ENODEV)
+		return len;
 
 	return sprintf(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name);
 }
@@ -387,6 +392,11 @@ static int rpmsg_dev_match(struct device *dev, struct device_driver *drv)
 static int rpmsg_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
 	struct rpmsg_device *rpdev = to_rpmsg_device(dev);
+	int ret;
+
+	ret = of_device_uevent_modalias(dev, env);
+	if (ret != -ENODEV)
+		return ret;
 
 	return add_uevent_var(env, "MODALIAS=" RPMSG_DEVICE_MODALIAS_FMT,
 					rpdev->id.name);
Signature · 1 line
2.12.0
#1 lore raw
Quoted 7 lines · Bjorn Andersson

When rpmsg devices are expected to be matched based on their compatible the modalias should reflect this, so that module autoloading has a chance to match and load the appropriate module.

and also probably:

Quoted 39 lines

---

Changes since v1:
- Also update rpmsg_uevent()

 drivers/rpmsg/rpmsg_core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/rpmsg/rpmsg_core.c +10 -1
index ad3d2a9df287..067650c5bcb6 100644
@@ -343,6 +343,11 @@ static ssize_t modalias_show(struct device *dev,
                             struct device_attribute *attr, char *buf)
 {
        struct rpmsg_device *rpdev = to_rpmsg_device(dev);
+       ssize_t len;
+
+       len = of_device_modalias(dev, buf, PAGE_SIZE);
+       if (len != -ENODEV)
+               return len;
 
        return sprintf(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name);
 }
@@ -387,6 +392,11 @@ static int rpmsg_dev_match(struct device *dev, struct device_driver *drv)
 static int rpmsg_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
        struct rpmsg_device *rpdev = to_rpmsg_device(dev);
+       int ret;
+
+       ret = of_device_uevent_modalias(dev, env);
+       if (ret != -ENODEV)
+               return ret;
 
        return add_uevent_var(env, "MODALIAS=" RPMSG_DEVICE_MODALIAS_FMT,
                                        rpdev->id.name);
--

2.12.0