[U-Boot] [PATCH 3/6] arm: Allow u32 as addrs for readX/writeX

Hans de Goede hdegoede at redhat.com
Tue Mar 29 17:46:14 CEST 2016


Hi,

On 03/29/2016 05:29 PM, Alexander Graf wrote:
> Gcc warns when you try to cast a u32 value into a pointer directly. When someone
> calls functions like readl or writel, he's pretty sure the parameter he passes
> is an address though, so we can as well cast it for him.
>
> This makes porting 32bit code to armv8 easier, as it means we don't have to
> touch common board code with explicit casts or UL redefines.
>
> Signed-off-by: Alexander Graf <agraf at suse.de>

Albert can we have your ack for this please ? It is probably
easiest if I take the entire series upstream through the u-boot-sunxi
tree.

Regards,

Hans


> ---
>   arch/arm/include/asm/io.h | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
> index 75773bd..b85f4d7 100644
> --- a/arch/arm/include/asm/io.h
> +++ b/arch/arm/include/asm/io.h
> @@ -67,15 +67,15 @@ static inline phys_addr_t virt_to_phys(void * vaddr)
>    * read/writes.  We define __arch_*[bl] here, and leave __arch_*w
>    * to the architecture specific code.
>    */
> -#define __arch_getb(a)			(*(volatile unsigned char *)(a))
> -#define __arch_getw(a)			(*(volatile unsigned short *)(a))
> -#define __arch_getl(a)			(*(volatile unsigned int *)(a))
> -#define __arch_getq(a)			(*(volatile unsigned long long *)(a))
> -
> -#define __arch_putb(v,a)		(*(volatile unsigned char *)(a) = (v))
> -#define __arch_putw(v,a)		(*(volatile unsigned short *)(a) = (v))
> -#define __arch_putl(v,a)		(*(volatile unsigned int *)(a) = (v))
> -#define __arch_putq(v,a)		(*(volatile unsigned long long *)(a) = (v))
> +#define __arch_getb(a)			(*(volatile unsigned char *)(long)(a))
> +#define __arch_getw(a)			(*(volatile unsigned short *)(long)(a))
> +#define __arch_getl(a)			(*(volatile unsigned int *)(long)(a))
> +#define __arch_getq(a)			(*(volatile unsigned long long *)(long)(a))
> +
> +#define __arch_putb(v,a)		(*(volatile unsigned char *)(long)(a) = (v))
> +#define __arch_putw(v,a)		(*(volatile unsigned short *)(long)(a) = (v))
> +#define __arch_putl(v,a)		(*(volatile unsigned int *)(long)(a) = (v))
> +#define __arch_putq(v,a)		(*(volatile unsigned long long *)(long)(a) = (v))
>
>   static inline void __raw_writesb(unsigned long addr, const void *data,
>   				 int bytelen)
>


More information about the U-Boot mailing list