public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address
@ 2016-04-20 16:08 Stefan Roese
  2016-04-20 16:10 ` Simon Glass
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Roese @ 2016-04-20 16:08 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
---
 drivers/core/device.c |  5 +++++
 include/dm/device.h   | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 269087a..1322991 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -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);
diff --git a/include/dm/device.h b/include/dm/device.h
index dad7591..0bcbead 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -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
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address
  2016-04-20 16:08 [U-Boot] [PATCH] dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address Stefan Roese
@ 2016-04-20 16:10 ` Simon Glass
  2016-05-07 15:19   ` Simon Glass
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2016-04-20 16:10 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On 20 April 2016 at 10:08, Stefan Roese <sr@denx.de> wrote:
> 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.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>  drivers/core/device.c |  5 +++++
>  include/dm/device.h   | 10 ++++++++++
>  2 files changed, 15 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

Request below...

>
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index 269087a..1322991 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -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);
> diff --git a/include/dm/device.h b/include/dm/device.h
> index dad7591..0bcbead 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -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"

> + */
> +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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address
  2016-04-20 16:10 ` Simon Glass
@ 2016-05-07 15:19   ` Simon Glass
  2016-05-07 15:31     ` Bin Meng
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2016-05-07 15:19 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On 20 April 2016 at 10:10, Simon Glass <sjg@chromium.org> wrote:
> Hi Stefan,
>
> On 20 April 2016 at 10:08, Stefan Roese <sr@denx.de> wrote:
>> 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.
>>
>> Signed-off-by: Stefan Roese <sr@denx.de>
>> Cc: Simon Glass <sjg@chromium.org>
>> ---
>>  drivers/core/device.c |  5 +++++
>>  include/dm/device.h   | 10 ++++++++++
>>  2 files changed, 15 insertions(+)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> Request below...
>
>>
>> diff --git a/drivers/core/device.c b/drivers/core/device.c
>> index 269087a..1322991 100644
>> --- a/drivers/core/device.c
>> +++ b/drivers/core/device.c
>> @@ -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);
>> diff --git a/include/dm/device.h b/include/dm/device.h
>> index dad7591..0bcbead 100644
>> --- a/include/dm/device.h
>> +++ b/include/dm/device.h
>> @@ -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"

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

>
>> + */
>> +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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address
  2016-05-07 15:19   ` Simon Glass
@ 2016-05-07 15:31     ` Bin Meng
  2016-05-07 15:33       ` Simon Glass
  0 siblings, 1 reply; 6+ messages in thread
From: Bin Meng @ 2016-05-07 15:31 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On Sat, May 7, 2016 at 11:19 PM, Simon Glass <sjg@chromium.org> wrote:
> Hi Stefan,
>
> On 20 April 2016 at 10:10, Simon Glass <sjg@chromium.org> wrote:
>> Hi Stefan,
>>
>> On 20 April 2016 at 10:08, Stefan Roese <sr@denx.de> wrote:
>>> 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.
>>>
>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>> Cc: Simon Glass <sjg@chromium.org>
>>> ---
>>>  drivers/core/device.c |  5 +++++
>>>  include/dm/device.h   | 10 ++++++++++
>>>  2 files changed, 15 insertions(+)
>>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>
>> Request below...
>>
>>>
>>> diff --git a/drivers/core/device.c b/drivers/core/device.c
>>> index 269087a..1322991 100644
>>> --- a/drivers/core/device.c
>>> +++ b/drivers/core/device.c
>>> @@ -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);
>>> diff --git a/include/dm/device.h b/include/dm/device.h
>>> index dad7591..0bcbead 100644
>>> --- a/include/dm/device.h
>>> +++ b/include/dm/device.h
>>> @@ -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"
>
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address
  2016-05-07 15:31     ` Bin Meng
@ 2016-05-07 15:33       ` Simon Glass
  2016-05-07 15:40         ` Stefan Roese
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2016-05-07 15:33 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On 7 May 2016 at 09:31, Bin Meng <bmeng.cn@gmail.com> wrote:
> Hi Simon,
>
> On Sat, May 7, 2016 at 11:19 PM, Simon Glass <sjg@chromium.org> wrote:
>> Hi Stefan,
>>
>> On 20 April 2016 at 10:10, Simon Glass <sjg@chromium.org> wrote:
>>> Hi Stefan,
>>>
>>> On 20 April 2016 at 10:08, Stefan Roese <sr@denx.de> wrote:
>>>> 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.
>>>>
>>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>>> Cc: Simon Glass <sjg@chromium.org>
>>>> ---
>>>>  drivers/core/device.c |  5 +++++
>>>>  include/dm/device.h   | 10 ++++++++++
>>>>  2 files changed, 15 insertions(+)
>>>
>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>
>>> Request below...
>>>
>>>>
>>>> diff --git a/drivers/core/device.c b/drivers/core/device.c
>>>> index 269087a..1322991 100644
>>>> --- a/drivers/core/device.c
>>>> +++ b/drivers/core/device.c
>>>> @@ -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);
>>>> diff --git a/include/dm/device.h b/include/dm/device.h
>>>> index dad7591..0bcbead 100644
>>>> --- a/include/dm/device.h
>>>> +++ b/include/dm/device.h
>>>> @@ -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"
>>
>> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH] dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address
  2016-05-07 15:33       ` Simon Glass
@ 2016-05-07 15:40         ` Stefan Roese
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Roese @ 2016-05-07 15:40 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 07.05.2016 17:33, Simon Glass wrote:
> Hi Bin,
>
> On 7 May 2016 at 09:31, Bin Meng <bmeng.cn@gmail.com> wrote:
>> Hi Simon,
>>
>> On Sat, May 7, 2016 at 11:19 PM, Simon Glass <sjg@chromium.org> wrote:
>>> Hi Stefan,
>>>
>>> On 20 April 2016 at 10:10, Simon Glass <sjg@chromium.org> wrote:
>>>> Hi Stefan,
>>>>
>>>> On 20 April 2016 at 10:08, Stefan Roese <sr@denx.de> wrote:
>>>>> 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.
>>>>>
>>>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>>>> Cc: Simon Glass <sjg@chromium.org>
>>>>> ---
>>>>>   drivers/core/device.c |  5 +++++
>>>>>   include/dm/device.h   | 10 ++++++++++
>>>>>   2 files changed, 15 insertions(+)
>>>>
>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>>
>>>> Request below...
>>>>
>>>>>
>>>>> diff --git a/drivers/core/device.c b/drivers/core/device.c
>>>>> index 269087a..1322991 100644
>>>>> --- a/drivers/core/device.c
>>>>> +++ b/drivers/core/device.c
>>>>> @@ -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);
>>>>> diff --git a/include/dm/device.h b/include/dm/device.h
>>>>> index dad7591..0bcbead 100644
>>>>> --- a/include/dm/device.h
>>>>> +++ b/include/dm/device.h
>>>>> @@ -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"
>>>
>>> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-05-07 15:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-20 16:08 [U-Boot] [PATCH] dm: core: Add dev_get_addr_ptr() to return a pointer to the reg address Stefan Roese
2016-04-20 16:10 ` Simon Glass
2016-05-07 15:19   ` Simon Glass
2016-05-07 15:31     ` Bin Meng
2016-05-07 15:33       ` Simon Glass
2016-05-07 15:40         ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox