[PATCH 2/2] USB: serial: do not forward USB specific errors in write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 drivers/usb/serial/usb-serial.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 17f7533..08a33ba 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;
 }
-- 
1.7.7.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux