Commit cd1e6504 authored by Grant Likely's avatar Grant Likely

of/device: Don't register disabled devices

Device nodes with the property status="disabled" are not usable and so
don't register them when parsing the device tree for devices.
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Cc: Hollis Blanchard <hollis_blanchard@mentor.com>
Cc: Deepak Saxena <deepak_saxena@mentor.com>
Cc: Scott Wood <scottwood@freescale.com>,
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
parent 6bd121e2
...@@ -633,6 +633,9 @@ EXPORT_SYMBOL(of_device_alloc); ...@@ -633,6 +633,9 @@ EXPORT_SYMBOL(of_device_alloc);
* @np: pointer to node to create device for * @np: pointer to node to create device for
* @bus_id: name to assign device * @bus_id: name to assign device
* @parent: Linux device model parent device. * @parent: Linux device model parent device.
*
* Returns pointer to created platform device, or NULL if a device was not
* registered. Unavailable devices will not get registered.
*/ */
struct platform_device *of_platform_device_create(struct device_node *np, struct platform_device *of_platform_device_create(struct device_node *np,
const char *bus_id, const char *bus_id,
...@@ -640,6 +643,9 @@ struct platform_device *of_platform_device_create(struct device_node *np, ...@@ -640,6 +643,9 @@ struct platform_device *of_platform_device_create(struct device_node *np,
{ {
struct platform_device *dev; struct platform_device *dev;
if (!of_device_is_available(np))
return NULL;
dev = of_device_alloc(np, bus_id, parent); dev = of_device_alloc(np, bus_id, parent);
if (!dev) if (!dev)
return NULL; return NULL;
...@@ -683,8 +689,9 @@ static int of_platform_bus_create(const struct device_node *bus, ...@@ -683,8 +689,9 @@ static int of_platform_bus_create(const struct device_node *bus,
pr_debug(" create child: %s\n", child->full_name); pr_debug(" create child: %s\n", child->full_name);
dev = of_platform_device_create(child, NULL, parent); dev = of_platform_device_create(child, NULL, parent);
if (dev == NULL) if (dev == NULL)
rc = -ENOMEM; continue;
else if (!of_match_node(matches, child))
if (!of_match_node(matches, child))
continue; continue;
if (rc == 0) { if (rc == 0) {
pr_debug(" and sub busses\n"); pr_debug(" and sub busses\n");
...@@ -733,10 +740,9 @@ int of_platform_bus_probe(struct device_node *root, ...@@ -733,10 +740,9 @@ int of_platform_bus_probe(struct device_node *root,
if (of_match_node(matches, root)) { if (of_match_node(matches, root)) {
pr_debug(" root match, create all sub devices\n"); pr_debug(" root match, create all sub devices\n");
dev = of_platform_device_create(root, NULL, parent); dev = of_platform_device_create(root, NULL, parent);
if (dev == NULL) { if (dev == NULL)
rc = -ENOMEM;
goto bail; goto bail;
}
pr_debug(" create all sub busses\n"); pr_debug(" create all sub busses\n");
rc = of_platform_bus_create(root, matches, &dev->dev); rc = of_platform_bus_create(root, matches, &dev->dev);
goto bail; goto bail;
...@@ -748,8 +754,8 @@ int of_platform_bus_probe(struct device_node *root, ...@@ -748,8 +754,8 @@ int of_platform_bus_probe(struct device_node *root,
pr_debug(" match: %s\n", child->full_name); pr_debug(" match: %s\n", child->full_name);
dev = of_platform_device_create(child, NULL, parent); dev = of_platform_device_create(child, NULL, parent);
if (dev == NULL) if (dev == NULL)
rc = -ENOMEM; continue;
else
rc = of_platform_bus_create(child, matches, &dev->dev); rc = of_platform_bus_create(child, matches, &dev->dev);
if (rc) { if (rc) {
of_node_put(child); of_node_put(child);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment