linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net: usb: hso: use swap macro in hso_kick_transmit
@ 2018-07-12 19:43 Gustavo A. R. Silva
  2018-07-16 20:35 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2018-07-12 19:43 UTC (permalink / raw)
  To: David S. Miller; +Cc: linux-usb, netdev, linux-kernel, Gustavo A. R. Silva

Make use of the swap macro and remove unnecessary variable *temp*.
This makes the code easier to read and maintain. Also, slightly
refactor some code due to the removal of *temp*.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Changes in v2:
 - Check serial->tx_data instead of temp.

 drivers/net/usb/hso.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index de305ea..184c24b 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1732,7 +1732,6 @@ static int hso_serial_ioctl(struct tty_struct *tty,
 /* starts a transmit */
 static void hso_kick_transmit(struct hso_serial *serial)
 {
-	u8 *temp;
 	unsigned long flags;
 	int res;
 
@@ -1748,14 +1747,12 @@ static void hso_kick_transmit(struct hso_serial *serial)
 		goto out;
 
 	/* Switch pointers around to avoid memcpy */
-	temp = serial->tx_buffer;
-	serial->tx_buffer = serial->tx_data;
-	serial->tx_data = temp;
+	swap(serial->tx_buffer, serial->tx_data);
 	serial->tx_data_count = serial->tx_buffer_count;
 	serial->tx_buffer_count = 0;
 
-	/* If temp is set, it means we switched buffers */
-	if (temp && serial->write_data) {
+	/* If serial->tx_data is set, it means we switched buffers */
+	if (serial->tx_data && serial->write_data) {
 		res = serial->write_data(serial);
 		if (res >= 0)
 			serial->tx_urb_used = 1;
-- 
2.7.4


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

* Re: [PATCH v2] net: usb: hso: use swap macro in hso_kick_transmit
  2018-07-12 19:43 [PATCH v2] net: usb: hso: use swap macro in hso_kick_transmit Gustavo A. R. Silva
@ 2018-07-16 20:35 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-07-16 20:35 UTC (permalink / raw)
  To: gustavo; +Cc: linux-usb, netdev, linux-kernel

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Thu, 12 Jul 2018 14:43:20 -0500

> Make use of the swap macro and remove unnecessary variable *temp*.
> This makes the code easier to read and maintain. Also, slightly
> refactor some code due to the removal of *temp*.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Changes in v2:
>  - Check serial->tx_data instead of temp.

Applied to net-next.

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

end of thread, other threads:[~2018-07-16 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-12 19:43 [PATCH v2] net: usb: hso: use swap macro in hso_kick_transmit Gustavo A. R. Silva
2018-07-16 20:35 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).