summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/of/base.c15
-rw-r--r--include/linux/of.h8
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 57420806c1a2..b70aec32e0e3 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -435,6 +435,21 @@ bool of_machine_compatible_match(const char *const *compats)
EXPORT_SYMBOL(of_machine_compatible_match);
/**
+ * of_machine_read_compatible - Get the compatible string of this machine
+ * @compatible: address at which the address of the compatible string will be
+ * stored
+ * @index: index of the compatible entry in the list
+ *
+ * Returns:
+ * 0 on success, negative error number on failure.
+ */
+int of_machine_read_compatible(const char **compatible, unsigned int index)
+{
+ return of_property_read_string_index(of_root, "compatible", index, compatible);
+}
+EXPORT_SYMBOL_GPL(of_machine_read_compatible);
+
+/**
* of_machine_device_match - Test root of device tree against a of_device_id array
* @matches: NULL terminated array of of_device_id match structures to search in
*
diff --git a/include/linux/of.h b/include/linux/of.h
index be6ec4916adf..7df971d52b55 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -426,6 +426,8 @@ static inline bool of_machine_is_compatible(const char *compat)
return of_machine_compatible_match(compats);
}
+int of_machine_read_compatible(const char **compatible, unsigned int index);
+
extern int of_add_property(struct device_node *np, struct property *prop);
extern int of_remove_property(struct device_node *np, struct property *prop);
extern int of_update_property(struct device_node *np, struct property *newprop);
@@ -851,6 +853,12 @@ static inline int of_machine_is_compatible(const char *compat)
return 0;
}
+static inline int of_machine_read_compatible(const char **compatible,
+ unsigned int index)
+{
+ return -ENOSYS;
+}
+
static inline int of_add_property(struct device_node *np, struct property *prop)
{
return 0;