Re: Resetting USB modems and USB to serial converters increases ttyUSBXX counter

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

 



On Tue, 20 Oct 2015, Bin Liu wrote:

> Hi,
> 
> On Tue, Oct 20, 2015 at 11:57 AM, Peter Stuge <peter@xxxxxxxx> wrote:
> > Greg K-H wrote:
> >> >> Userspace still has the port open, so the number is not reused until
> >> >> userspace closes the device node.  Fix your userspace programs to
> >> >> properly listen to the hangup signal to know to release the device
> >> >node
> >> >> and you should be fine.
> >> >
> >> >There's still a bit of a race condition here, isn't there?
> >> >
> >> >Is there any good way to deal with that?

Yes, there is a race condition.  If the program closes the device node 
before the device is plugged in again, the ttyUSB number won't change; 
otherwise it will.  No, there is no good way to deal with this.

The good news is that it doesn't matter.  Provided the programs are 
written to release the device nodes properly, the numbers won't 
increase indefinitely the way Erwin described:

	Program opens /dev/ttyUSB0
	Device is unplugged
	Device is plugged in again and is assigned to /dev/ttyUSB1
	Program closes the ttyUSB0 device node

	Program opens /dev/ttyUSB1
	Device is unplugged
	Device is plugged in again and is assigned to /dev/ttyUSB0
		(which is now available)
	Program closes the ttyUSB1 device node

	Program opens /dev/ttyUSB0 ...

Alan Stern

--
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