linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: gdm724x: Fix alignment in gdm_mux
@ 2019-03-09 17:56 Ignacio Losiggio
  2019-03-17 11:23 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Ignacio Losiggio @ 2019-03-09 17:56 UTC (permalink / raw)
  To: gregkh, devel, linux-kernel; +Cc: Ignacio Losiggio, Ignacio Losiggio

This patch modifies the alignment and linebreaks in gdm_mux in order to make
the code more concise.

Signed-off-by: Ignacio Losiggio <iglosiggio@dc.uba.ar>
---
 drivers/staging/gdm724x/gdm_mux.c | 35 ++++++++++++++-----------------
 drivers/staging/gdm724x/gdm_mux.h |  2 +-
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c
index e2a050ba6fbb..be13de12ce9f 100644
--- a/drivers/staging/gdm724x/gdm_mux.c
+++ b/drivers/staging/gdm724x/gdm_mux.c
@@ -164,8 +164,7 @@ static int up_to_host(struct mux_rx *r)
 
 		total_len = ALIGN(MUX_HEADER_SIZE + payload_size, 4);
 
-		if (len - packet_size_sum <
-			total_len) {
+		if (len - packet_size_sum < total_len) {
 			pr_err("invalid payload : %d %d %04x\n",
 			       payload_size, len, packet_type);
 			break;
@@ -178,11 +177,10 @@ static int up_to_host(struct mux_rx *r)
 		}
 
 		ret = r->callback(mux_header->data,
-				payload_size,
-				index,
-				mux_dev->tty_dev,
-				RECV_PACKET_PROCESS_CONTINUE
-				);
+		                  payload_size,
+				  index,
+				  mux_dev->tty_dev,
+				  RECV_PACKET_PROCESS_CONTINUE);
 		if (ret == TO_HOST_BUFFER_REQUEST_FAIL) {
 			r->offset += packet_size_sum;
 			break;
@@ -191,11 +189,10 @@ static int up_to_host(struct mux_rx *r)
 		packet_size_sum += total_len;
 		if (len - packet_size_sum <= MUX_HEADER_SIZE + 2) {
 			ret = r->callback(NULL,
-					0,
-					index,
-					mux_dev->tty_dev,
-					RECV_PACKET_PROCESS_COMPLETE
-					);
+					  0,
+					  index,
+					  mux_dev->tty_dev,
+					  RECV_PACKET_PROCESS_COMPLETE);
 			break;
 		}
 	}
@@ -376,8 +373,8 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index,
 	mux_header->packet_type = __cpu_to_le16(packet_type[tty_index]);
 
 	memcpy(t->buf + MUX_HEADER_SIZE, data, len);
-	memset(t->buf + MUX_HEADER_SIZE + len, 0, total_len - MUX_HEADER_SIZE -
-	       len);
+	memset(t->buf + MUX_HEADER_SIZE + len, 0,
+	       total_len - MUX_HEADER_SIZE - len);
 
 	t->len = total_len;
 	t->callback = cb;
@@ -418,8 +415,7 @@ static int gdm_mux_send_control(void *priv_dev, int request, int value,
 			      2,
 			      buf,
 			      len,
-			      5000
-			     );
+			      5000);
 
 	if (ret < 0)
 		pr_err("usb_control_msg error: %d\n", ret);
@@ -429,9 +425,10 @@ static int gdm_mux_send_control(void *priv_dev, int request, int value,
 
 static void release_usb(struct mux_dev *mux_dev)
 {
-	struct rx_cxt		*rx = &mux_dev->rx;
-	struct mux_rx		*r, *r_next;
-	unsigned long		flags;
+	struct rx_cxt *rx = &mux_dev->rx;
+	struct mux_rx *r;
+	struct mux_rx *r_next;
+	unsigned long flags;
 
 	cancel_delayed_work(&mux_dev->work_rx);
 
diff --git a/drivers/staging/gdm724x/gdm_mux.h b/drivers/staging/gdm724x/gdm_mux.h
index 51c22e3d8aeb..5bfb95be3ed3 100644
--- a/drivers/staging/gdm724x/gdm_mux.h
+++ b/drivers/staging/gdm724x/gdm_mux.h
@@ -13,7 +13,7 @@
 #define PM_NORMAL 0
 #define PM_SUSPEND 1
 
-#define USB_RT_ACM          (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
+#define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
 
 #define START_FLAG 0xA512485A
 #define MUX_HEADER_SIZE 14
-- 
2.21.0


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

* Re: [PATCH] staging: gdm724x: Fix alignment in gdm_mux
  2019-03-09 17:56 [PATCH] staging: gdm724x: Fix alignment in gdm_mux Ignacio Losiggio
@ 2019-03-17 11:23 ` Greg KH
  2019-03-18  0:46   ` Ignacio Losiggio
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2019-03-17 11:23 UTC (permalink / raw)
  To: Ignacio Losiggio; +Cc: devel, linux-kernel, Ignacio Losiggio

On Sat, Mar 09, 2019 at 02:56:14PM -0300, Ignacio Losiggio wrote:
> This patch modifies the alignment and linebreaks in gdm_mux in order to make
> the code more concise.

"concise"?

For some of these, there is no real change needed, it's all up to the
author's "taste", so they are not needed.

> 
> Signed-off-by: Ignacio Losiggio <iglosiggio@dc.uba.ar>
> ---
>  drivers/staging/gdm724x/gdm_mux.c | 35 ++++++++++++++-----------------
>  drivers/staging/gdm724x/gdm_mux.h |  2 +-
>  2 files changed, 17 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c
> index e2a050ba6fbb..be13de12ce9f 100644
> --- a/drivers/staging/gdm724x/gdm_mux.c
> +++ b/drivers/staging/gdm724x/gdm_mux.c
> @@ -164,8 +164,7 @@ static int up_to_host(struct mux_rx *r)
>  
>  		total_len = ALIGN(MUX_HEADER_SIZE + payload_size, 4);
>  
> -		if (len - packet_size_sum <
> -			total_len) {
> +		if (len - packet_size_sum < total_len) {

This is good.

>  			pr_err("invalid payload : %d %d %04x\n",
>  			       payload_size, len, packet_type);
>  			break;
> @@ -178,11 +177,10 @@ static int up_to_host(struct mux_rx *r)
>  		}
>  
>  		ret = r->callback(mux_header->data,
> -				payload_size,
> -				index,
> -				mux_dev->tty_dev,
> -				RECV_PACKET_PROCESS_CONTINUE
> -				);
> +		                  payload_size,
> +				  index,
> +				  mux_dev->tty_dev,
> +				  RECV_PACKET_PROCESS_CONTINUE);

Shouldn't you make some of these lines longer to make less lines?

>  		if (ret == TO_HOST_BUFFER_REQUEST_FAIL) {
>  			r->offset += packet_size_sum;
>  			break;
> @@ -191,11 +189,10 @@ static int up_to_host(struct mux_rx *r)
>  		packet_size_sum += total_len;
>  		if (len - packet_size_sum <= MUX_HEADER_SIZE + 2) {
>  			ret = r->callback(NULL,
> -					0,
> -					index,
> -					mux_dev->tty_dev,
> -					RECV_PACKET_PROCESS_COMPLETE
> -					);
> +					  0,
> +					  index,
> +					  mux_dev->tty_dev,
> +					  RECV_PACKET_PROCESS_COMPLETE);

Same here.

>  			break;
>  		}
>  	}
> @@ -376,8 +373,8 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index,
>  	mux_header->packet_type = __cpu_to_le16(packet_type[tty_index]);
>  
>  	memcpy(t->buf + MUX_HEADER_SIZE, data, len);
> -	memset(t->buf + MUX_HEADER_SIZE + len, 0, total_len - MUX_HEADER_SIZE -
> -	       len);
> +	memset(t->buf + MUX_HEADER_SIZE + len, 0,
> +	       total_len - MUX_HEADER_SIZE - len);

this is good.

>  
>  	t->len = total_len;
>  	t->callback = cb;
> @@ -418,8 +415,7 @@ static int gdm_mux_send_control(void *priv_dev, int request, int value,
>  			      2,
>  			      buf,
>  			      len,
> -			      5000
> -			     );
> +			      5000);

Again, you can shorten the number of lines needed here.

>  
>  	if (ret < 0)
>  		pr_err("usb_control_msg error: %d\n", ret);
> @@ -429,9 +425,10 @@ static int gdm_mux_send_control(void *priv_dev, int request, int value,
>  
>  static void release_usb(struct mux_dev *mux_dev)
>  {
> -	struct rx_cxt		*rx = &mux_dev->rx;
> -	struct mux_rx		*r, *r_next;
> -	unsigned long		flags;
> +	struct rx_cxt *rx = &mux_dev->rx;
> +	struct mux_rx *r;
> +	struct mux_rx *r_next;
> +	unsigned long flags;

No need to change this at all.

>  
>  	cancel_delayed_work(&mux_dev->work_rx);
>  
> diff --git a/drivers/staging/gdm724x/gdm_mux.h b/drivers/staging/gdm724x/gdm_mux.h
> index 51c22e3d8aeb..5bfb95be3ed3 100644
> --- a/drivers/staging/gdm724x/gdm_mux.h
> +++ b/drivers/staging/gdm724x/gdm_mux.h
> @@ -13,7 +13,7 @@
>  #define PM_NORMAL 0
>  #define PM_SUSPEND 1
>  
> -#define USB_RT_ACM          (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
> +#define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE)

No tab?

thanks,

greg k-h

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

* Re: [PATCH] staging: gdm724x: Fix alignment in gdm_mux
  2019-03-17 11:23 ` Greg KH
@ 2019-03-18  0:46   ` Ignacio Losiggio
  0 siblings, 0 replies; 3+ messages in thread
From: Ignacio Losiggio @ 2019-03-18  0:46 UTC (permalink / raw)
  To: devel; +Cc: linux-kernel

El dom, 17 de mar 2019 a las 8:23 AM, Greg KH 
<gregkh@linuxfoundation.org> escribió:
> For some of these, there is no real change needed, it's all up to the
> author's "taste", so they are not needed.

Thanks for the feedback! I will send a revised version.



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

end of thread, other threads:[~2019-03-18  0:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-09 17:56 [PATCH] staging: gdm724x: Fix alignment in gdm_mux Ignacio Losiggio
2019-03-17 11:23 ` Greg KH
2019-03-18  0:46   ` Ignacio Losiggio

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