patch-2.4.7 linux/drivers/usb/acm.c

Next file: linux/drivers/usb/bluetooth.c
Previous file: linux/drivers/sound/ymfpci.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.6/linux/drivers/usb/acm.c linux/drivers/usb/acm.c
@@ -1,5 +1,5 @@
 /*
- * acm.c  Version 0.18
+ * acm.c  Version 0.19
  *
  * Copyright (c) 1999 Armin Fuerst	<fuerst@in.tum.de>
  * Copyright (c) 1999 Pavel Machek	<pavel@suse.cz>
@@ -21,6 +21,7 @@
  *	v0.16 - added code for modems with swapped data and control interfaces
  *	v0.17 - added new style probing
  *	v0.18 - fixed new style probing for devices with more configurations
+ *	v0.19 - fixed CLOCAL handling (thanks to Richard Shih-Ping Chan)
  */
 
 /*
@@ -51,6 +52,7 @@
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
+#include <linux/smp_lock.h>
 #undef DEBUG
 #include <linux/usb.h>
 
@@ -202,13 +204,10 @@
 
 			newctrl = le16_to_cpup((__u16 *) data);
 
-#if 0
-			/* Please someone tell me how to do this properly to kill pppd and not kill minicom */
 			if (acm->tty && !acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
 				dbg("calling hangup");
 				tty_hangup(acm->tty);
 			}
-#endif
 
 			acm->ctrlin = newctrl;
 
@@ -305,7 +304,14 @@
 
 	MOD_INC_USE_COUNT;
 
-	if (acm->used++) return 0;
+        lock_kernel();
+
+	if (acm->used++) {
+                unlock_kernel();
+                return 0;
+        }
+
+        unlock_kernel();
 
 	acm->ctrlurb.dev = acm->dev;
 	if (usb_submit_urb(&acm->ctrlurb))
@@ -410,7 +416,7 @@
 static int acm_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
 {
 	struct acm *acm = tty->driver_data;
-	unsigned int retval, mask, newctrl;
+	unsigned int mask, newctrl;
 
 	if (!ACM_READY(acm)) return -EINVAL;
 
@@ -429,7 +435,8 @@
 		case TIOCMBIS:
 		case TIOCMBIC:
 
-			if ((retval = get_user(mask, (unsigned long *) arg))) return retval;
+			if (get_user(mask, (unsigned long *) arg))
+				return -EFAULT;
 
 			newctrl = acm->ctrlout;
 			mask = (mask & TIOCM_DTR ? ACM_CTRL_DTR : 0) | (mask & TIOCM_RTS ? ACM_CTRL_RTS : 0);
@@ -475,7 +482,7 @@
 		(termios->c_cflag & PARODD ? 1 : 2) + (termios->c_cflag & CMSPAR ? 2 : 0) : 0;
 	newline.databits = acm_tty_size[(termios->c_cflag & CSIZE) >> 4];
 
-	acm->clocal = termios->c_cflag & CLOCAL;
+	acm->clocal = ((termios->c_cflag & CLOCAL) != 0);
 
 	if (!newline.speed) {
 		newline.speed = acm->line.speed;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)