[PATCH 094/103] USB: opticon: fix return value of tiocmset

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

 



Make sure we return 0 or a negative error number appropriate for
userspace on errors.

Currently 1 rather than 0 is returned on successful operation.

Signed-off-by: Johan Hovold <jhovold@xxxxxxxxx>
---
 drivers/usb/serial/opticon.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index e13e1a4..6af5bb8 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -120,7 +120,10 @@ static int send_control_msg(struct usb_serial_port *port, u8 requesttype,
 				0, 0, buffer, 1, 0);
 	kfree(buffer);
 
-	return retval;
+	if (retval < 0)
+		return retval;
+
+	return 0;
 }
 
 static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port)
@@ -329,10 +332,13 @@ static int opticon_tiocmset(struct tty_struct *tty,
 
 	/* Send the new RTS state to the connected device */
 	mutex_lock(&serial->disc_mutex);
-	if (!serial->disconnected)
+	if (!serial->disconnected) {
 		ret = send_control_msg(port, CONTROL_RTS, !rts);
-	else
+		if (ret)
+			ret = usb_translate_errors(ret);
+	} else {
 		ret = -ENODEV;
+	}
 	mutex_unlock(&serial->disc_mutex);
 
 	return ret;
-- 
1.8.1.1

--
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