Skip to contentSkip to conversation

dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address

PATCH Superseded Stefan Roese 3 participants 6 messages Apr 20, 2016 – May 7, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 drivers/core/device.c |  5 +++++
 include/dm/device.h   | 10 ++++++++++
 2 files changed, 15 insertions(+)
drivers/core/device.c +5 -0
index 269087a..1322991 100644
@@ -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
index dad7591..0bcbead 100644
@@ -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
+ */
+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
#1 lore raw

PATCH 1/1 dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address

Hi Stefan,

Quoted 12 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 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.

Quoted 6 lines
---
 drivers/core/device.c |  5 +++++
 include/dm/device.h   | 10 ++++++++++
 2 files changed, 15 insertions(+)

Request below...

Quoted 22 lines
drivers/core/device.c +5 -0
index 269087a..1322991 100644
@@ -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 +0 -0
index dad7591..0bcbead 100644

include/dm/device.h int device_find_next_child(struct udevice **devp); · line 462

Quoted 9 lines
include/dm/device.h +6 -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

Please mention the error condition, e.g. ", or NULL if there is no such property"

Quoted 10 lines
include/dm/device.h +4 -1
+ */
+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
--

2.8.1

Regards,
Simon

#2 lore raw

PATCH 1/1 dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address

Hi Stefan,

Quoted 50 lines · Simon Glass

Hi Stefan,

Quoted 12 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 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.

Quoted 6 lines
---
 drivers/core/device.c |  5 +++++
 include/dm/device.h   | 10 ++++++++++
 2 files changed, 15 insertions(+)

Request below...

Quoted 24 lines
drivers/core/device.c +5 -0
index 269087a..1322991 100644
@@ -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 +0 -0
index dad7591..0bcbead 100644
@@ -454,6 +454,16 @@ int device_find_next_child(struct udevice **devp);
 fdt_addr_t dev_get_addr(struct udevice *dev);
 
Quoted 10 lines

include/dm/device.h int device_find_next_child(struct udevice **devp); · line 462

Quoted 7 lines
include/dm/device.h +6 -0
 /**
+ * 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

Please mention the error condition, e.g. ", or NULL if there is no such property"

I'd like to get this applied. If you like I can fix this when applying?

Quoted 10 lines
Quoted 10 lines
include/dm/device.h +4 -1
+ */
+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
--

2.8.1

Regards,
Simon

#3 lore raw

PATCH 1/1 dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address

Hi Simon,

Quoted 64 lines · Simon Glass

Hi Stefan,

Quoted 50 lines · Simon Glass

Hi Stefan,

Quoted 12 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 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.

Quoted 6 lines
---
 drivers/core/device.c |  5 +++++
 include/dm/device.h   | 10 ++++++++++
 2 files changed, 15 insertions(+)

Request below...

Quoted 24 lines
drivers/core/device.c +5 -0
index 269087a..1322991 100644
@@ -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 +0 -0
index dad7591..0bcbead 100644
@@ -454,6 +454,16 @@ int device_find_next_child(struct udevice **devp);
 fdt_addr_t dev_get_addr(struct udevice *dev);
 
Quoted 10 lines

include/dm/device.h int device_find_next_child(struct udevice **devp); · line 462

Quoted 7 lines
include/dm/device.h +6 -0
 /**
+ * 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

Please mention the error condition, e.g. ", or NULL if there is no such property"

Quoted 2 lines

I'd like to get this applied. If you like I can fix this when applying?

Looks this was already applied an in mainline. See 28027521be95d27fcb83669e09ce3563bb4dd977

Regards,
Bin

#4 lore raw

PATCH 1/1 dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address

Hi Bin,

Quoted 67 lines · Bin Meng

Hi Simon,

Quoted 64 lines · Simon Glass

Hi Stefan,

Quoted 60 lines · Simon Glass

Hi Stefan,

Quoted 12 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 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.

Quoted 6 lines
---
 drivers/core/device.c |  5 +++++
 include/dm/device.h   | 10 ++++++++++
 2 files changed, 15 insertions(+)

Request below...

Quoted 22 lines
drivers/core/device.c +5 -0
index 269087a..1322991 100644
@@ -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 +0 -0
index dad7591..0bcbead 100644

include/dm/device.h int device_find_next_child(struct udevice **devp); · line 462

Quoted 9 lines
include/dm/device.h +6 -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

Please mention the error condition, e.g. ", or NULL if there is no such property"

Quoted 5 lines
Quoted 2 lines

I'd like to get this applied. If you like I can fix this when applying?

Looks this was already applied an in mainline. See 28027521be95d27fcb83669e09ce3563bb4dd977

OK thanks, not sure what happened there.

Regards,
Simon

#5 lore raw

PATCH 1/1 dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address

Hi Simon,

Quoted 70 lines · Simon Glass

Hi Bin,

Quoted 67 lines · Bin Meng

Hi Simon,

Quoted 64 lines · Simon Glass

Hi Stefan,

Quoted 60 lines · Simon Glass

Hi Stefan,

Quoted 12 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 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.

Quoted 6 lines
---
  drivers/core/device.c |  5 +++++
  include/dm/device.h   | 10 ++++++++++
  2 files changed, 15 insertions(+)

Request below...

Quoted 22 lines
drivers/core/device.c +5 -0
index 269087a..1322991 100644
@@ -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 +0 -0
index dad7591..0bcbead 100644

include/dm/device.h int device_find_next_child(struct udevice **devp); · line 462

Quoted 9 lines
include/dm/device.h +6 -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

Please mention the error condition, e.g. ", or NULL if there is no such property"

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I'd like to get this applied. If you like I can fix this when applying?

Looks this was already applied an in mainline. See 28027521be95d27fcb83669e09ce3563bb4dd977

OK thanks, not sure what happened there.

Yes, IIRC, Heiko applied it with the I2C DWC patches. I've also added the comment in the header, so this should hopefully be okay.

Thanks,
Stefan