From 3827d8762febd68ff1b6db0bb5efa55bfbccaeb4 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 10 Nov 2011 17:38:13 +0100 Subject: [PATCH] USB: serial: do not forward USB specific errors in open Use usb_translate_errors() to map USB-specific errors to errors appropriate for user space (ENOMEM, ENODEV and EIO) in open. 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 --- drivers/usb/serial/usb-serial.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 8d5190f3d8eb..a2a0574b662a 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -260,6 +260,10 @@ static int serial_activate(struct tty_port *tport, struct tty_struct *tty) else retval = port->serial->type->open(tty, port); mutex_unlock(&serial->disc_mutex); + + if (retval < 0) + retval = usb_translate_errors(retval); + return retval; } -- 2.20.1