[PATCH] usb-serial: don't let open files pin minor numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch (as1266) changes the way usb-serial manages its minor
numbers.  There's no need to retain a minor number after the device
has been disconnected, since the only thing the minor gets used for is
to determine which port corresponds to a device file during open().
(It also gets used in serial_proc_show, but we don't have to worry
about that.)

Returning minor numbers during serial_disconnect rather than
destroy_serial allows the numbers (and hence device node names) to be
reused even when a process is holding an unplugged device's file open.
This is what users expect to happen, and there's no reason not to do
it.

Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

---

Not intended for 2.6.31, although it could be merged immediately if 
there are no objections.


Index: usb-2.6/drivers/usb/serial/usb-serial.c
===================================================================
--- usb-2.6.orig/drivers/usb/serial/usb-serial.c
+++ usb-2.6/drivers/usb/serial/usb-serial.c
@@ -138,10 +138,6 @@ static void destroy_serial(struct kref *
 
 	dbg("%s - %s", __func__, serial->type->description);
 
-	/* return the minor range that this device had */
-	if (serial->minor != SERIAL_TTY_NO_MINOR)
-		return_serial(serial);
-
 	serial->type->release(serial);
 
 	for (i = 0; i < serial->num_ports; ++i) {
@@ -1157,6 +1153,10 @@ void usb_serial_disconnect(struct usb_in
 	}
 	serial->type->disconnect(serial);
 
+	/* return the minor range that this device had */
+	if (serial->minor != SERIAL_TTY_NO_MINOR)
+		return_serial(serial);
+
 	/* let the last holder of this object
 	 * cause it to be cleaned up */
 	usb_serial_put(serial);

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux