These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / of / device.c
index 20c1332..e5f47ce 100644 (file)
@@ -60,11 +60,12 @@ int of_device_add(struct platform_device *ofdev)
        ofdev->name = dev_name(&ofdev->dev);
        ofdev->id = -1;
 
-       /* 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->dev.of_node));
+       /*
+        * If this device has not binding numa node in devicetree, that is
+        * of_node_to_nid returns NUMA_NO_NODE. device_add will assume that this
+        * device is on the same node as the parent.
+        */
+       set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->dev.of_node));
 
        return device_add(&ofdev->dev);
 }
@@ -163,6 +164,18 @@ void of_device_unregister(struct platform_device *ofdev)
 }
 EXPORT_SYMBOL(of_device_unregister);
 
+const void *of_device_get_match_data(const struct device *dev)
+{
+       const struct of_device_id *match;
+
+       match = of_match_device(dev->driver->of_match_table, dev);
+       if (!match)
+               return NULL;
+
+       return match->data;
+}
+EXPORT_SYMBOL(of_device_get_match_data);
+
 ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len)
 {
        const char *compat;