[PATCH 2/2] net: calexdaxgmac: fixup endian issues after __raw IO function change

David Laight David.Laight at ACULAB.COM
Tue Feb 12 04:19:52 EST 2013


> > You are using le32_to_cpu() and cpu_to_le32() the wrong way round, and
> > then putting casts on the wrong side, i.e. it should be:
> >
> > 	value = le32_to_cpu((__force __le32)__raw_readl(addr));
> > 	__raw_writel((__force u32)cpu_to_le32(value), addr);
> >
> > (I do wonder why __raw I/O functions aren't declared to take/return __le
> > types... it would avoid the need to cast altogether.)
> 
> Because they do things with the order the cpu is working in, the
> read{x} and write{x} transfer cpu to bus-endian so returning an __le
> type would not be correct.

Surely you want to arrange to use the byte-swapping memory
read/write instructions, rather than byteswapping the value.

Particularly on ppc which doesn't have a byteswap instruction
but can do byteswapping memory accesses.

	David



More information about the linux-arm-kernel mailing list