error handling with usb serial open failures #2
Oliver Neukum <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Organization | Novell |
| Message-ID | <[email protected]> |
Hi,
this is the second attempt. What do you think?
Regards
Oliver
-----
--- a/drivers/usb/serial/usb-serial.c 2007-03-26 09:18:08.000000000 +0200
+++ b/drivers/usb/serial/usb-serial.c 2007-03-27 11:30:25.000000000 +0200
@@ -184,7 +184,7 @@
struct usb_serial *serial;
struct usb_serial_port *port;
unsigned int portNumber;
- int retval;
+ int retval = -ENODEV;
dbg("%s", __FUNCTION__);
@@ -192,13 +192,12 @@
serial = usb_serial_get_by_index(tty->index);
if (!serial) {
tty->driver_data = NULL;
- return -ENODEV;
+ goto trivial_error;
}
portNumber = tty->index - serial->minor;
port = serial->port[portNumber];
if (!port) {
- retval = -ENODEV;
goto bailout_kref_put;
}
@@ -243,6 +242,8 @@
mutex_unlock(&port->mutex);
bailout_kref_put:
usb_serial_put(serial);
+trivial_error:
+ port->cleaning_up = 1;
return retval;
}
@@ -255,6 +256,12 @@
dbg("%s - port %d", __FUNCTION__, port->number);
+ /*protected by BKL */
+ if (port->cleaning_up) {
+ port->cleaning_up = 0;
+ return;
+ }
+
mutex_lock(&port->mutex);
if (port->open_count == 0) {
--- a/include/linux/usb/serial.h 2007-03-26 09:23:20.000000000 +0200
+++ b/include/linux/usb/serial.h 2007-03-27 11:11:39.000000000 +0200
@@ -64,7 +64,7 @@
struct usb_serial * serial;
struct tty_struct * tty;
spinlock_t lock;
- struct mutex mutex;
+ struct mutex mutex;
unsigned char number;
unsigned char * interrupt_in_buffer;
@@ -92,6 +92,7 @@
int open_count;
char throttled;
char throttle_req;
+ char cleaning_up;
struct device dev;
};
#define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev)
-------------------------------------------------------------------------
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
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel