[PATCH] fix ide-iops for big endian archs

From: Benjamin Herrenschmidt (benh@kernel.crashing.org)
Date: Wed Sep 25 2002 - 07:32:23 EST


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)



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Sep 30 2002 - 22:00:22 EST