Skip to content
Snippets Groups Projects
Commit c131c8bc authored by Philipp Tomsich's avatar Philipp Tomsich
Browse files

dm: core: add dev_read_addr_ptr()


The dev_read_addr_ptr() mimics the behaviour of the devfdt_get_addr_ptr(),
retrieving the first address of the node's reg-property and returning
it as a pointer (or NULL on failure).

Signed-off-by: default avatarPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: default avatarPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
parent af823151
No related branches found
No related tags found
No related merge requests found
...@@ -57,6 +57,13 @@ fdt_addr_t dev_read_addr(struct udevice *dev) ...@@ -57,6 +57,13 @@ fdt_addr_t dev_read_addr(struct udevice *dev)
return dev_read_addr_index(dev, 0); return dev_read_addr_index(dev, 0);
} }
void *dev_read_addr_ptr(struct udevice *dev)
{
fdt_addr_t addr = dev_read_addr(dev);
return (addr == FDT_ADDR_T_NONE) ? NULL : (void *)addr;
}
fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *property, fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *property,
fdt_size_t *sizep) fdt_size_t *sizep)
{ {
......
...@@ -112,6 +112,16 @@ fdt_addr_t dev_read_addr_index(struct udevice *dev, int index); ...@@ -112,6 +112,16 @@ fdt_addr_t dev_read_addr_index(struct udevice *dev, int index);
*/ */
fdt_addr_t dev_read_addr(struct udevice *dev); fdt_addr_t dev_read_addr(struct udevice *dev);
/**
* dev_read_addr_ptr() - Get the reg property of a device
* as a pointer
*
* @dev: Device to read from
*
* @return pointer or NULL if not found
*/
void *dev_read_addr_ptr(struct udevice *dev);
/** /**
* dev_read_addr_size() - get address and size from a device property * dev_read_addr_size() - get address and size from a device property
* *
...@@ -417,6 +427,11 @@ static inline fdt_addr_t dev_read_addr(struct udevice *dev) ...@@ -417,6 +427,11 @@ static inline fdt_addr_t dev_read_addr(struct udevice *dev)
return devfdt_get_addr(dev); return devfdt_get_addr(dev);
} }
static inline void *dev_read_addr_ptr(struct udevice *dev)
{
return devfdt_get_addr_ptr(dev);
}
static inline fdt_addr_t dev_read_addr_size(struct udevice *dev, static inline fdt_addr_t dev_read_addr_size(struct udevice *dev,
const char *propname, const char *propname,
fdt_size_t *sizep) fdt_size_t *sizep)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment