Kaynağa Gözat

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

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.

Signed-off-by: Gimcuan Hui <gimcuan@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Gimcuan Hui 7 yıl önce
ebeveyn
işleme
d8a42b1ff8
1 değiştirilmiş dosya ile 7 ekleme ve 4 silme
  1. 7 4
      drivers/usb/serial/ark3116.c

+ 7 - 4
drivers/usb/serial/ark3116.c

@@ -83,7 +83,10 @@ static int ark3116_write_reg(struct usb_serial *serial,
 				 usb_sndctrlpipe(serial->dev, 0),
 				 usb_sndctrlpipe(serial->dev, 0),
 				 0xfe, 0x40, val, reg,
 				 0xfe, 0x40, val, reg,
 				 NULL, 0, ARK_TIMEOUT);
 				 NULL, 0, ARK_TIMEOUT);
-	return result;
+	if (result)
+		return result;
+
+	return 0;
 }
 }
 
 
 static int ark3116_read_reg(struct usb_serial *serial,
 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 result;
 	}
 	}
 
 
-	return buf[0];
+	return 0;
 }
 }
 
 
 static inline int calc_divisor(int bps)
 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 */
 	/* read modem status */
 	result = ark3116_read_reg(serial, UART_MSR, buf);
 	result = ark3116_read_reg(serial, UART_MSR, buf);
-	if (result < 0)
+	if (result)
 		goto err_close;
 		goto err_close;
 	priv->msr = *buf;
 	priv->msr = *buf;
 
 
 	/* read line status */
 	/* read line status */
 	result = ark3116_read_reg(serial, UART_LSR, buf);
 	result = ark3116_read_reg(serial, UART_LSR, buf);
-	if (result < 0)
+	if (result)
 		goto err_close;
 		goto err_close;
 	priv->lsr = *buf;
 	priv->lsr = *buf;