aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlaf Hering <olaf@aepfle.de>2008-04-24 09:16:00 -0400
committerPaul Mackerras <paulus@samba.org>2008-05-14 08:31:28 -0400
commit140b932f8cb6cced10b96860651a198b1b89cbb9 (patch)
treeb515aa9982f7eaffd43b994497bff925b2a8b96b
parent9d5f525b86453da921360727112161254accc8c1 (diff)
[POWERPC] Create modalias file in sysfs for of_platform bus
Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading of modules. Modalias files are already present for many other bus types. This adds also a newline to the devspec files. Also create a devspec file for mac-io devices. They were created as a side effect. Use correct buffer size for mac-io modalias buffer. Tested on iBook1 and Efika. Signed-off-by: Olaf Hering <olaf@aepfle.de> Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r--drivers/macintosh/macio_sysfs.c12
-rw-r--r--drivers/of/device.c36
-rw-r--r--drivers/of/platform.c3
3 files changed, 34 insertions, 17 deletions
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c
index 112e5ef728f1..9e9453b58425 100644
--- a/drivers/macintosh/macio_sysfs.c
+++ b/drivers/macintosh/macio_sysfs.c
@@ -44,7 +44,7 @@ static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
44 struct of_device *ofdev = to_of_device(dev); 44 struct of_device *ofdev = to_of_device(dev);
45 int len; 45 int len;
46 46
47 len = of_device_get_modalias(ofdev, buf, PAGE_SIZE); 47 len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2);
48 48
49 buf[len] = '\n'; 49 buf[len] = '\n';
50 buf[len+1] = 0; 50 buf[len+1] = 0;
@@ -52,6 +52,15 @@ static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
52 return len+1; 52 return len+1;
53} 53}
54 54
55static ssize_t devspec_show(struct device *dev,
56 struct device_attribute *attr, char *buf)
57{
58 struct of_device *ofdev;
59
60 ofdev = to_of_device(dev);
61 return sprintf(buf, "%s\n", ofdev->node->full_name);
62}
63
55macio_config_of_attr (name, "%s\n"); 64macio_config_of_attr (name, "%s\n");
56macio_config_of_attr (type, "%s\n"); 65macio_config_of_attr (type, "%s\n");
57 66
@@ -60,5 +69,6 @@ struct device_attribute macio_dev_attrs[] = {
60 __ATTR_RO(type), 69 __ATTR_RO(type),
61 __ATTR_RO(compatible), 70 __ATTR_RO(compatible),
62 __ATTR_RO(modalias), 71 __ATTR_RO(modalias),
72 __ATTR_RO(devspec),
63 __ATTR_NULL 73 __ATTR_NULL
64}; 74};
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}
49EXPORT_SYMBOL(of_dev_put); 49EXPORT_SYMBOL(of_dev_put);
50 50
51static ssize_t dev_show_devspec(struct device *dev, 51static 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
60static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL); 60static 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
72struct 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
79int of_device_register(struct of_device *ofdev) 95int 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}
95EXPORT_SYMBOL(of_device_register); 100EXPORT_SYMBOL(of_device_register);
96 101
97void of_device_unregister(struct of_device *ofdev) 102void 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}
102EXPORT_SYMBOL(of_device_unregister); 106EXPORT_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
20extern struct device_attribute of_platform_device_attrs[];
21
20static int of_platform_bus_match(struct device *dev, struct device_driver *drv) 22static 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