summaryrefslogtreecommitdiff
path: root/drivers/of/base.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2010-01-28 13:47:25 -0700
committerGrant Likely <grant.likely@secretlab.ca>2010-01-28 13:47:25 -0700
commit1f43cfb9474d1c4f22598b6e3213ec035be6dd56 (patch)
tree71b769e38856b591ec68d9bb593766bdc679c0c9 /drivers/of/base.c
parent86e032213424958b45564d0cc96b3316641a49d3 (diff)
of: merge machine_is_compatible()
Merge common code between PowerPC and Microblaze Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Tested-by: Wolfram Sang <w.sang@pengutronix.de> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r--drivers/of/base.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ec56739eb247..dba995b70b84 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -144,6 +144,27 @@ int of_device_is_compatible(const struct device_node *device,
EXPORT_SYMBOL(of_device_is_compatible);
/**
+ * machine_is_compatible - Test root of device tree for a given compatible value
+ * @compat: compatible string to look for in root node's compatible property.
+ *
+ * Returns true if the root node has the given value in its
+ * compatible property.
+ */
+int machine_is_compatible(const char *compat)
+{
+ struct device_node *root;
+ int rc = 0;
+
+ root = of_find_node_by_path("/");
+ if (root) {
+ rc = of_device_is_compatible(root, compat);
+ of_node_put(root);
+ }
+ return rc;
+}
+EXPORT_SYMBOL(machine_is_compatible);
+
+/**
* of_device_is_available - check if a device is available for use
*
* @device: Node to check for availability