[PATCH] fix ide-iops for big endian archs

Benjamin Herrenschmidt
2002-09-25T12:27:07Z

[-- Attachment #1: Type: text/plain, Size: 1803 bytes --]

Curently in 2.5 (afaik in -ac too), the ide-iops "s" routines used
to transfer datas in/out the data port are incorrect for big endian
machines. They are implemented with a loop of inw/outw which are
byteswapping, but a fifo transfer like that mustn't be swapped.

Here's a patch against current 2.5 (that should apply to 2.4 -ac too)
that fixes those with a #define for now. I have done some further
cleanup of the iops (removing the {IN,OUT}{BYTE,WORD,LONG} macros
and removing the "P" iops from the hwif structure) too, but Alan
didn't accept those yet.

I enclosed the patch as an attachement too in case the mailer screws
it up...

===== drivers/ide/ide-iops.c 1.1 vs edited =====
--- 1.1/drivers/ide/ide-iops.c Wed Sep 11 08:54:11 2002
+++ edited/drivers/ide/ide-iops.c Wed Sep 25 14:19:58 2002
@@ -54,12 +54,20 @@

static inline void ide_insw (u32 port, void *addr, u32 count)
{
+#ifdef __BIG_ENDIAN
+ insw(port, addr, count);
+#else
while (count--) { *(u16 *)addr = IN_WORD(port); addr += 2; }
+#endif
}

static inline void ide_insw_p (u32 port, void *addr, u32 count)
{
- while (count--) { *(u16 *)addr = IN_WORD_P(port); addr += 2; }
+#ifdef __BIG_ENDIAN
+ insw(port, addr, count);
+#else
+ while (count--) { *(u16 *)addr = IN_WORD(port); addr += 2; }
+#endif
}

static inline u32 ide_inl (u32 port)
@@ -106,12 +114,20 @@

static inline void ide_outsw (u32 port, void *addr, u32 count)
{
+#ifdef __BIG_ENDIAN
+ outsw(port, addr, count);
+#else
while (count--) { OUT_WORD(*(u16 *)addr, port); addr += 2; }
+#endif
}

static inline void ide_outsw_p (u32 port, void *addr, u32 count)
{
+#ifdef __BIG_ENDIAN
+ outsw(port, addr, count);
+#else
while (count--) { OUT_WORD_P(*(u16 *)addr, port); addr += 2; }
+#endif
}

static inline void ide_outl (u32 addr, u32 port)

[-- Attachment #2: ide-fix.diff --]
[-- Type: application/text, Size: 1165 bytes --]