public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: serial: digi_acceleport: Improve readability and enhance error handling
@ 2024-09-22 11:17 amin-amani
  2024-09-22 14:56 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: amin-amani @ 2024-09-22 11:17 UTC (permalink / raw)
  To: johan; +Cc: gregkh, linux-usb, linux-kernel, A.Amani

From: "A.Amani" <didi1364@gmail.com>

- Improved coding style to adhere to kernel standards as suggested by
  checkpatch.pl.
- Indented case statements for baud rate and word size to improve code
  readability.
- Separated null checks for port, serial, and private data for clearer
  error handling.
- Improved error messages to better indicate which specific data (port,
  serial, or private) is null.
- No functional changes, only structural improvements and clearer
  debugging output.

Signed-off-by: A.Amani <didi1364@gmail.com>
---
 drivers/usb/serial/digi_acceleport.c | 105 +++++++++++++++++++--------
 1 file changed, 73 insertions(+), 32 deletions(-)

diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index d1dea3850576..da707967a0c4 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -685,25 +685,44 @@ static void digi_set_termios(struct tty_struct *tty,
 		}
 		switch (baud) {
 		/* drop DTR and RTS on transition to B0 */
-		case 0: digi_set_modem_signals(port, 0, 1); break;
-		case 50: arg = DIGI_BAUD_50; break;
-		case 75: arg = DIGI_BAUD_75; break;
-		case 110: arg = DIGI_BAUD_110; break;
-		case 150: arg = DIGI_BAUD_150; break;
-		case 200: arg = DIGI_BAUD_200; break;
-		case 300: arg = DIGI_BAUD_300; break;
-		case 600: arg = DIGI_BAUD_600; break;
-		case 1200: arg = DIGI_BAUD_1200; break;
-		case 1800: arg = DIGI_BAUD_1800; break;
-		case 2400: arg = DIGI_BAUD_2400; break;
-		case 4800: arg = DIGI_BAUD_4800; break;
-		case 9600: arg = DIGI_BAUD_9600; break;
-		case 19200: arg = DIGI_BAUD_19200; break;
-		case 38400: arg = DIGI_BAUD_38400; break;
-		case 57600: arg = DIGI_BAUD_57600; break;
-		case 115200: arg = DIGI_BAUD_115200; break;
-		case 230400: arg = DIGI_BAUD_230400; break;
-		case 460800: arg = DIGI_BAUD_460800; break;
+		case 0:
+			digi_set_modem_signals(port, 0, 1); break;
+		case 50:
+			arg = DIGI_BAUD_50; break;
+		case 75:
+			arg = DIGI_BAUD_75; break;
+		case 110:
+			arg = DIGI_BAUD_110; break;
+		case 150:
+			arg = DIGI_BAUD_150; break;
+		case 200:
+			arg = DIGI_BAUD_200; break;
+		case 300:
+			arg = DIGI_BAUD_300; break;
+		case 600:
+			arg = DIGI_BAUD_600; break;
+		case 1200:
+			arg = DIGI_BAUD_1200; break;
+		case 1800:
+			arg = DIGI_BAUD_1800; break;
+		case 2400:
+			arg = DIGI_BAUD_2400; break;
+		case 4800:
+			arg = DIGI_BAUD_4800; break;
+		case 9600:
+			arg = DIGI_BAUD_9600; break;
+		case 19200:
+			arg = DIGI_BAUD_19200; break;
+		case 38400:
+			arg = DIGI_BAUD_38400; break;
+		case 57600:
+			arg = DIGI_BAUD_57600; break;
+		case 115200:
+			arg = DIGI_BAUD_115200; break;
+		case 230400:
+			arg = DIGI_BAUD_230400; break;
+		case 460800:
+			arg = DIGI_BAUD_460800; break;
 		default:
 			arg = DIGI_BAUD_9600;
 			baud = 9600;
@@ -737,10 +756,14 @@ static void digi_set_termios(struct tty_struct *tty,
 	if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
 		arg = -1;
 		switch (cflag & CSIZE) {
-		case CS5: arg = DIGI_WORD_SIZE_5; break;
-		case CS6: arg = DIGI_WORD_SIZE_6; break;
-		case CS7: arg = DIGI_WORD_SIZE_7; break;
-		case CS8: arg = DIGI_WORD_SIZE_8; break;
+		case CS5:
+			arg = DIGI_WORD_SIZE_5; break;
+		case CS6:
+			arg = DIGI_WORD_SIZE_6; break;
+		case CS7:
+			arg = DIGI_WORD_SIZE_7; break;
+		case CS8:
+			arg = DIGI_WORD_SIZE_8; break;
 		default:
 			dev_dbg(dev,
 				"digi_set_termios: can't handle word size %d\n",
@@ -967,16 +990,30 @@ static void digi_write_bulk_callback(struct urb *urb)
 	int status = urb->status;
 	bool wakeup;
 
-	/* port and serial sanity check */
-	if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
-		pr_err("%s: port or port->private is NULL, status=%d\n",
+	/* port sanity check */
+	if (port == NULL) {
+		pr_err("%s: port is NULL, status=%d\n",
+			__func__, status);
+		return;
+	}
+	/* serial sanity check */
+	priv = usb_get_serial_port_data(port);
+	if (priv == NULL) {
+		pr_err("%s: port->private is NULL, status=%d\n",
 			__func__, status);
 		return;
 	}
 	serial = port->serial;
-	if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) {
+	if (serial == NULL) {
 		dev_err(&port->dev,
-			"%s: serial or serial->private is NULL, status=%d\n",
+			"%s: serial  is NULL, status=%d\n",
+			__func__, status);
+		return;
+	}
+	serial_priv = usb_get_serial_data(serial);
+	if (serial_priv == NULL) {
+		dev_err(&port->dev,
+			"%s: serial->private is NULL, status=%d\n",
 			__func__, status);
 		return;
 	}
@@ -1309,13 +1346,17 @@ static void digi_read_bulk_callback(struct urb *urb)
 			__func__, status);
 		return;
 	}
-	if (port->serial == NULL ||
-		(serial_priv = usb_get_serial_data(port->serial)) == NULL) {
-		dev_err(&port->dev, "%s: serial is bad or serial->private "
+	if (port->serial == NULL) {
+		dev_err(&port->dev, "%s: serial is bad,"
+			" status=%d\n", __func__, status);
+		return;
+	}
+	serial_priv = usb_get_serial_data(port->serial);
+	if (serial_priv == NULL) {
+		dev_err(&port->dev, "%s:serial->private "
 			"is NULL, status=%d\n", __func__, status);
 		return;
 	}
-
 	/* do not resubmit urb if it has any status error */
 	if (status) {
 		dev_err(&port->dev,
-- 
2.34.1


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

* Re: [PATCH] usb: serial: digi_acceleport: Improve readability and enhance error handling
  2024-09-22 11:17 [PATCH] usb: serial: digi_acceleport: Improve readability and enhance error handling amin-amani
@ 2024-09-22 14:56 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2024-09-22 14:56 UTC (permalink / raw)
  To: amin-amani; +Cc: johan, linux-usb, linux-kernel

On Sun, Sep 22, 2024 at 02:47:01PM +0330, amin-amani wrote:
> From: "A.Amani" <didi1364@gmail.com>
> 
> - Improved coding style to adhere to kernel standards as suggested by
>   checkpatch.pl.
> - Indented case statements for baud rate and word size to improve code
>   readability.
> - Separated null checks for port, serial, and private data for clearer
>   error handling.
> - Improved error messages to better indicate which specific data (port,
>   serial, or private) is null.
> - No functional changes, only structural improvements and clearer
>   debugging output.
> 
> Signed-off-by: A.Amani <didi1364@gmail.com>
> ---
>  drivers/usb/serial/digi_acceleport.c | 105 +++++++++++++++++++--------
>  1 file changed, 73 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
> index d1dea3850576..da707967a0c4 100644
> --- a/drivers/usb/serial/digi_acceleport.c
> +++ b/drivers/usb/serial/digi_acceleport.c
> @@ -685,25 +685,44 @@ static void digi_set_termios(struct tty_struct *tty,
>  		}
>  		switch (baud) {
>  		/* drop DTR and RTS on transition to B0 */
> -		case 0: digi_set_modem_signals(port, 0, 1); break;
> -		case 50: arg = DIGI_BAUD_50; break;
> -		case 75: arg = DIGI_BAUD_75; break;
> -		case 110: arg = DIGI_BAUD_110; break;
> -		case 150: arg = DIGI_BAUD_150; break;
> -		case 200: arg = DIGI_BAUD_200; break;
> -		case 300: arg = DIGI_BAUD_300; break;
> -		case 600: arg = DIGI_BAUD_600; break;
> -		case 1200: arg = DIGI_BAUD_1200; break;
> -		case 1800: arg = DIGI_BAUD_1800; break;
> -		case 2400: arg = DIGI_BAUD_2400; break;
> -		case 4800: arg = DIGI_BAUD_4800; break;
> -		case 9600: arg = DIGI_BAUD_9600; break;
> -		case 19200: arg = DIGI_BAUD_19200; break;
> -		case 38400: arg = DIGI_BAUD_38400; break;
> -		case 57600: arg = DIGI_BAUD_57600; break;
> -		case 115200: arg = DIGI_BAUD_115200; break;
> -		case 230400: arg = DIGI_BAUD_230400; break;
> -		case 460800: arg = DIGI_BAUD_460800; break;
> +		case 0:
> +			digi_set_modem_signals(port, 0, 1); break;
> +		case 50:
> +			arg = DIGI_BAUD_50; break;
> +		case 75:
> +			arg = DIGI_BAUD_75; break;
> +		case 110:
> +			arg = DIGI_BAUD_110; break;
> +		case 150:
> +			arg = DIGI_BAUD_150; break;
> +		case 200:
> +			arg = DIGI_BAUD_200; break;
> +		case 300:
> +			arg = DIGI_BAUD_300; break;
> +		case 600:
> +			arg = DIGI_BAUD_600; break;
> +		case 1200:
> +			arg = DIGI_BAUD_1200; break;
> +		case 1800:
> +			arg = DIGI_BAUD_1800; break;
> +		case 2400:
> +			arg = DIGI_BAUD_2400; break;
> +		case 4800:
> +			arg = DIGI_BAUD_4800; break;
> +		case 9600:
> +			arg = DIGI_BAUD_9600; break;
> +		case 19200:
> +			arg = DIGI_BAUD_19200; break;
> +		case 38400:
> +			arg = DIGI_BAUD_38400; break;
> +		case 57600:
> +			arg = DIGI_BAUD_57600; break;
> +		case 115200:
> +			arg = DIGI_BAUD_115200; break;
> +		case 230400:
> +			arg = DIGI_BAUD_230400; break;
> +		case 460800:
> +			arg = DIGI_BAUD_460800; break;
>  		default:
>  			arg = DIGI_BAUD_9600;
>  			baud = 9600;
> @@ -737,10 +756,14 @@ static void digi_set_termios(struct tty_struct *tty,
>  	if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
>  		arg = -1;
>  		switch (cflag & CSIZE) {
> -		case CS5: arg = DIGI_WORD_SIZE_5; break;
> -		case CS6: arg = DIGI_WORD_SIZE_6; break;
> -		case CS7: arg = DIGI_WORD_SIZE_7; break;
> -		case CS8: arg = DIGI_WORD_SIZE_8; break;
> +		case CS5:
> +			arg = DIGI_WORD_SIZE_5; break;
> +		case CS6:
> +			arg = DIGI_WORD_SIZE_6; break;
> +		case CS7:
> +			arg = DIGI_WORD_SIZE_7; break;
> +		case CS8:
> +			arg = DIGI_WORD_SIZE_8; break;
>  		default:
>  			dev_dbg(dev,
>  				"digi_set_termios: can't handle word size %d\n",
> @@ -967,16 +990,30 @@ static void digi_write_bulk_callback(struct urb *urb)
>  	int status = urb->status;
>  	bool wakeup;
>  
> -	/* port and serial sanity check */
> -	if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
> -		pr_err("%s: port or port->private is NULL, status=%d\n",
> +	/* port sanity check */
> +	if (port == NULL) {
> +		pr_err("%s: port is NULL, status=%d\n",
> +			__func__, status);
> +		return;
> +	}
> +	/* serial sanity check */
> +	priv = usb_get_serial_port_data(port);
> +	if (priv == NULL) {
> +		pr_err("%s: port->private is NULL, status=%d\n",
>  			__func__, status);
>  		return;
>  	}
>  	serial = port->serial;
> -	if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) {
> +	if (serial == NULL) {
>  		dev_err(&port->dev,
> -			"%s: serial or serial->private is NULL, status=%d\n",
> +			"%s: serial  is NULL, status=%d\n",
> +			__func__, status);
> +		return;
> +	}
> +	serial_priv = usb_get_serial_data(serial);
> +	if (serial_priv == NULL) {
> +		dev_err(&port->dev,
> +			"%s: serial->private is NULL, status=%d\n",
>  			__func__, status);
>  		return;
>  	}
> @@ -1309,13 +1346,17 @@ static void digi_read_bulk_callback(struct urb *urb)
>  			__func__, status);
>  		return;
>  	}
> -	if (port->serial == NULL ||
> -		(serial_priv = usb_get_serial_data(port->serial)) == NULL) {
> -		dev_err(&port->dev, "%s: serial is bad or serial->private "
> +	if (port->serial == NULL) {
> +		dev_err(&port->dev, "%s: serial is bad,"
> +			" status=%d\n", __func__, status);
> +		return;
> +	}
> +	serial_priv = usb_get_serial_data(port->serial);
> +	if (serial_priv == NULL) {
> +		dev_err(&port->dev, "%s:serial->private "
>  			"is NULL, status=%d\n", __func__, status);
>  		return;
>  	}
> -
>  	/* do not resubmit urb if it has any status error */
>  	if (status) {
>  		dev_err(&port->dev,
> -- 
> 2.34.1
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch did many different things all at once, making it difficult
  to review.  All Linux kernel patches need to only do one thing at a
  time.  If you need to do multiple things (such as clean up all coding
  style issues in a file/driver), do it in a sequence of patches, each
  one doing only one thing.  This will make it easier to review the
  patches to ensure that they are correct, and to help alleviate any
  merge issues that larger patches can cause.

- It looks like you did not use your "real" name for the patch on either
  the Signed-off-by: line, or the From: line (both of which have to
  match).  Please read the kernel file,
  Documentation/process/submitting-patches.rst for how to do this
  correctly.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

end of thread, other threads:[~2024-09-22 14:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-22 11:17 [PATCH] usb: serial: digi_acceleport: Improve readability and enhance error handling amin-amani
2024-09-22 14:56 ` Greg KH

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