dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address
PATCH v2 1/1 dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address
On some platforms (e.g. x86), the return value of dev_get_addr() can't be assigned to a pointer type variable directly. As there might be a difference between the size of fdt_addr_t and the pointer type. On x86 for example, "fdt_addr_t" is 64bit but "void *" only 32bit. So assigning the register base directly in dev_get_addr() results in this compilation warning:
warning: cast to pointer from integer of different size
This patch introduces the new function dev_get_addr_ptr() that returns a pointer to the 'reg' address that can be used by drivers in this case.
---
v2:
- Mention error condition in function prototype as suggested by Simon
drivers/core/device.c | 5 +++++ include/dm/device.h | 10 ++++++++++ 2 files changed, 15 insertions(+)
drivers/core/device.c +5 -0
@@ -673,6 +673,11 @@ fdt_addr_t dev_get_addr(struct udevice *dev)return dev_get_addr_index (dev,0 ); } +void *dev_get_addr_ptr (struct udevice *dev) +{ +return (void *)(uintptr_t )dev_get_addr_index (dev,0 ); +} +bool device_has_children (struct udevice *dev) {return !list_empty (&dev->child_head);
include/dm/device.h +10 -0
@@ -454,6 +454,16 @@ int device_find_next_child(struct udevice **devp);fdt_addr_t dev_get_addr (struct udevice *dev);/** +* dev_get_addr_ptr() - Return pointer to the address of the reg property +* of a device +* +* @dev: Pointer to a device +* +* @return Pointer to addr, or NULL if there is no such property +*/ +void *dev_get_addr_ptr (struct udevice *dev); + +/** * dev_get_addr_index() - Get the indexed reg property of a device * * @dev: Pointer to a device
Signature · 1 line
2.8.1
PATCH v2 1/1 dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address
Quoted 14 lines · Stefan Roese
On some platforms (e.g. x86), the return value of
dev_get_addr()can't be assigned to a pointer type variable directly. As there might be a difference between the size offdt_addr_tand the pointer type. On x86 for example, "fdt_addr_t" is 64bit but "void *" only 32bit. So assigning the register base directly indev_get_addr()results in this compilation warning:
warning: cast to pointer from integer of different sizeThis patch introduces the new function
dev_get_addr_ptr()that returns a pointer to the 'reg' address that can be used by drivers in this case.Signed-off-by Stefan Roese <[email protected]>Reviewed-by Simon Glass <[email protected]>
Quoted 8 lines
---
v2:
- Mention error condition in function prototype as suggested by Simondrivers/core/device.c | 5 +++++ include/dm/device.h | 10 ++++++++++ 2 files changed, 15 insertions(+)
PATCH v2 1/1 dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address
In reply to Stefan RoeseQuoted 14 lines · Stefan Roese
On some platforms (e.g. x86), the return value of
dev_get_addr()can't be assigned to a pointer type variable directly. As there might be a difference between the size offdt_addr_tand the pointer type. On x86 for example, "fdt_addr_t" is 64bit but "void *" only 32bit. So assigning the register base directly indev_get_addr()results in this compilation warning:
warning: cast to pointer from integer of different sizeThis patch introduces the new function
dev_get_addr_ptr()that returns a pointer to the 'reg' address that can be used by drivers in this case.Signed-off-by Stefan Roese <[email protected]>Reviewed-by Simon Glass <[email protected]>
Quoted 7 lines
---
v2:
- Mention error condition in function prototype as suggested by Simondrivers/core/device.c | 5 +++++ include/dm/device.h | 10 ++++++++++ 2 files changed, 15 insertions(+)