Some usbserial functions returns -EINVAL if the port doesn't exist or if
it's not opened. However, the right error code for such situations is
-ENODEV.

Signed-off-by: Luiz Fernando N. Capitulino <[EMAIL PROTECTED]>

---

 drivers/usb/serial/usb-serial.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

121a7a4d83af0f8e3a14b4b056b51963bef9f43a
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 9c36f0e..bea0486 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -274,7 +274,7 @@ static void serial_close(struct tty_stru
 static int serial_write (struct tty_struct * tty, const unsigned char *buf, 
int count)
 {
        struct usb_serial_port *port = tty->driver_data;
-       int retval = -EINVAL;
+       int retval = -ENODEV;
 
        if (!port)
                goto exit;
@@ -296,7 +296,7 @@ exit:
 static int serial_write_room (struct tty_struct *tty) 
 {
        struct usb_serial_port *port = tty->driver_data;
-       int retval = -EINVAL;
+       int retval = -ENODEV;
 
        if (!port)
                goto exit;
@@ -318,7 +318,7 @@ exit:
 static int serial_chars_in_buffer (struct tty_struct *tty) 
 {
        struct usb_serial_port *port = tty->driver_data;
-       int retval = -EINVAL;
+       int retval = -ENODEV;
 
        if (!port)
                goto exit;
@@ -488,19 +488,18 @@ static int serial_tiocmget (struct tty_s
        struct usb_serial_port *port = tty->driver_data;
 
        if (!port)
-               goto exit;
+               return -ENODEV;
 
        dbg("%s - port %d", __FUNCTION__, port->number);
 
        if (!port->open_count) {
                dbg("%s - port not open", __FUNCTION__);
-               goto exit;
+               return -ENODEV;
        }
 
        if (port->serial->type->tiocmget)
                return port->serial->type->tiocmget(port, file);
 
-exit:
        return -EINVAL;
 }
 
@@ -510,19 +509,18 @@ static int serial_tiocmset (struct tty_s
        struct usb_serial_port *port = tty->driver_data;
 
        if (!port)
-               goto exit;
+               return -ENODEV;
 
        dbg("%s - port %d", __FUNCTION__, port->number);
 
        if (!port->open_count) {
                dbg("%s - port not open", __FUNCTION__);
-               goto exit;
+               return -ENODEV;
        }
 
        if (port->serial->type->tiocmset)
                return port->serial->type->tiocmset(port, file, set, clear);
 
-exit:
        return -EINVAL;
 }
 
-- 
1.3.3



-- 
Luiz Fernando N. Capitulino


_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to