Commit b9f73067f32531db608e469a9ad20ce631e34550

Authored by Zhang Rui
Committed by Rafael J. Wysocki
1 parent 8c4ff6d009

platform: introduce OF style 'modalias' support for platform bus

Fix a problem that, the platform bus supports the OF style modalias
in .uevent() call, but not in its device 'modalias' sysfs attribute.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Showing 3 changed files with 13 additions and 0 deletions Side-by-side Diff

drivers/base/platform.c
... ... @@ -679,6 +679,10 @@
679 679 struct platform_device *pdev = to_platform_device(dev);
680 680 int len;
681 681  
  682 + len = of_device_get_modalias(dev, buf, PAGE_SIZE -1);
  683 + if (len != -ENODEV)
  684 + return len;
  685 +
682 686 len = acpi_device_modalias(dev, buf, PAGE_SIZE -1);
683 687 if (len != -ENODEV)
684 688 return len;
... ... @@ -85,6 +85,9 @@
85 85 int cplen, i;
86 86 ssize_t tsize, csize, repend;
87 87  
  88 + if ((!dev) || (!dev->of_node))
  89 + return -ENODEV;
  90 +
88 91 /* Name & Type */
89 92 csize = snprintf(str, len, "of:N%sT%s", dev->of_node->name,
90 93 dev->of_node->type);
include/linux/of_device.h
... ... @@ -64,6 +64,12 @@
64 64 static inline void of_device_uevent(struct device *dev,
65 65 struct kobj_uevent_env *env) { }
66 66  
  67 +static inline int of_device_get_modalias(struct device *dev,
  68 + char *str, ssize_t len)
  69 +{
  70 + return -ENODEV;
  71 +}
  72 +
67 73 static inline int of_device_uevent_modalias(struct device *dev,
68 74 struct kobj_uevent_env *env)
69 75 {