On Fri, 23 Mar 2007, Greg KH wrote: > On Fri, Mar 23, 2007 at 12:36:11PM -0700, John wrote: > > Here two solutions are possible: > > 1. Keep port range (ttyUSB0 and ttyUSB1 in this case) > > reserved until all files are closed. > > This is what the current code attempts to do. > > But this means that if the same device is re-plugged, > > it will be registered as ttyUSB2,ttyUSB3, > > even if it is the only connected device. > > I had seen applications (in embedded solutions), > > which had ttyUSB0 hardcoded because they expected > > only single USB peripheral at a time. > > Such applications will be broken by this approach. > > > > 2. Unregister ports in usb_serial_disconnect > > (by calling device_del). Mark such ports as > > dead, so all further calls to serial_* routines > > on these ports will fail (this was already > > implemented by Oliver's and my patches). > > Allow newly plugged devices to reuse the same > > ttyUSB0-ttyUSB1 range. Allow applications > > to open files to this new device. > > Allow applications to keep open files > > to long disappeared devices as long as they want - > > they will not interfere with new devices and > > newly opened files. > > > > Please, vote on #1 or #2. > > I say #1 as I implemented it :) > > If userspace still has the device node open, then we need to keep the > number still in use.
THe USB subsystem is inconsistent in the way it handles these things: New USB buses are assigned the lowest available bus number. If you remove bus 1 and then add a new bus, it will be called bus 1 no matter what device files may still be open for the old bus. New USB devices are assigned the next device address. If you unplug the device at address 2 and then plug it back in, it will be assigned address 3. Sysfs paths are based on physical port numbers, without regard to plugging and unplugging. I don't buy the argument about needing to keep the number in use merely because the device node is still open. Once the node has been unregistered it is no longer visible to userspace. Only the existing open file references can be used, and a new device node could be created using the same name without conflict. Regular files work like that. If a program has a file named "foo" open when you do "rm foo", the open file reference won't prevent you from creating a new file named "foo" in the same directory. There will be no conflict or confusion between the two files. Alan Stern ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel