aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of/device.c')
-rw-r--r--drivers/of/device.c36
1 files changed, 20 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}
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);