core: fdtaddr: add devfdt_get_addr_size_index_ptr function
authorJohan Jonker <jbx6244@gmail.com>
Fri, 21 Apr 2023 15:33:58 +0000 (17:33 +0200)
committerKever Yang <kever.yang@rock-chips.com>
Sat, 6 May 2023 09:28:18 +0000 (17:28 +0800)
Add devfdt_get_addr_size_index_ptr function with the same
functionality as devfdt_get_addr_size_index, but instead
a return pointer is given.

Suggested-by: Michael Nazzareno Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/core/fdtaddr.c
include/dm/fdtaddr.h

index b9b0c28..3b59b70 100644 (file)
@@ -126,6 +126,14 @@ fdt_addr_t devfdt_get_addr_size_index(const struct udevice *dev, int index,
 #endif
 }
 
 #endif
 }
 
+void *devfdt_get_addr_size_index_ptr(const struct udevice *dev, int index,
+                                    fdt_size_t *size)
+{
+       fdt_addr_t addr = devfdt_get_addr_size_index(dev, index, size);
+
+       return (addr == FDT_ADDR_T_NONE) ? NULL : (void *)(uintptr_t)addr;
+}
+
 fdt_addr_t devfdt_get_addr_name(const struct udevice *dev, const char *name)
 {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 fdt_addr_t devfdt_get_addr_name(const struct udevice *dev, const char *name)
 {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
index c9d2b27..dcdc191 100644 (file)
@@ -111,7 +111,7 @@ void *devfdt_get_addr_index_ptr(const struct udevice *dev, int index);
  * @dev: Pointer to a device
  * @index: the 'reg' property can hold a list of <addr, size> pairs
  *        and @index is used to select which one is required
  * @dev: Pointer to a device
  * @index: the 'reg' property can hold a list of <addr, size> pairs
  *        and @index is used to select which one is required
- * @size: Pointer to size varible - this function returns the size
+ * @size: Pointer to size variable - this function returns the size
  *        specified in the 'reg' property here
  *
  * Return: addr
  *        specified in the 'reg' property here
  *
  * Return: addr
@@ -120,6 +120,21 @@ fdt_addr_t devfdt_get_addr_size_index(const struct udevice *dev, int index,
                                      fdt_size_t *size);
 
 /**
                                      fdt_size_t *size);
 
 /**
+ * devfdt_get_addr_size_index_ptr() - Return indexed pointer to the address of the
+ *                                    reg property of a device
+ *
+ * @dev: Pointer to a device
+ * @index: the 'reg' property can hold a list of <addr, size> pairs
+ *        and @index is used to select which one is required
+ * @size: Pointer to size variable - this function returns the size
+ *        specified in the 'reg' property here
+ *
+ * Return: Pointer to addr, or NULL if there is no such property
+ */
+void *devfdt_get_addr_size_index_ptr(const struct udevice *dev, int index,
+                                    fdt_size_t *size);
+
+/**
  * devfdt_get_addr_name() - Get the reg property of a device, indexed by name
  *
  * @dev: Pointer to a device
  * devfdt_get_addr_name() - Get the reg property of a device, indexed by name
  *
  * @dev: Pointer to a device