[U-Boot] [PATCH v2 3/7] dm: core: Introduce dev_read_alias_highest_id()

Michal Simek michal.simek at xilinx.com
Thu Jan 31 15:30:59 UTC 2019


It is wrapper for calling of_alias_get_highest_id() when live tree is
enabled and fdtdec_get_alias_highest_id() if not.

Signed-off-by: Michal Simek <michal.simek at xilinx.com>
---

Changes in v2:
- New patch

 drivers/core/read.c |  8 ++++++++
 include/dm/read.h   | 16 ++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/core/read.c b/drivers/core/read.c
index 3c46b3674ed6..6bda077a34b9 100644
--- a/drivers/core/read.c
+++ b/drivers/core/read.c
@@ -264,3 +264,11 @@ u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr)
 {
 	return ofnode_translate_address(dev_ofnode(dev), in_addr);
 }
+
+int dev_read_alias_highest_id(const char *stem)
+{
+	if (of_live_active())
+		return of_alias_get_highest_id(stem);
+
+	return fdtdec_get_alias_highest_id(gd->fdt_blob, stem);
+}
diff --git a/include/dm/read.h b/include/dm/read.h
index 389e30e7fb44..60b727cbd821 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -510,6 +510,17 @@ int dev_read_resource_byname(struct udevice *dev, const char *name,
  * @return the translated address; OF_BAD_ADDR on error
  */
 u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr);
+
+/**
+ * dev_read_alias_highest_id - Get highest alias id for the given stem
+ * @stem:	Alias stem to be examined
+ *
+ * The function travels the lookup table to get the highest alias id for the
+ * given alias stem.
+ * @return alias ID, if found, else -1
+ */
+int dev_read_alias_highest_id(const char *stem);
+
 #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
 
 static inline int dev_read_u32(struct udevice *dev,
@@ -740,6 +751,11 @@ static inline u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_a
 	return ofnode_translate_address(dev_ofnode(dev), in_addr);
 }
 
+static inline int dev_read_alias_highest_id(const char *stem)
+{
+	return fdtdec_get_alias_highest_id(gd->fdt_blob, stem);
+}
+
 #endif /* CONFIG_DM_DEV_READ_INLINE */
 
 /**
-- 
1.9.1



More information about the U-Boot mailing list