diff options
Diffstat (limited to 'drivers/of/device.c')
-rw-r--r-- | drivers/of/device.c | 61 |
1 files changed, 7 insertions, 54 deletions
diff --git a/drivers/of/device.c b/drivers/of/device.c index 92de0eb74aea..62b4b32ac887 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c | |||
@@ -47,63 +47,10 @@ void of_dev_put(struct platform_device *dev) | |||
47 | } | 47 | } |
48 | EXPORT_SYMBOL(of_dev_put); | 48 | EXPORT_SYMBOL(of_dev_put); |
49 | 49 | ||
50 | static ssize_t devspec_show(struct device *dev, | 50 | int of_device_add(struct platform_device *ofdev) |
51 | struct device_attribute *attr, char *buf) | ||
52 | { | ||
53 | struct platform_device *ofdev; | ||
54 | |||
55 | ofdev = to_platform_device(dev); | ||
56 | return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name); | ||
57 | } | ||
58 | |||
59 | static ssize_t name_show(struct device *dev, | ||
60 | struct device_attribute *attr, char *buf) | ||
61 | { | ||
62 | struct platform_device *ofdev; | ||
63 | |||
64 | ofdev = to_platform_device(dev); | ||
65 | return sprintf(buf, "%s\n", ofdev->dev.of_node->name); | ||
66 | } | ||
67 | |||
68 | static ssize_t modalias_show(struct device *dev, | ||
69 | struct device_attribute *attr, char *buf) | ||
70 | { | ||
71 | ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2); | ||
72 | buf[len] = '\n'; | ||
73 | buf[len+1] = 0; | ||
74 | return len+1; | ||
75 | } | ||
76 | |||
77 | struct device_attribute of_platform_device_attrs[] = { | ||
78 | __ATTR_RO(devspec), | ||
79 | __ATTR_RO(name), | ||
80 | __ATTR_RO(modalias), | ||
81 | __ATTR_NULL | ||
82 | }; | ||
83 | |||
84 | /** | ||
85 | * of_release_dev - free an of device structure when all users of it are finished. | ||
86 | * @dev: device that's been disconnected | ||
87 | * | ||
88 | * Will be called only by the device core when all users of this of device are | ||
89 | * done. | ||
90 | */ | ||
91 | void of_release_dev(struct device *dev) | ||
92 | { | ||
93 | struct platform_device *ofdev; | ||
94 | |||
95 | ofdev = to_platform_device(dev); | ||
96 | of_node_put(ofdev->dev.of_node); | ||
97 | kfree(ofdev); | ||
98 | } | ||
99 | EXPORT_SYMBOL(of_release_dev); | ||
100 | |||
101 | int of_device_register(struct platform_device *ofdev) | ||
102 | { | 51 | { |
103 | BUG_ON(ofdev->dev.of_node == NULL); | 52 | BUG_ON(ofdev->dev.of_node == NULL); |
104 | 53 | ||
105 | device_initialize(&ofdev->dev); | ||
106 | |||
107 | /* name and id have to be set so that the platform bus doesn't get | 54 | /* name and id have to be set so that the platform bus doesn't get |
108 | * confused on matching */ | 55 | * confused on matching */ |
109 | ofdev->name = dev_name(&ofdev->dev); | 56 | ofdev->name = dev_name(&ofdev->dev); |
@@ -117,6 +64,12 @@ int of_device_register(struct platform_device *ofdev) | |||
117 | 64 | ||
118 | return device_add(&ofdev->dev); | 65 | return device_add(&ofdev->dev); |
119 | } | 66 | } |
67 | |||
68 | int of_device_register(struct platform_device *pdev) | ||
69 | { | ||
70 | device_initialize(&pdev->dev); | ||
71 | return of_device_add(pdev); | ||
72 | } | ||
120 | EXPORT_SYMBOL(of_device_register); | 73 | EXPORT_SYMBOL(of_device_register); |
121 | 74 | ||
122 | void of_device_unregister(struct platform_device *ofdev) | 75 | void of_device_unregister(struct platform_device *ofdev) |