public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: serial: Clean up the return values of read_reg and write_reg
@ 2017-11-27 15:36 Gimcuan Hui
  2017-11-28  8:47 ` Johan Hovold
  0 siblings, 1 reply; 3+ messages in thread
From: Gimcuan Hui @ 2017-11-27 15:36 UTC (permalink / raw)
  To: Johan Hovold; +Cc: gregkh, linux-usb, linux-kernel

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>
---
 drivers/usb/serial/ark3116.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 3c544782f60b..23d46ef87d64 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -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;
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] USB: serial: Clean up the return values of read_reg and write_reg
  2017-11-27 15:36 [PATCH] USB: serial: Clean up the return values of read_reg and write_reg Gimcuan Hui
@ 2017-11-28  8:47 ` Johan Hovold
  2017-11-28 11:25   ` Gimcuan Hui
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Hovold @ 2017-11-28  8:47 UTC (permalink / raw)
  To: Gimcuan Hui; +Cc: Johan Hovold, gregkh, linux-usb, linux-kernel

On Mon, Nov 27, 2017 at 03:36:51PM +0000, Gimcuan Hui wrote:
> 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>

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

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

Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] USB: serial: Clean up the return values of read_reg and write_reg
  2017-11-28  8:47 ` Johan Hovold
@ 2017-11-28 11:25   ` Gimcuan Hui
  0 siblings, 0 replies; 3+ messages in thread
From: Gimcuan Hui @ 2017-11-28 11:25 UTC (permalink / raw)
  To: Johan Hovold, linux-kernel

On 28 November 2017 at 08:47, Johan Hovold <johan@kernel.org> wrote:
> On Mon, Nov 27, 2017 at 03:36:51PM +0000, Gimcuan Hui wrote:
>> 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>
>
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-28 11:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-27 15:36 [PATCH] USB: serial: Clean up the return values of read_reg and write_reg Gimcuan Hui
2017-11-28  8:47 ` Johan Hovold
2017-11-28 11:25   ` Gimcuan Hui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox