Hi,
Since last December me and Oliver are trying to
fix a number of problems in usb-serial.c.
Most of them happen when devices are plugged
and unplugged and files are opened and closed
in various orders.

usb-serial.c registers new tty ports by calling
device_register from usb_serial_probe routine,
which is called when a supported USB device is
plugged. Typically, the first such device 
is registered as ttyUSB0 and ttyUSB1.
If another device is plugged at the same time, 
then it will be registered as ttyUSB2-ttyUSB3, etc.

When device is unplugged and all files opened
to it's ports are closed, then destroy_serial
function is called, which calls device_unregister
on each port (like ttyUSB0 and ttyUSB1).

When the device is re-plugged, then it will
get the same ttyUSB0 and ttyUSB1 again.

Unfortunately, it is possible (and common)
for a device to be un-plugged and re-plugged
while an application still holds file ttyUSB0 opened.

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.

This is Oliver's opinion:
"
It seems to me that if we cannot guarantee that 
the devices are identical, we must make sure they 
have different numbers.
Consider the case of a multithreaded program
opening the same device multiple times.

However, this is not a question I alone should
decide. Please ask the full list.
"

Thank you
John


 
____________________________________________________________________________________
TV dinner still cooling? 
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/

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

Reply via email to