]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/of/device.c
OF-device: Don't overwrite numa_node in device registration
[linux-2.6-omap-h63xx.git] / drivers / of / device.c
index 8a1d93a2bb815c380bb18710369912834c2d2f06..224ae6bc67b6bb7b5b893192b7170cc6be8ef29c 100644 (file)
@@ -57,6 +57,15 @@ static ssize_t devspec_show(struct device *dev,
        return sprintf(buf, "%s\n", ofdev->node->full_name);
 }
 
+static ssize_t name_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
+{
+       struct of_device *ofdev;
+
+       ofdev = to_of_device(dev);
+       return sprintf(buf, "%s\n", ofdev->node->name);
+}
+
 static ssize_t modalias_show(struct device *dev,
                                struct device_attribute *attr, char *buf)
 {
@@ -71,6 +80,7 @@ static ssize_t modalias_show(struct device *dev,
 
 struct device_attribute of_platform_device_attrs[] = {
        __ATTR_RO(devspec),
+       __ATTR_RO(name),
        __ATTR_RO(modalias),
        __ATTR_NULL
 };
@@ -95,7 +105,16 @@ EXPORT_SYMBOL(of_release_dev);
 int of_device_register(struct of_device *ofdev)
 {
        BUG_ON(ofdev->node == NULL);
-       return device_register(&ofdev->dev);
+
+       device_initialize(&ofdev->dev);
+
+       /* device_add will assume that this device is on the same node as
+        * the parent. If there is no parent defined, set the node
+        * explicitly */
+       if (!ofdev->dev.parent)
+               set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->node));
+
+       return device_add(&ofdev->dev);
 }
 EXPORT_SYMBOL(of_device_register);