PCI reading without endian conversion

Benjamin Herrenschmidt benh at kernel.crashing.org
Sat Feb 21 15:33:17 EST 2009


> > 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().

Beware that __raw_* forms also don't have memory barriers.

In general, you know what byte order your device uses (which is often
little endian) and you use the appropriate ioread32{be}. Now, for
userspace, you simply need to mimmic those accessors.

Ben.





More information about the Linuxppc-dev mailing list