[U-Boot] [PATCH 3/5] Data type defined for pointer addresses

York Sun yorksun at freescale.com
Mon Dec 7 21:31:00 CET 2015



On 12/07/2015 09:50 AM, Tom Rini wrote:
> On Mon, Dec 07, 2015 at 09:33:45AM -0800, York Sun wrote:
>>
>>
>> On 12/07/2015 09:14 AM, Scott Wood wrote:
>>> On Mon, 2015-12-07 at 12:08 -0500, Tom Rini wrote:
>>>> On Mon, Dec 07, 2015 at 08:50:28AM -0800, York Sun wrote:
>>>>> Guys,
>>>>>
>>>>> Please comment on this new typedef. I am not comfortable to accept it.
>>>>>
>>>>> On 11/18/2015 09:41 PM, Aneesh Bansal wrote:
>>>>>> A new data type uintptr_t has been defined for creating
>>>>>> pointers (32 or 64 bit depending on Core) from 32 bit variables
>>>>>> storing the address.
>>>>>> If a 32 bit variable (u32) is typecasted to a pointer (void *),
>>>>>> compiler gives a warning in case size of pointer on the core is 64 bit.
>>>>>>
>>>>>> Signed-off-by: Aneesh Bansal <aneesh.bansal at freescale.com>
>>>>>> ---
>>>>>>  arch/arm/include/asm/types.h     | 2 ++
>>>>>>  arch/powerpc/include/asm/types.h | 1 +
>>>>>>  2 files changed, 3 insertions(+)
>>>>>>
>>>>>> diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/asm/types.h
>>>>>> index 388058e..5555765 100644
>>>>>> --- a/arch/arm/include/asm/types.h
>>>>>> +++ b/arch/arm/include/asm/types.h
>>>>>> @@ -56,6 +56,8 @@ typedef unsigned long phys_addr_t;
>>>>>>  typedef unsigned long phys_size_t;
>>>>>>  #endif
>>>>>>  
>>>>>> +typedef unsigned long uintptr_t;
>>>>>
>>>>> It is used in next patch of this series
>>>>> http://patchwork.ozlabs.org/patch/552669/, in two-step casting such as
>>>>>
>>>>> (u8 *)(uintptr_t)csf_hdr_addr
>>>>>
>>>>> As OP indicated, the variable is u32. Casting to a pointer causes
>>>>> compiling
>>>>> warning. Is this the right approach?
>>>>
>>>> Approach is OK.  But please do it as a "backport" of 142956af from the
>>>> linux kernel which adds 142956af to <linux/types.h> so everyone has it.
>>>
>>> There's also an existing uintptr_t typedef in include/compiler.h...
>>>
>>
>> Tom,
>>
>> We seem not having the abuse of ptrdiff_t. So the equivalent of Linux commit
>> 142956af would be moving this typedef from include/compiler.h to
>> include/linux/types.h.
> 
> Ah good, thanks.  I didn't follow the trail too far.
> 

Aneesh,

Please revise your patch according to the feedback. Thanks.

York


More information about the U-Boot mailing list