Resent-Date: Mon, 17 May 1999 10:17:32 +0200 (MET DST)
To: Jes Sorensen <Jes.Sorensen@cern.ch>
Cc: linux-m68k@lists.linux-m68k.org
Subject: Re: 2.3.1 snapshot
References: <199905141825.UAA156782@rsplus10.cern.ch>
X-Yow: The Korean War must have been fun.
From: Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
Date: 17 May 1999 10:16:05 +0200
In-Reply-To: Jes Sorensen's message of "Fri, 14 May 1999 20:25:42 +0200"
Resent-From: linux-m68k@phil.uni-sb.de

Jes Sorensen <Jes.Sorensen@cern.ch> writes:

|> Anyway it can be found at SunSITE.auc.dk
|> /pub/os/linux/680x0/testing/linux-2.3.1-snapshot.tar.gz

For those who want to try, here are some patches:

--- linux/arch/m68k/atari/joystick.c.~1~	Thu Aug 27 09:09:08 1998
+++ linux/arch/m68k/atari/joystick.c	Fri May 14 19:48:59 1999
@@ -134,7 +134,8 @@
 {
     joystick[0].active = joystick[1].active = 0;
     joystick[0].ready = joystick[1].ready = 0;
-    joystick[0].wait = joystick[1].wait = NULL;
+    init_waitqueue_head(&joystick[0].wait);
+    init_waitqueue_head(&joystick[1].wait);
 
     if (register_chrdev(MAJOR_NR, "Joystick", &atari_joystick_fops))
 	printk("unable to get major %d for joystick devices\n", MAJOR_NR);
--- linux/arch/m68k/atari/stdma.c.~1~	Fri Jan  9 18:09:49 1998
+++ linux/arch/m68k/atari/stdma.c	Sat May 15 14:35:33 1999
@@ -43,7 +43,7 @@
 						/* int func to be called */
 static void (*stdma_isr)(int, void *, struct pt_regs *) = NULL;
 static void	*stdma_isr_data = NULL;		/* data passed to isr */
-static struct wait_queue *stdma_wait = NULL;	/* wait queue for ST-DMA */
+static DECLARE_WAIT_QUEUE_HEAD(stdma_wait);	/* wait queue for ST-DMA */
 
 
 
--- linux/arch/m68k/atari/stram.c.~1~	Fri Oct 23 23:04:46 1998
+++ linux/arch/m68k/atari/stram.c	Fri May 14 19:50:24 1999
@@ -200,7 +200,7 @@
 static int stram_swap_type;
 
 /* Semaphore for get_stram_region.  */
-static struct semaphore stram_swap_sem = MUTEX;
+static DECLARE_MUTEX(stram_swap_sem);
 
 /* major and minor device number of the ST-RAM device; for the major, we use
  * the same as Amiga z2ram, which is really similar and impossible on Atari,
--- linux/drivers/char/atarimouse.c.~1~	Wed Aug 26 18:40:23 1998
+++ linux/drivers/char/atarimouse.c	Fri May 14 19:01:00 1999
@@ -168,7 +168,7 @@
 
 	mouse.active = 0;
 	mouse.ready = 0;
-	mouse.wait = NULL;
+	init_waitqueue_head(&mouse.wait);
 
 	r = misc_register(&atari_mouse);
 	if (r)
--- linux/drivers/char/m68kserial.c.~1~	Wed May 12 17:53:16 1999
+++ linux/drivers/char/m68kserial.c	Fri May 14 19:05:53 1999
@@ -245,7 +245,7 @@
  * memory if large numbers of serial ports are open.
  */
 static unsigned char *tmp_buf = 0;
-static struct semaphore tmp_buf_sem = MUTEX;
+static DECLARE_MUTEX(tmp_buf_sem);
 
 static inline int serial_paranoia_check(struct m68k_async_struct *info,
 					kdev_t device, const char *routine)
@@ -1043,7 +1043,7 @@
 static int block_til_ready(struct tty_struct *tty, struct file * filp,
 			   struct m68k_async_struct *info)
 {
-	struct wait_queue wait = { current, NULL };
+	DECLARE_WAITQUEUE(wait, current);
 	int		retval;
 	int		do_clocal = 0;
 	unsigned long flags;
@@ -1456,9 +1456,9 @@
 		info->tqueue.data = info;
 		info->callout_termios =callout_driver.init_termios;
 		info->normal_termios = serial_driver.init_termios;
-		info->open_wait = 0;
-		info->close_wait = 0;
-		info->delta_msr_wait = 0;
+		init_waitqueue_head(&info->open_wait);
+		init_waitqueue_head(&info->close_wait);
+		init_waitqueue_head(&info->delta_msr_wait);
 		info->icount.cts = info->icount.dsr = 0;
 		info->icount.rng = info->icount.dcd = 0;
 		info->icount.rx = info->icount.tx = 0;
--- linux/include/asm-m68k/atari_joystick.h.~1~	Wed Apr 24 18:17:15 1996
+++ linux/include/asm-m68k/atari_joystick.h	Fri May 14 19:51:39 1999
@@ -16,7 +16,7 @@
 	char		dir;
 	int		ready;
 	int		active;
-	struct wait_queue *wait;
+	wait_queue_head_t wait;
 };
 
 #endif
--- linux/include/asm-m68k/m68kserial.h.~1~	Sun Apr 25 03:40:46 1999
+++ linux/include/asm-m68k/m68kserial.h	Fri May 14 19:35:12 1999
@@ -244,9 +244,9 @@
 	struct tq_struct	tqueue;
 	struct termios		normal_termios;
 	struct termios		callout_termios;
-	struct wait_queue	*open_wait;
-	struct wait_queue	*close_wait;
-	struct wait_queue	*delta_msr_wait;
+	wait_queue_head_t	open_wait;
+	wait_queue_head_t	close_wait;
+	wait_queue_head_t	delta_msr_wait;
 	struct async_icount	icount;	/* kernel counters for the 4 input interrupts */
 	struct m68k_async_struct	*next_port; /* For the linked list */
 	struct m68k_async_struct	*prev_port;
--- linux/include/asm-m68k/semaphore.h	Fri May 14 18:20:28 1999
+++ linux/include/asm/semaphore.h	Sat May 15 16:49:48 1999
@@ -2,6 +2,7 @@
 #define _M68K_SEMAPHORE_H
 
 #include <linux/linkage.h>
+#include <linux/wait.h>
 
 #include <asm/system.h>
 #include <asm/atomic.h>
@@ -18,12 +19,47 @@
 struct semaphore {
 	atomic_t count;
 	atomic_t waking;
-	struct wait_queue * wait;
+	wait_queue_head_t wait;
+#if WAITQUEUE_DEBUG
+	long __magic;
+#endif
 };
 
-#define MUTEX ((struct semaphore) { ATOMIC_INIT(1), ATOMIC_INIT(0), NULL })
-#define MUTEX_LOCKED ((struct semaphore) { ATOMIC_INIT(0), ATOMIC_INIT(0), NULL })
+#if WAITQUEUE_DEBUG
+# define __SEM_DEBUG_INIT(name) \
+		, (long)&(name).__magic
+#else
+# define __SEM_DEBUG_INIT(name)
+#endif
+
+#define __SEMAPHORE_INITIALIZER(name,count) \
+{ ATOMIC_INIT(count), ATOMIC_INIT(0), __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
+	__SEM_DEBUG_INIT(name) }
+
+#define __MUTEX_INITIALIZER(name) \
+	__SEMAPHORE_INITIALIZER(name,1)
 
+#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
+	struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
+
+#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
+#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
+
+extern inline void sema_init (struct semaphore *sem, int val)
+{
+	*sem = (struct semaphore)__SEMAPHORE_INITIALIZER(*sem, val);
+}
+
+static inline void init_MUTEX (struct semaphore *sem)
+{
+	sema_init(sem, 1);
+}
+
+static inline void init_MUTEX_LOCKED (struct semaphore *sem)
+{
+	sema_init(sem, 0);
+}
+
 asmlinkage void __down_failed(void /* special register calling convention */);
 asmlinkage int  __down_failed_interruptible(void  /* params in registers */);
 asmlinkage int  __down_failed_trylock(void  /* params in registers */);
@@ -34,8 +70,6 @@
 asmlinkage int  __down_trylock(struct semaphore * sem);
 asmlinkage void __up(struct semaphore * sem);
 
-#define sema_init(sem, val)	atomic_set(&((sem)->count), val)
-
 /*
  * This is ugly, but we want the default case to fall through.
  * "down_failed" is a special asm handler that calls the C
@@ -44,6 +78,11 @@
 extern inline void down(struct semaphore * sem)
 {
 	register struct semaphore *sem1 __asm__ ("%a1") = sem;
+
+#if WAITQUEUE_DEBUG
+	CHECK_MAGIC(sem->__magic);
+#endif
+
 	__asm__ __volatile__(
 		"| atomic down operation\n\t"
 		"subql #1,%0@\n\t"
@@ -64,6 +103,10 @@
 	register struct semaphore *sem1 __asm__ ("%a1") = sem;
 	register int result __asm__ ("%d0");
 
+#if WAITQUEUE_DEBUG
+	CHECK_MAGIC(sem->__magic);
+#endif
+
 	__asm__ __volatile__(
 		"| atomic interruptible down operation\n\t"
 		"subql #1,%1@\n\t"
@@ -86,6 +129,10 @@
 	register struct semaphore *sem1 __asm__ ("%a1") = sem;
 	register int result __asm__ ("%d0");
 
+#if WAITQUEUE_DEBUG
+	CHECK_MAGIC(sem->__magic);
+#endif
+
 	__asm__ __volatile__(
 		"| atomic down trylock operation\n\t"
 		"subql #1,%1@\n\t"
@@ -112,6 +159,11 @@
 extern inline void up(struct semaphore * sem)
 {
 	register struct semaphore *sem1 __asm__ ("%a1") = sem;
+
+#if WAITQUEUE_DEBUG
+	CHECK_MAGIC(sem->__magic);
+#endif
+
 	__asm__ __volatile__(
 		"| atomic up operation\n\t"
 		"addql #1,%0@\n\t"

-- 
Andreas Schwab                                      "And now for something
schwab@issan.cs.uni-dortmund.de                      completely different"
schwab@gnu.org

