To: linux-m68k@lists.linux-m68k.org
Subject: L68K: Patch for 2.1.99
X-Yow: If elected, Zippy pledges to each and every American
 a 55-year-old houseboy...
From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Date: 05 May 1998 10:24:45 +0200
Sender: owner-linux-m68k@phil.uni-sb.de

A few fixes for 2.1.99:

- remove remaining uses of asm/atari_mouse.h
- update ataflop.c to use new mod_timer
- cleanup and bug fixes for lp_m68k.c and m68kserial.c
- update kernel/printk.c
- fix warning in filesystems.c

Andreas.

----------------------------------------------------------------------
--- arch/m68k/atari/atakeyb.c.~1~	Mon May  4 18:07:49 1998
+++ arch/m68k/atari/atakeyb.c	Tue May  5 01:35:07 1998
@@ -28,7 +28,6 @@
 #include <asm/atariints.h>
 #include <asm/atarihw.h>
 #include <asm/atarikb.h>
-#include <asm/atari_mouse.h>
 #include <asm/atari_joystick.h>
 #include <asm/irq.h>
 
--- arch/m68k/atari/joystick.c.~1~	Mon Mar 23 18:21:27 1998
+++ arch/m68k/atari/joystick.c	Fri Apr  3 19:06:28 1998
@@ -15,7 +15,6 @@
 
 #include <asm/atarikb.h>
 #include <asm/atari_joystick.h>
-#include <asm/atari_mouse.h>
 #include <asm/uaccess.h>
 
 #define MAJOR_NR    JOYSTICK_MAJOR
--- drivers/block/ataflop.c.~1~	Mon May  4 18:10:14 1998
+++ drivers/block/ataflop.c	Fri Mar 27 19:09:39 1998
@@ -344,16 +344,10 @@
 	} while(0)
 
 #define	START_TIMEOUT()						\
-    do {							\
-        del_timer( &timeout_timer );				\
-        timeout_timer.expires = jiffies + FLOPPY_TIMEOUT;	\
-        add_timer( &timeout_timer );				\
-	} while(0)
+    mod_timer(&timeout_timer, jiffies + FLOPPY_TIMEOUT)
 
 #define	STOP_TIMEOUT()						\
-    do {							\
-        del_timer( &timeout_timer );				\
-	} while(0)
+    del_timer(&timeout_timer)
 
 
 /*
--- drivers/char/lp_m68k.c.~1~	Wed Mar 18 19:45:22 1998
+++ drivers/char/lp_m68k.c	Fri Apr 10 07:30:07 1998
@@ -191,7 +191,9 @@
     lp_table[dev]->bytes_written = 0;	/* init buffer read-pointer */
     lp_error = 0;
     lp_table[dev]->copy_size = (count <= LP_BUFFER_SIZE ? count : LP_BUFFER_SIZE);
-    copy_from_user(lp_table[dev]->lp_buffer, buf, lp_table[dev]->copy_size);
+    if (copy_from_user(lp_table[dev]->lp_buffer, buf,
+		       lp_table[dev]->copy_size))
+      return -EFAULT;
     while (lp_table[dev]->copy_size) {
       save_flags(flags);
       cli();				/* no interrupts now */
@@ -224,10 +226,9 @@
       rc = total_bytes_written + lp_table[dev]->bytes_written;
 
       if (signal_pending(current)) {
-	if (rc)
-	  return rc;
-	else
-	  return -EINTR;
+	if (rc == 0)
+	  rc = -EINTR;
+	return rc;
       }
       if (lp_error) {
 
@@ -289,52 +290,53 @@
 
 	temp = buf;
 	while (count > 0) {
-		if (lp_char_polled(get_user(temp), dev)) {
+		int c;
+		if (get_user(c, temp))
+			return -EFAULT;
+		if (lp_char_polled(c, dev)) {
 			/* only update counting vars if character was printed */
 			count--; temp++;
 #ifdef LP_DEBUG
 			lp_total_chars++;
 #endif
 		} else { /* if printer timed out */
+			unsigned long timeout = LP_TIMEOUT_POLLED;
+			int error = 0;
 			if (lp_table[dev]->lp_has_pout(dev)) {
 				printk(KERN_NOTICE "lp%d: out of paper\n",dev);
 				if (lp_table[dev]->flags & LP_ABORT)
-					return temp - buf ? temp-buf : -ENOSPC;
-				current->state = TASK_INTERRUPTIBLE;
-				current->timeout = jiffies + LP_TIMEOUT_POLLED;
-				schedule();
+					error = -ENOSPC;
 			} else if (!lp_table[dev]->lp_is_online(dev)) {
 				printk(KERN_NOTICE "lp%d: off-line\n",dev);
 				if (lp_table[dev]->flags & LP_ABORT)
-					return temp - buf ? temp-buf : -EIO;
-				current->state = TASK_INTERRUPTIBLE;
-				current->timeout = jiffies + LP_TIMEOUT_POLLED;
-				schedule();
+					error = -EIO;
 			} else
 	                /* not offline or out of paper. on fire? */
 			if (lp_table[dev]->lp_is_busy(dev)) {
 				printk(KERN_NOTICE "lp%d: on fire\n",dev);
 				if (lp_table[dev]->flags & LP_ABORT)
-					return temp - buf ? temp-buf : -EFAULT;
-				current->state = TASK_INTERRUPTIBLE;
-				current->timeout = jiffies + LP_TIMEOUT_POLLED;
-				schedule();
+					error = -EIO;
 			}
+			else
+				timeout = lp_table[dev]->time;
 
 			/* check for signals before going to sleep */
-			if (signal_pending(current)) {
+			if (error == 0 && signal_pending(current))
+				error = -EINTR;
+			if (error) {
 				if (temp != buf)
 					return temp-buf;
 				else
-					return -EINTR;
+					return error;
 			}
+
 #ifdef LP_DEBUG
 			printk("lp sleeping at %d characters for %d jiffies\n",
-				lp_total_chars, lp_table[dev]->time);
+				lp_total_chars, timeout);
 			lp_total_chars = 0;
 #endif
 			current->state = TASK_INTERRUPTIBLE;
-			current->timeout = jiffies + lp_table[dev]->time;
+			current->timeout = jiffies + timeout;
 			schedule();
 		}
 	}
@@ -365,8 +367,12 @@
 	int dev = MINOR(inode->i_rdev);
 	int ret;
 
+	MOD_INC_USE_COUNT;
+
+	ret = -ENODEV;
 	if (dev >= MAX_LP)
-		return -ENODEV;
+		goto out_err;
+
 #ifdef CONFIG_KMOD
 	if (!lp_table[dev]) {
 		char modname[30];
@@ -376,22 +382,25 @@
 	}
 #endif
 	if (!lp_table[dev])
-		return -ENODEV;
+		goto out_err;
 	if (!(lp_table[dev]->flags & LP_EXIST))
-		return -ENODEV;
+		goto out_err;
+	ret = -EBUSY;
 	if (lp_table[dev]->flags & LP_BUSY)
-		return -EBUSY;
+		goto out_err;
 
 	lp_table[dev]->flags |= LP_BUSY;
 
 	ret = lp_table[dev]->lp_open(dev);
 	if (ret != 0) {
 		lp_table[dev]->flags &= ~LP_BUSY;
-	}
-	else {
-		MOD_INC_USE_COUNT;
+		goto out_err;
 	}
 	return ret;
+
+out_err:
+	MOD_DEC_USE_COUNT;
+	return ret;
 }
 
 static int lp_release(struct inode *inode, struct file *file)
@@ -409,15 +418,16 @@
 		    unsigned int cmd, unsigned long arg)
 {
 	unsigned int minor = MINOR(inode->i_rdev);
-	int retval = 0;
+	int retval = -ENODEV;
 
 #ifdef LP_DEBUG
 	printk("lp%d ioctl, cmd: 0x%x, arg: 0x%x\n", minor, cmd, arg);
 #endif
 	if (minor >= max_lp)
-		return -ENODEV;
+		goto out;
 	if (!(lp_table[minor]->flags & LP_EXIST))
-		return -ENODEV;
+		goto out;
+	retval = 0;
 	switch (cmd) {
 	case LPTIME:
 		lp_table[minor]->time = arg;
@@ -439,11 +449,11 @@
 	        retval = lp_irq;
 		break;
 	default:
+		retval = -EINVAL;
 		if (lp_table[minor]->lp_ioctl)
 			retval = lp_table[minor]->lp_ioctl(minor, cmd, arg);
-		else
-			retval = -EINVAL;
 	}
+out:
 	return retval;
 }
 
--- drivers/char/m68kserial.c.~1~	Fri Feb  6 20:27:04 1998
+++ drivers/char/m68kserial.c	Fri Apr  3 17:46:35 1998
@@ -1363,7 +1363,7 @@
 	 *	The interrupt of the serial console port
 	 *	can't be shared.
 	 */
-	if (sercons.flags & CON_FIRST) {
+	if (sercons.flags & CON_CONSDEV) {
 		for(i = 0; i < NR_PORTS; i++)
 			if (i != sercons.index &&
 			    rs_table[i].irq == rs_table[sercons.index].irq)
--- fs/filesystems.c.~1~	Mon May  4 18:17:22 1998
+++ fs/filesystems.c	Thu Apr  9 00:17:47 1998
@@ -41,6 +41,9 @@
 #ifdef CONFIG_CODA_FS
 extern int init_coda_fs(void);
 #endif
+#ifdef CONFIG_DEVPTS_FS
+extern int init_devpts_fs(void);
+#endif
 
 extern void device_setup(void);
 extern void binfmt_setup(void);
--- kernel/printk.c.~1~	Mon May  4 18:20:09 1998
+++ kernel/printk.c	Wed Apr 15 19:07:48 1998
@@ -341,10 +341,11 @@
 	if (preferred_console < 0) {
 		if (console->index < 0)
 			console->index = 0;
+		if (console->setup == NULL ||
+		    console->setup(console, NULL) == 0) {
 			console->flags |= CON_ENABLED | CON_CONSDEV;
 			preferred_console = 0;
- 		if (console->setup)
-			console->setup(console, NULL);
+		}
 	}
 
 	/*
@@ -359,13 +360,14 @@
 			continue;
 		if (console->index < 0)
 			console->index = console_cmdline[i].index;
- 		console->flags |= CON_ENABLED;
- 		console->index = console_cmdline[i].index;
+		if (console->setup &&
+		    console->setup(console, console_cmdline[i].options) != 0)
+			break;
+		console->flags |= CON_ENABLED;
+		console->index = console_cmdline[i].index;
 		if (i == preferred_console)
 			console->flags |= CON_CONSDEV;
- 		if (console->setup)
-			console->setup(console, console_cmdline[i].options);
- 		break;
+		break;
 	}
 
 	if (!(console->flags & CON_ENABLED))
