patch-2.3.99-pre4 linux/drivers/usb/acm.c

Next file: linux/drivers/usb/audio.c
Previous file: linux/drivers/usb/Makefile
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre3/linux/drivers/usb/acm.c linux/drivers/usb/acm.c
@@ -52,6 +52,10 @@
 #define DEBUG
 #include <linux/usb.h>
 
+void tty_register_devfs (struct tty_driver *driver, unsigned int flags,
+			unsigned minor);
+void tty_unregister_devfs (struct tty_driver *driver, unsigned minor);
+
 /*
  * CMSPAR, some architectures can't have space and mark parity.
  */
@@ -143,6 +147,7 @@
 };
 
 static struct usb_driver acm_driver;
+static struct tty_driver acm_tty_driver;
 static struct acm *acm_table[ACM_TTY_MINORS] = { NULL, /* .... */ };
 
 #define ACM_READY(acm)	(acm && acm->dev && acm->used)
@@ -306,20 +311,19 @@
 
 	if (!acm || !acm->used) return;
 
-	MOD_DEC_USE_COUNT;
-
-	if (--acm->used) return;
-	
-	if (acm->dev) {
-		acm_set_control(acm, acm->ctrlout = 0);
-		usb_unlink_urb(&acm->ctrlurb);
-		usb_unlink_urb(&acm->writeurb);
-		usb_unlink_urb(&acm->readurb);
-		return;
+	if (!--acm->used) {
+		if (acm->dev) {
+			acm_set_control(acm, acm->ctrlout = 0);
+			usb_unlink_urb(&acm->ctrlurb);
+			usb_unlink_urb(&acm->writeurb);
+			usb_unlink_urb(&acm->readurb);
+		} else {
+			tty_unregister_devfs(&acm_tty_driver, acm->minor);
+			acm_table[acm->minor] = NULL;
+			kfree(acm);
+		}
 	}
-
-	acm_table[acm->minor] = NULL;
-	kfree(acm);
+	MOD_DEC_USE_COUNT;
 }
 
 static int acm_tty_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count)
@@ -572,6 +576,7 @@
 		usb_driver_claim_interface(&acm_driver, acm->iface + 0, acm);
 		usb_driver_claim_interface(&acm_driver, acm->iface + 1, acm);
 
+		tty_register_devfs(&acm_tty_driver, 0, minor);
 		return acm_table[minor] = acm;
 	}
 
@@ -599,6 +604,7 @@
 	usb_driver_release_interface(&acm_driver, acm->iface + 1);
 
 	if (!acm->used) {
+		tty_unregister_devfs(&acm_tty_driver, acm->minor);
 		acm_table[acm->minor] = NULL;
 		kfree(acm);
 		return;
@@ -630,14 +636,14 @@
 
 static struct tty_driver acm_tty_driver = {
 	magic:			TTY_DRIVER_MAGIC,
-	driver_name:		"usb",
-	name:			"ttyACM",
+	driver_name:		"acm",
+	name:			"usb/acm/%d",
 	major:			ACM_TTY_MAJOR,
 	minor_start:		0,
 	num:			ACM_TTY_MINORS,
 	type:			TTY_DRIVER_TYPE_SERIAL,
 	subtype:		SERIAL_TYPE_NORMAL,
-	flags:			TTY_DRIVER_REAL_RAW,
+	flags:			TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS,
 
 	refcount:		&acm_tty_refcount,
 

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