PCI reading without endian conversion
Geert Uytterhoeven
Geert.Uytterhoeven at sonycom.com
Mon Feb 23 21:37:29 EST 2009
On Fri, 20 Feb 2009, Ira Snyder wrote:
> On Fri, Feb 20, 2009 at 03:56:39PM -0600, Matt Sealey wrote:
> > Am I correct in saying that cpu_to_le32 and le32_to_cpu are the
> > functions/macros I need to use to do byte swapping to make everything
> > go little endian (and back again when I read them back in the kernel)?
> >
> > Or is there some cleverer way already implemented in the kernel?
>
> I would say that the __raw_readl() reads in cpu order. If you wanted to
> convert that to le32, you'd use cpu_to_le32().
Well...
__raw_readl() does read in cpu order. But since you're reading from the PCI
bus, which is little endian, you actually read a little endian value. So you
should use le32_to_cpu() to convert it to a native value.
(yes, at the lowest level, cpu_to_le32() and le32_to_cpu() do the same thing
on PPC: byte swapping 32-bit data).
With kind regards,
Geert Uytterhoeven
Software Architect
Sony Techsoft Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
Phone: +32 (0)2 700 8453
Fax: +32 (0)2 700 8622
E-mail: Geert.Uytterhoeven at sonycom.com
Internet: http://www.sony-europe.com/
A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010
More information about the Linuxppc-dev
mailing list