Resent-Date: Wed, 21 Oct 1998 13:34:12 +0200 (MET DST)
From: Kars de Jong <jongk@cs.utwente.nl>
To: Linux/m68k mailing list <linux-m68k@lists.linux-m68k.org>
Subject: Bug in ide.h found (and fixed)
Date: Wed, 21 Oct 1998 13:29:57 +0200
Resent-From: linux-m68k@phil.uni-sb.de

Hi all,

I found (and fixed) the bug(s) that lurked into the code for outsw() and
insw() in include/asm-m68k/ide.h. The problem was swapped arguments, and a logic
error. Nothing like asm for nice errors.

Kars, who can finally use the normal tree again :)
--
------------------------------------------------------------------------------
Kars de Jong             Signaalkamp rules the waves!       Turrican@Discworld
--------======]**-----|      jongk@cs.utwente.nl      |-----**[======---------

--- linux-2.1.124/include/asm-m68k/ide.h.old	Mon Jun  8 18:57:15 1998
+++ linux-2.1.124/include/asm-m68k/ide.h	Wed Oct 21 11:54:29 1998
@@ -146,34 +146,36 @@
 	if (_nr & 15) {					\
 		_tmp = (_nr & 15) - 1;			\
 		asm volatile (				\
-			"1: movew %2@,%3@+; dbra %4,1b"	\
+			"1: movew %2@,%0@+; dbra %1,1b"	\
+			: "=a" (_buf), "=d" (_tmp)	\
+			: "a" (_port), "0" (_buf),	\
+			  "1" (_tmp));			\
+	}						\
+	if (_nr >> 4) {					\
+		_tmp = (_nr >> 4) - 1;			\
+		asm volatile (				\
+			"1: "				\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"movew %2@,%0@+; "		\
+			"dbra %1,1b"			\
 			: "=a" (_buf), "=d" (_tmp)	\
 			: "a" (_port), "0" (_buf),	\
 			  "1" (_tmp));			\
 	}						\
-	_tmp = (_nr >> 4) - 1;				\
-	asm volatile (					\
-		"1: "					\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"movew %2@,%3@+; "			\
-		"dbra %4,1b"				\
-		: "=a" (_buf), "=d" (_tmp)		\
-		: "a" (_port), "0" (_buf),		\
-		  "1" (_tmp));				\
 })
 
 #define outsw(port, buf, nr) ({				\
@@ -185,34 +187,36 @@
 	if (_nr & 15) {					\
 		_tmp = (_nr & 15) - 1;			\
 		asm volatile (				\
-			"1: movew %3@,%2@+; dbra %4,1b"	\
+			"1: movew %0@+,%2@; dbra %1,1b"	\
+			: "=a" (_buf), "=d" (_tmp)	\
+			: "a" (_port), "0" (_buf),	\
+			  "1" (_tmp));			\
+	}						\
+	if (_nr >> 4) {					\
+		_tmp = (_nr >> 4) - 1;			\
+		asm volatile (				\
+			"1: "				\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"movew %0@+,%2@; "		\
+			"dbra %1,1b"	   		\
 			: "=a" (_buf), "=d" (_tmp)	\
 			: "a" (_port), "0" (_buf),	\
 			  "1" (_tmp));			\
 	}						\
-	_tmp = (_nr >> 4) - 1;				\
-	asm volatile (					\
-		"1: "					\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"movew %3@+,%2@; "			\
-		"dbra %4,1b"	   			\
-		: "=a" (_buf), "=d" (_tmp)		\
-		: "a" (_port), "0" (_buf),		\
-		  "1" (_tmp));				\
 })
 
 #ifdef CONFIG_ATARI

