USB: keyspan: pull in one indent level
Subsystems (3)
PATCH 1/2 USB: keyspan: pull in one indent level
We can remove the "if (urb->actual_length) {" check because checking for "while (i < urb->actual_length) {" is sufficient. This lets us pull the code in one indent level.
drivers/usb/serial/keyspan.c +33 -35
@@ -712,45 +712,43 @@ static void usa49wg_indat_callback(struct urb *urb) i =0 ; len =0 ; -if (urb->actual_length) { -while (i < urb->actual_length) { +while (i < urb->actual_length) { -/* Check port number from message*/ -if (data[i] >= serial->num_ports) { -dev_dbg (&urb->dev->dev,"%s - Unexpected port number %d\n" , - __func__, data[i]); -return ; - } - port = serial->port[data[i++]]; - len = data[i++]; +/* Check port number from message*/ +if (data[i] >= serial->num_ports) { +dev_dbg (&urb->dev->dev,"%s - Unexpected port number %d\n" , + __func__, data[i]); +return ; + } + port = serial->port[data[i++]]; + len = data[i++]; -/* 0x80 bit is error flag */ -if ((data[i] &0x80 ) =0 ) { -/* no error on any byte */ - i++; -for (x =1 ; x < len ; ++x) -tty_insert_flip_char (&port->port, - data[i++],0 ); - }else { -/* -* some bytes had errors, every byte has status -*/ -for (x =0 ; x +1 < len; x +=2 ) { -int stat = data[i], flag =0 ; -if (stat &RXERROR_OVERRUN ) - flag |=TTY_OVERRUN ; -if (stat &RXERROR_FRAMING ) - flag |=TTY_FRAME ; -if (stat &RXERROR_PARITY ) - flag |=TTY_PARITY ; -/* XXX should handle break (0x10) */ -tty_insert_flip_char (&port->port, - data[i+1 ], flag); - i +=2 ; - } +/* 0x80 bit is error flag */ +if ((data[i] &0x80 ) =0 ) { +/* no error on any byte */ + i++; +for (x =1 ; x < len ; ++x) +tty_insert_flip_char (&port->port, + data[i++],0 ); + }else { +/* +* some bytes had errors, every byte has status +*/ +for (x =0 ; x +1 < len; x +=2 ) { +int stat = data[i], flag =0 ; +if (stat &RXERROR_OVERRUN ) + flag |=TTY_OVERRUN ; +if (stat &RXERROR_FRAMING ) + flag |=TTY_FRAME ; +if (stat &RXERROR_PARITY ) + flag |=TTY_PARITY ; +/* XXX should handle break (0x10) */ +tty_insert_flip_char (&port->port, data[i+1 ], + flag); + i +=2 ; } -tty_flip_buffer_push (&port->port); } +tty_flip_buffer_push (&port->port); }/* Resubmit urb so we continue receiving */
Hello.
Quoted 17 lines · Dan Carpenter
We can remove the "if (
urb->actual_length) {" check because checking for "while (i <urb->actual_length) {" is sufficient. This lets us pull the code in one indent level.Signed-off-by Dan Carpenter <[email protected]>drivers/usb/serial/keyspan.c +1
-2@@ -712,45 +712,43 @@ static void usa49wg_indat_callback(struct urb *urb) i =0 ; len =0 ; -if (urb->actual_length) { -while (i < urb->actual_length) { +while (i < urb->actual_length) {
drivers/usb/serial/keyspan.c static void usa49wg_indat_callback(struct urb *urb) · line 717
Quoted 10 lines
drivers/usb/serial/keyspan.c +1
-8-/* Check port number from message*/ -if (data[i] >= serial->num_ports) { -dev_dbg (&urb->dev->dev,"%s - Unexpected port number %d\n" , - __func__, data[i]); -return ; - } - port = serial->port[data[i++]]; - len = data[i++]; +/* Check port number from message*/
Minor nit. Could you add a space before '*/'?
Quoted 35 lines
drivers/usb/serial/keyspan.c +10
-24+if (data[i] >= serial->num_ports) { +dev_dbg (&urb->dev->dev,"%s - Unexpected port number %d\n" , + __func__, data[i]); +return ; + } + port = serial->port[data[i++]]; + len = data[i++]; -/* 0x80 bit is error flag */ -if ((data[i] &0x80 ) =0 ) { -/* no error on any byte */ - i++; -for (x =1 ; x < len ; ++x) -tty_insert_flip_char (&port->port, - data[i++],0 ); - }else { -/* -* some bytes had errors, every byte has status -*/ -for (x =0 ; x +1 < len; x +=2 ) { -int stat = data[i], flag =0 ; -if (stat &RXERROR_OVERRUN ) - flag |=TTY_OVERRUN ; -if (stat &RXERROR_FRAMING ) - flag |=TTY_FRAME ; -if (stat &RXERROR_PARITY ) - flag |=TTY_PARITY ; -/* XXX should handle break (0x10) */ -tty_insert_flip_char (&port->port, - data[i+1 ], flag); - i +=2 ; - } +/* 0x80 bit is error flag */ +if ((data[i] &0x80 ) =0 ) { +/* no error on any byte */
drivers/usb/serial/keyspan.c static void usa49wg_indat_callback(struct urb *urb) · line 738
Quoted 10 lines
drivers/usb/serial/keyspan.c +10
-0+ i++; +for (x =1 ; x < len ; ++x) +tty_insert_flip_char (&port->port, + data[i++],0 ); + }else { +/* +* some bytes had errors, every byte has status +*/ +for (x =0 ; x +1 < len; x +=2 ) { +int stat = data[i], flag =0 ;
Empty line wouldn't hurt here.
drivers/usb/serial/keyspan.c static void usa49wg_indat_callback(struct urb *urb) · line 749
Quoted 11 lines
drivers/usb/serial/keyspan.c +10
-0+if (stat &RXERROR_OVERRUN ) + flag |=TTY_OVERRUN ; +if (stat &RXERROR_FRAMING ) + flag |=TTY_FRAME ; +if (stat &RXERROR_PARITY ) + flag |=TTY_PARITY ; +/* XXX should handle break (0x10) */ +tty_insert_flip_char (&port->port, data[i+1 ], + flag); + i +=2 ; }
WBR, Sergei