From: Johan Hovold Date: Thu, 10 Nov 2011 16:40:44 +0000 (+0100) Subject: USB: serial: do not forward USB specific errors in write X-Git-Tag: MMI-PSA29.97-13-9~17726^2~61 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c6249ff7521c0211e9daa37f07a4c016a5c4d454;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git USB: serial: do not forward USB specific errors in write 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 5c4fcf8d5f98..8c46813b9afa 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -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; }