readw byte sex?

Jeff Garzik jgarzik at mandrakesoft.com
Wed Mar 29 07:15:11 EST 2000


jlquinn at us.ibm.com wrote:
>
> I've seen info about this go by in the past, but wasn't paying careful
> attention...
>
> I'm working on trying to get my Advansys 970UW working under PPC linux
> 2.2.x.  I'm not tackling 2.3.x because I don't think the driver itself is
> up to date with respect to the 2.3 tree, while it is OK for x86 and alpha
> 2.2.x.  I'm having (surprise, surprise) byte swapping problems, which I so
> far am tracing to the following construct and pals:
>
>  x = le16_to_cpu(readw(addr))
>
> Both of these are byteswapping, leaving me with a reversed value, which of
> course causes havoc later.  What's the correct way to do this?  I can't
> find where the exact platform-independent semantics of readw are defined.
>
> Is this a FAQ?

readw is defined as functioning on a little endian PCI bus, so it
already should byte swap for you.

--
Jeff Garzik              | Tact is the ability to tell a man
Building 1024            | he has an open mind when he has a
MandrakeSoft, Inc.       | hole in his head.  (-random fortune)

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-dev mailing list