[U-Boot] [PATCH v3 03/17] dm: core: lists.c: add new function lists_bind_fdt_by_prop()

Przemyslaw Marczak p.marczak at samsung.com
Tue Mar 24 21:30:37 CET 2015


This change adds new function: lists_bind_fdt_by_prop(), which can be used
for bind the devices by custom property name for the compatible string.

The function lists_bind_fdt() works the same as previous.

Signed-off-by: Przemyslaw Marczak <p.marczak at samsung.com>
---
 drivers/core/lists.c | 28 +++++++++++++++++++---------
 include/dm/lists.h   | 18 ++++++++++++++++++
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index ff115c4..d96040a 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -99,14 +99,17 @@ int device_bind_driver(struct udevice *parent, const char *drv_name,
  * @param blob:		Device tree pointer
  * @param offset:	Offset of node in device tree
  * @param of_match:	List of compatible strings to match
+ * @param prop:		Name of compatible string property
  * @param of_idp:	Returns the match that was found
  * @return 0 if there is a match, -ENOENT if no match, -ENODEV if the node
  * does not have a compatible string, other error <0 if there is a device
  * tree error
  */
-static int driver_check_compatible(const void *blob, int offset,
-				   const struct udevice_id *of_match,
-				   const struct udevice_id **of_idp)
+static int driver_check_prop_compatible(const void *blob,
+					int offset,
+					const char *prop,
+					const struct udevice_id *of_match,
+					const struct udevice_id **of_idp)
 {
 	int ret;
 
@@ -115,8 +118,8 @@ static int driver_check_compatible(const void *blob, int offset,
 		return -ENOENT;
 
 	while (of_match->compatible) {
-		ret = fdt_node_check_compatible(blob, offset,
-						of_match->compatible);
+		ret = fdt_node_check_prop_compatible(blob, offset, prop,
+						     of_match->compatible);
 		if (!ret) {
 			*of_idp = of_match;
 			return 0;
@@ -131,8 +134,8 @@ static int driver_check_compatible(const void *blob, int offset,
 	return -ENOENT;
 }
 
-int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
-		   struct udevice **devp)
+int lists_bind_fdt_by_prop(struct udevice *parent, const void *blob, int offset,
+			   const char *prop, struct udevice **devp)
 {
 	struct driver *driver = ll_entry_start(struct driver, driver);
 	const int n_ents = ll_entry_count(struct driver, driver);
@@ -148,8 +151,8 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
 	if (devp)
 		*devp = NULL;
 	for (entry = driver; entry != driver + n_ents; entry++) {
-		ret = driver_check_compatible(blob, offset, entry->of_match,
-					      &id);
+		ret = driver_check_prop_compatible(blob, offset, prop,
+						   entry->of_match, &id);
 		name = fdt_get_name(blob, offset, NULL);
 		if (ret == -ENOENT) {
 			continue;
@@ -183,4 +186,11 @@ int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
 
 	return result;
 }
+
+int lists_bind_fdt(struct udevice *parent, const void *blob, int offset,
+		   struct udevice **devp)
+{
+	return lists_bind_fdt_by_prop(parent, blob, offset, "compatible", devp);
+
+}
 #endif
diff --git a/include/dm/lists.h b/include/dm/lists.h
index 1b50af9..c63757b 100644
--- a/include/dm/lists.h
+++ b/include/dm/lists.h
@@ -45,6 +45,24 @@ struct uclass_driver *lists_uclass_lookup(enum uclass_id id);
 int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only);
 
 /**
+ * lists_bind_fdt_by_prop() - bind a device tree node by the given compatible
+ * property name.
+ *
+ * This creates a new device bound to the given device tree node, with
+ * @parent as its parent.
+ *
+ * @parent: parent device (root)
+ * @blob: device tree blob
+ * @offset: offset of this device tree node
+ * @prop: fdt property name within looking for the driver compatible string
+ * @devp: if non-NULL, returns a pointer to the bound device
+ * @return 0 if device was bound, -EINVAL if the device tree is invalid,
+ * other -ve value on error
+ */
+int lists_bind_fdt_by_prop(struct udevice *parent, const void *blob, int offset,
+			   const char *prop, struct udevice **devp);
+
+/**
  * lists_bind_fdt() - bind a device tree node
  *
  * This creates a new device bound to the given device tree node, with
-- 
1.9.1



More information about the U-Boot mailing list