diff options
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/device.c | 36 | ||||
-rw-r--r-- | drivers/of/platform.c | 3 |
2 files changed, 23 insertions, 16 deletions
diff --git a/drivers/of/device.c b/drivers/of/device.c index 29681c4b700b..8fbfeee53c1e 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c | |||
@@ -48,16 +48,32 @@ void of_dev_put(struct of_device *dev) | |||
48 | } | 48 | } |
49 | EXPORT_SYMBOL(of_dev_put); | 49 | EXPORT_SYMBOL(of_dev_put); |
50 | 50 | ||
51 | static ssize_t dev_show_devspec(struct device *dev, | 51 | static ssize_t devspec_show(struct device *dev, |
52 | struct device_attribute *attr, char *buf) | 52 | struct device_attribute *attr, char *buf) |
53 | { | 53 | { |
54 | struct of_device *ofdev; | 54 | struct of_device *ofdev; |
55 | 55 | ||
56 | ofdev = to_of_device(dev); | 56 | ofdev = to_of_device(dev); |
57 | return sprintf(buf, "%s", ofdev->node->full_name); | 57 | return sprintf(buf, "%s\n", ofdev->node->full_name); |
58 | } | 58 | } |
59 | 59 | ||
60 | static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); | 60 | static ssize_t modalias_show(struct device *dev, |
61 | struct device_attribute *attr, char *buf) | ||
62 | { | ||
63 | struct of_device *ofdev = to_of_device(dev); | ||
64 | ssize_t len = 0; | ||
65 | |||
66 | len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); | ||
67 | buf[len] = '\n'; | ||
68 | buf[len+1] = 0; | ||
69 | return len+1; | ||
70 | } | ||
71 | |||
72 | struct device_attribute of_platform_device_attrs[] = { | ||
73 | __ATTR_RO(devspec), | ||
74 | __ATTR_RO(modalias), | ||
75 | __ATTR_NULL | ||
76 | }; | ||
61 | 77 | ||
62 | /** | 78 | /** |
63 | * of_release_dev - free an of device structure when all users of it are finished. | 79 | * of_release_dev - free an of device structure when all users of it are finished. |
@@ -78,25 +94,13 @@ EXPORT_SYMBOL(of_release_dev); | |||
78 | 94 | ||
79 | int of_device_register(struct of_device *ofdev) | 95 | int of_device_register(struct of_device *ofdev) |
80 | { | 96 | { |
81 | int rc; | ||
82 | |||
83 | BUG_ON(ofdev->node == NULL); | 97 | BUG_ON(ofdev->node == NULL); |
84 | 98 | return device_register(&ofdev->dev); | |
85 | rc = device_register(&ofdev->dev); | ||
86 | if (rc) | ||
87 | return rc; | ||
88 | |||
89 | rc = device_create_file(&ofdev->dev, &dev_attr_devspec); | ||
90 | if (rc) | ||
91 | device_unregister(&ofdev->dev); | ||
92 | |||
93 | return rc; | ||
94 | } | 99 | } |
95 | EXPORT_SYMBOL(of_device_register); | 100 | EXPORT_SYMBOL(of_device_register); |
96 | 101 | ||
97 | void of_device_unregister(struct of_device *ofdev) | 102 | void of_device_unregister(struct of_device *ofdev) |
98 | { | 103 | { |
99 | device_remove_file(&ofdev->dev, &dev_attr_devspec); | ||
100 | device_unregister(&ofdev->dev); | 104 | device_unregister(&ofdev->dev); |
101 | } | 105 | } |
102 | EXPORT_SYMBOL(of_device_unregister); | 106 | EXPORT_SYMBOL(of_device_unregister); |
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index ca09a63a64db..298de0f95d70 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/of_device.h> | 17 | #include <linux/of_device.h> |
18 | #include <linux/of_platform.h> | 18 | #include <linux/of_platform.h> |
19 | 19 | ||
20 | extern struct device_attribute of_platform_device_attrs[]; | ||
21 | |||
20 | static int of_platform_bus_match(struct device *dev, struct device_driver *drv) | 22 | static int of_platform_bus_match(struct device *dev, struct device_driver *drv) |
21 | { | 23 | { |
22 | struct of_device *of_dev = to_of_device(dev); | 24 | struct of_device *of_dev = to_of_device(dev); |
@@ -103,6 +105,7 @@ int of_bus_type_init(struct bus_type *bus, const char *name) | |||
103 | bus->suspend = of_platform_device_suspend; | 105 | bus->suspend = of_platform_device_suspend; |
104 | bus->resume = of_platform_device_resume; | 106 | bus->resume = of_platform_device_resume; |
105 | bus->shutdown = of_platform_device_shutdown; | 107 | bus->shutdown = of_platform_device_shutdown; |
108 | bus->dev_attrs = of_platform_device_attrs; | ||
106 | return bus_register(bus); | 109 | return bus_register(bus); |
107 | } | 110 | } |
108 | 111 | ||