To: linux-m68k@lists.linux-m68k.org
Subject: L68K: 2.1.72 patch
X-Yow: Hello.  Just walk along and try NOT to think about your
 INTESTINES being almost FORTY YARDS LONG!!
From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Date: 19 Dec 1997 10:48:37 +0100
Sender: owner-linux-m68k@phil.uni-sb.de

This is the first part of my patch for 2.1.72.  The second part will
follow when i have applied Roman's and Geert's patches.

Andreas.

----------------------------------------------------------------------
--- linux/arch/m68k/atari/stram.c.~1~	Wed Dec 17 19:49:02 1997
+++ linux/arch/m68k/atari/stram.c	Thu Dec 18 08:20:40 1997
@@ -169,6 +169,8 @@
 /* The ST-RAM's swap type */
 static int stram_swap_type;
 
+#endif /* CONFIG_STRAM_SWAP */
+
 typedef struct stram_block {
 	struct stram_block *next;
 	unsigned long start;
@@ -210,9 +212,6 @@
 static unsigned stat_swap_move = 0;
 static unsigned stat_swap_force = 0;
 #endif /* DO_PROC */
-
-#endif /* CONFIG_STRAM_SWAP */
-
 
 /***************************** Prototypes *****************************/
 
--- linux/arch/m68k/ifpsp060/iskeleton.S.~1~	Mon Jul 28 17:23:16 1997
+++ linux/arch/m68k/ifpsp060/iskeleton.S	Tue Dec  9 17:49:22 1997
@@ -183,7 +183,7 @@
 |
 | _060_lock_page():
 |
-| Entry point for the operating system's routine to "lock" a page
+| Entry point for the operating system`s routine to "lock" a page
 | from being paged out. This routine is needed by the cas/cas2
 | algorithms so that no page faults occur within the "core" code
 | region. Note: the routine must lock two pages if the operand 
@@ -208,7 +208,7 @@
 |
 | _060_unlock_page():
 |
-| Entry point for the operating system's routine to "unlock" a
+| Entry point for the operating system`s routine to "unlock" a
 | page that has been "locked" previously with _real_lock_page.
 | Note: the routine must unlock two pages if the operand spans
 | two pages.
--- linux/arch/m68k/ifpsp060/os.S.~1~	Mon Feb 17 17:33:06 1997
+++ linux/arch/m68k/ifpsp060/os.S	Tue Dec  9 18:32:28 1997
@@ -345,7 +345,6 @@
 copyinae:	
 	movs.b		(%a0)+,%d1		| fetch user byte
 	move.b		%d1,(%a1)+		| write supervisor byte
-	subq.l		#0x1,%d0		| are we through yet?
 	dbra		%d0,morein		| are we through yet?
 	moveq		#0,%d0			| return success
 	rts
--- linux/arch/m68k/kernel/process.c.~1~	Tue Dec  9 08:39:59 1997
+++ linux/arch/m68k/kernel/process.c	Thu Dec 18 22:49:32 1997
@@ -113,17 +113,14 @@
 		printk("USP: %08lx\n", rdusp());
 }
 
-/*
- * Free current thread data structures etc..
- */
-void exit_thread(void)
-{
-}
-
 void flush_thread(void)
 {
+	unsigned long zero = 0;
 	set_fs(USER_DS);
 	current->tss.fs = __USER_DS;
+	asm volatile (".chip 68k/68881\n\t"
+		      "frestore %0@\n\t"
+		      ".chip 68k" : : "a" (&zero));
 }
 
 /*
@@ -160,10 +157,6 @@
 	return ret;
 }
 
-void release_thread(struct task_struct *dead_task)
-{
-}
-
 int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
 		 struct task_struct * p, struct pt_regs * regs)
 {
@@ -195,8 +188,7 @@
 	/* Copy the current fpu state */
 	asm volatile ("fsave %0" : : "m" (p->tss.fpstate[0]) : "memory");
 
-	if((!CPU_IS_060 && p->tss.fpstate[0]) ||
-	   (CPU_IS_060 && p->tss.fpstate[2]))
+	if (!CPU_IS_060 ? p->tss.fpstate[0] : p->tss.fpstate[2])
 	  asm volatile ("fmovemx %/fp0-%/fp7,%0\n\t"
 			"fmoveml %/fpiar/%/fpcr/%/fpsr,%1"
 			: : "m" (p->tss.fp[0]), "m" (p->tss.fpcntl[0])
@@ -215,7 +207,7 @@
 
   /* First dump the fpu context to avoid protocol violation.  */
   asm volatile ("fsave %0" :: "m" (fpustate[0]) : "memory");
-  if((!CPU_IS_060 && !fpustate[0]) || (CPU_IS_060 && !fpustate[2]))
+  if (!CPU_IS_060 ? !fpustate[0] : !fpustate[2])
      return 0;
 
   asm volatile ("fmovem %/fpiar/%/fpcr/%/fpsr,%0"
--- linux/arch/m68k/kernel/signal.c.~1~	Thu Dec 11 17:51:39 1997
+++ linux/arch/m68k/kernel/signal.c	Thu Dec 18 22:52:45 1997
@@ -566,10 +566,10 @@
 				  : "m" (*fpregs.f_fpregs),
 				    "m" (fpregs.f_pcr)
 				  : "memory");
-		copy_to_user(&fpregs, &uc->uc_mcontext.fpregs, sizeof(fpregs));
+		copy_to_user(&uc->uc_mcontext.fpregs, &fpregs, sizeof(fpregs));
 	}
 	if (context_size)
-		copy_to_user(fpstate + 4, (long *)&uc->uc_fpstate + 1,
+		copy_to_user((long *)&uc->uc_fpstate + 1, fpstate + 4,
 			     context_size);
 }
 
--- linux/drivers/block/ataflop.c.~1~	Wed Dec 17 19:49:22 1997
+++ linux/drivers/block/ataflop.c	Thu Dec 18 08:42:54 1997
@@ -978,11 +978,12 @@
 		 * search for the first non-existent sector and need 1 sec to
 		 * recognise that it isn't present :-(
 		 */
+		del_timer (&readtrack_timer);
 		readtrack_timer.expires =
 		  jiffies + HZ/5 + (old_motoron ? 0 : HZ);
 		       /* 1 rot. + 5 rot.s if motor was off  */
-		add_timer( &readtrack_timer );
 		MultReadInProgress = 1;
+		add_timer( &readtrack_timer );
 	}
 	START_TIMEOUT();
 }
@@ -1060,8 +1061,8 @@
 	if (read_track) {
 		if (!MultReadInProgress)
 			return;
-		MultReadInProgress = 0;
 		del_timer( &readtrack_timer );
+		MultReadInProgress = 0;
 	}
 
 	/* Correct the track if stretch != 0 */
--- linux/include/asm-m68k/processor.h.~1~	Tue Dec  9 07:15:26 1997
+++ linux/include/asm-m68k/processor.h	Thu Dec 18 22:18:38 1997
@@ -58,13 +58,6 @@
 static inline void start_thread(struct pt_regs * regs, unsigned long pc,
 				unsigned long usp)
 {
-	unsigned long nilstate = 0;
-
-	/* clear floating point state */
-	__asm__ __volatile__ (".chip 68k/68881\n\t"
-			      "frestore %0@\n\t"
-			      ".chip 68k" : : "a" (&nilstate));
-
 	/* reads from user space */
 	set_fs(USER_DS);
 
@@ -74,7 +67,16 @@
 }
 
 /* Free all resources held by a thread. */
-extern void release_thread(struct task_struct *);
+static inline void release_thread(struct task_struct *dead_task)
+{
+}
+
+/*
+ * Free current thread data structures etc..
+ */
+static inline void exit_thread(void)
+{
+}
 
 /*
  * Return saved PC of a blocked thread.
--- linux/include/linux/kernel.h.~1~	Wed Dec 17 19:57:37 1997
+++ linux/include/linux/kernel.h	Fri Dec  5 14:07:59 1997
@@ -75,10 +75,10 @@
  */
 
 #define NIPQUAD(addr) \
-	(((addr) >> 0)  & 0xff), \
-	(((addr) >> 8)  & 0xff), \
-	(((addr) >> 16) & 0xff), \
-	(((addr) >> 24) & 0xff)
+	(int)((htonl(addr) >> 24) & 0xff), \
+	(int)((htonl(addr) >> 16) & 0xff), \
+	(int)((htonl(addr) >> 8)  & 0xff), \
+	(int)((htonl(addr) >> 0)  & 0xff)
 
 #endif /* __KERNEL__ */
 
