Skip to contentSkip to conversation

USB: serial: Clean up the return values of read_reg and write_reg

PATCH In review Gimcuan Hui 2 participants 3 messages Nov 27, 2017 – Nov 28, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: serial: Clean up the return values of read_reg and write_reg

write_reg returns 0 on success, we can make it more explicit by returning number 0 instead of result variable.

read_reg should return 0 on success since this is a more common pattern.

The user of read_reg has been clean-up and should be at the same commit.

---
 drivers/usb/serial/ark3116.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/usb/serial/ark3116.c +7 -4
index 3c544782f60b..23d46ef87d64 100644
@@ -83,7 +83,10 @@ static int ark3116_write_reg(struct usb_serial *serial,
 				 usb_sndctrlpipe(serial->dev, 0),
 				 0xfe, 0x40, val, reg,
 				 NULL, 0, ARK_TIMEOUT);
-	return result;
+	if (result)
+		return result;
+
+	return 0;
 }
 
 static int ark3116_read_reg(struct usb_serial *serial,
@@ -105,7 +108,7 @@ static int ark3116_read_reg(struct usb_serial *serial,
 		return result;
 	}
 
-	return buf[0];
+	return 0;
 }
 
 static inline int calc_divisor(int bps)
@@ -355,13 +358,13 @@ static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port)
 
 	/* read modem status */
 	result = ark3116_read_reg(serial, UART_MSR, buf);
-	if (result < 0)
+	if (result)
 		goto err_close;
 	priv->msr = *buf;
 
 	/* read line status */
 	result = ark3116_read_reg(serial, UART_LSR, buf);
-	if (result < 0)
+	if (result)
 		goto err_close;
 	priv->lsr = *buf;
 
Signature · 1 line
2.11.0
maintainer
#1 lore raw
Quoted 8 lines · Gimcuan Hui

write_reg returns 0 on success, we can make it more explicit by returning number 0 instead of result variable.

read_reg should return 0 on success since this is a more common pattern.

The user of read_reg has been clean-up and should be at the same commit.

Thanks for the update. Now applied for -next with a slightly modified summary:

USB: serial: ark3116: clean up return values of register accessors

Johan

#2 lore raw
Quoted 8 lines · Johan Hovold
Quoted 7 lines · Gimcuan Hui

write_reg returns 0 on success, we can make it more explicit by returning number 0 instead of result variable.

read_reg should return 0 on success since this is a more common pattern.

The user of read_reg has been clean-up and should be at the same commit.

Quoted 8 lines
Quoted 1 line

Thanks for the update. Now applied for -next with a slightly modified summary:

USB: serial: ark3116: clean up return values of register accessors

Johan

:)

gimcuan