[U-Boot] [PATCH] rmobile: kzm9g: Fix warnin in cmp_loop function

Albert ARIBAUD albert.u.boot at aribaud.net
Fri Jul 6 16:01:24 CEST 2012


Hi Nobuhiro,

On Fri,  6 Jul 2012 09:07:30 +0900, Nobuhiro Iwamatsu
<nobuhiro.iwamatsu.yj at renesas.com> wrote:
> cmp_loop function was used from the structure of register.
> And for the member of this structure, volatile is defined.
> Since a volatile declaration of cmp_loop function is not made
> by argument, made warning by compiler. This fixes this problem.
> 
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj at renesas.com>
> ---
>  board/kmc/kzm9g/kzm9g.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/board/kmc/kzm9g/kzm9g.c b/board/kmc/kzm9g/kzm9g.c
> index ad72c8d..8d7c61a 100644
> --- a/board/kmc/kzm9g/kzm9g.c
> +++ b/board/kmc/kzm9g/kzm9g.c
> @@ -48,7 +48,7 @@ DECLARE_GLOBAL_DATA_PTR;
>  #define PORT34CR (0xE6051022)
>  #define PORT35CR (0xE6051023)
>  
> -static int cmp_loop(u32 *addr, u32 data, u32 cmp)
> +static int cmp_loop(volatile u32 *addr, u32 data, u32 cmp)
>  {
>  	int err = -1;
>  	int timeout = 100;

I doubt cmp_loop needs this change. Volatile qualifiers do not make
much sense in anything other than actual read or write instructions;
if cmp_loop needs any volatile, it's as casts in its body, not as
qualifiers in its signature. Fix the compiler warning by casting the
actual argument in the *call* to cmp_loop to non-volatile instead.

(incidentally, you should ask yourself why is the structure, or
structure member, is qualified volatile in the first place; usually
this is the sign that some code should instead use readl or writel
and/or have isb() barriers at strategic places.)

Amicalement,
-- 
Albert.


More information about the U-Boot mailing list