]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
USB: serial: do not forward USB specific errors in write
authorJohan Hovold <jhovold@gmail.com>
Thu, 10 Nov 2011 16:40:44 +0000 (17:40 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 15 Nov 2011 18:49:42 +0000 (10:49 -0800)
Use usb_translate_errors() to map USB-specific errors to errors
appropriate for user space (ENOMEM, ENODEV and EIO) in write.

Currently almost all serial drivers simply forward error codes from the
stack (e.g. from usb_submit_urb()), but these codes often have
different meanings in user-space. Doing the mapping in usb-serial core
simplifies driver code and allows for more consistent error reporting.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/serial/usb-serial.c

index 5c4fcf8d5f98db0efcf29870120e2779279189fa..8c46813b9afa276871c001f4ee236a1445c6032a 100644 (file)
@@ -364,6 +364,8 @@ static int serial_write(struct tty_struct *tty, const unsigned char *buf,
 
        /* pass on to the driver specific version of this function */
        retval = port->serial->type->write(tty, port, buf, count);
+       if (retval < 0)
+               retval = usb_translate_errors(retval);
 exit:
        return retval;
 }