linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] usb: serial: remove redundant conditions
@ 2015-12-11  9:46 Geyslan G. Bem
  2015-12-11  9:46 ` [PATCH 2/2] usb: serial: remove redundant condition Geyslan G. Bem
  2015-12-11 10:13 ` [PATCH 1/2] usb: serial: remove redundant conditions Johan Hovold
  0 siblings, 2 replies; 7+ messages in thread
From: Geyslan G. Bem @ 2015-12-11  9:46 UTC (permalink / raw)
  To: peter.senna
  Cc: Geyslan G. Bem, Johan Hovold, Greg Kroah-Hartman, linux-usb,
	linux-kernel

This patch removes redundant conditions.

 (!A || (A && B)) is the same as (!A || B).

Tested by compilation only.
Caught by cppcheck.

Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
---
 drivers/usb/serial/io_edgeport.c | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index c086697..f49327d 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -1046,9 +1046,8 @@ static void edge_close(struct usb_serial_port *port)
 
 	edge_port->closePending = true;
 
-	if ((!edge_serial->is_epic) ||
-	    ((edge_serial->is_epic) &&
-	     (edge_serial->epic_descriptor.Supports.IOSPChase))) {
+	if (!edge_serial->is_epic ||
+	    edge_serial->epic_descriptor.Supports.IOSPChase) {
 		/* flush and chase */
 		edge_port->chaseResponsePending = true;
 
@@ -1061,9 +1060,8 @@ static void edge_close(struct usb_serial_port *port)
 			edge_port->chaseResponsePending = false;
 	}
 
-	if ((!edge_serial->is_epic) ||
-	    ((edge_serial->is_epic) &&
-	     (edge_serial->epic_descriptor.Supports.IOSPClose))) {
+	if (!edge_serial->is_epic ||
+	    edge_serial->epic_descriptor.Supports.IOSPClose) {
 	       /* close the port */
 		dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CLOSE_PORT\n", __func__);
 		send_iosp_ext_cmd(edge_port, IOSP_CMD_CLOSE_PORT, 0);
@@ -1612,9 +1610,8 @@ static void edge_break(struct tty_struct *tty, int break_state)
 	struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial);
 	int status;
 
-	if ((!edge_serial->is_epic) ||
-	    ((edge_serial->is_epic) &&
-	     (edge_serial->epic_descriptor.Supports.IOSPChase))) {
+	if (!edge_serial->is_epic ||
+	    edge_serial->epic_descriptor.Supports.IOSPChase) {
 		/* flush and chase */
 		edge_port->chaseResponsePending = true;
 
@@ -1628,9 +1625,8 @@ static void edge_break(struct tty_struct *tty, int break_state)
 		}
 	}
 
-	if ((!edge_serial->is_epic) ||
-	    ((edge_serial->is_epic) &&
-	     (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) {
+	if (!edge_serial->is_epic ||
+	    edge_serial->epic_descriptor.Supports.IOSPSetClrBreak) {
 		if (break_state == -1) {
 			dev_dbg(&port->dev, "%s - Sending IOSP_CMD_SET_BREAK\n", __func__);
 			status = send_iosp_ext_cmd(edge_port,
@@ -2465,9 +2461,8 @@ static void change_port_settings(struct tty_struct *tty,
 		unsigned char stop_char  = STOP_CHAR(tty);
 		unsigned char start_char = START_CHAR(tty);
 
-		if ((!edge_serial->is_epic) ||
-		    ((edge_serial->is_epic) &&
-		     (edge_serial->epic_descriptor.Supports.IOSPSetXChar))) {
+		if (!edge_serial->is_epic ||
+		    edge_serial->epic_descriptor.Supports.IOSPSetXChar) {
 			send_iosp_ext_cmd(edge_port,
 					IOSP_CMD_SET_XON_CHAR, start_char);
 			send_iosp_ext_cmd(edge_port,
@@ -2494,13 +2489,11 @@ static void change_port_settings(struct tty_struct *tty,
 	}
 
 	/* Set flow control to the configured value */
-	if ((!edge_serial->is_epic) ||
-	    ((edge_serial->is_epic) &&
-	     (edge_serial->epic_descriptor.Supports.IOSPSetRxFlow)))
+	if (!edge_serial->is_epic ||
+	    edge_serial->epic_descriptor.Supports.IOSPSetRxFlow)
 		send_iosp_ext_cmd(edge_port, IOSP_CMD_SET_RX_FLOW, rxFlow);
-	if ((!edge_serial->is_epic) ||
-	    ((edge_serial->is_epic) &&
-	     (edge_serial->epic_descriptor.Supports.IOSPSetTxFlow)))
+	if (!edge_serial->is_epic ||
+	    edge_serial->epic_descriptor.Supports.IOSPSetTxFlow)
 		send_iosp_ext_cmd(edge_port, IOSP_CMD_SET_TX_FLOW, txFlow);
 
 
-- 
2.6.3


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

* [PATCH 2/2] usb: serial: remove redundant condition
  2015-12-11  9:46 [PATCH 1/2] usb: serial: remove redundant conditions Geyslan G. Bem
@ 2015-12-11  9:46 ` Geyslan G. Bem
  2015-12-11 12:30   ` Sergei Shtylyov
  2015-12-11 10:13 ` [PATCH 1/2] usb: serial: remove redundant conditions Johan Hovold
  1 sibling, 1 reply; 7+ messages in thread
From: Geyslan G. Bem @ 2015-12-11  9:46 UTC (permalink / raw)
  To: peter.senna
  Cc: Geyslan G. Bem, Johan Hovold, Greg Kroah-Hartman, linux-usb,
	linux-kernel

This patch removes redundant condition.

 (length && length > 5) can be reduced to a single evaluation.

Tested by compilation only.
Caught by cppcheck.

Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
---
 drivers/usb/serial/mos7840.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 8ac9b55..2c69bfc 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -635,7 +635,7 @@ static void mos7840_interrupt_callback(struct urb *urb)
 	 * Byte 4 IIR Port 4 (port.number is 3)
 	 * Byte 5 FIFO status for both */
 
-	if (length && length > 5) {
+	if (length > 5) {
 		dev_dbg(&urb->dev->dev, "%s", "Wrong data !!!\n");
 		return;
 	}
-- 
2.6.3


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

* Re: [PATCH 1/2] usb: serial: remove redundant conditions
  2015-12-11  9:46 [PATCH 1/2] usb: serial: remove redundant conditions Geyslan G. Bem
  2015-12-11  9:46 ` [PATCH 2/2] usb: serial: remove redundant condition Geyslan G. Bem
@ 2015-12-11 10:13 ` Johan Hovold
  2015-12-11 10:25   ` Geyslan G. Bem
  1 sibling, 1 reply; 7+ messages in thread
From: Johan Hovold @ 2015-12-11 10:13 UTC (permalink / raw)
  To: Geyslan G. Bem
  Cc: peter.senna, Johan Hovold, Greg Kroah-Hartman, linux-usb,
	linux-kernel

On Fri, Dec 11, 2015 at 06:46:41AM -0300, Geyslan G. Bem wrote:
> This patch removes redundant conditions.
> 
>  (!A || (A && B)) is the same as (!A || B).
> 
> Tested by compilation only.
> Caught by cppcheck.
> 
> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>

You forgot to update the commit summary (to include the driver name)
when splitting the original patch. I fixed that up and applied both for
next.

Thanks,
Johan

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

* Re: [PATCH 1/2] usb: serial: remove redundant conditions
  2015-12-11 10:13 ` [PATCH 1/2] usb: serial: remove redundant conditions Johan Hovold
@ 2015-12-11 10:25   ` Geyslan G. Bem
  2015-12-11 10:30     ` Johan Hovold
  0 siblings, 1 reply; 7+ messages in thread
From: Geyslan G. Bem @ 2015-12-11 10:25 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Peter Senna Tschudin, Greg Kroah-Hartman, linux-usb, LKML

2015-12-11 7:13 GMT-03:00 Johan Hovold <johan@kernel.org>:
> On Fri, Dec 11, 2015 at 06:46:41AM -0300, Geyslan G. Bem wrote:
>> This patch removes redundant conditions.
>>
>>  (!A || (A && B)) is the same as (!A || B).
>>
>> Tested by compilation only.
>> Caught by cppcheck.
>>
>> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
>
> You forgot to update the commit summary (to include the driver name)
> when splitting the original patch. I fixed that up and applied both for
> next.
Sorry. I got it: USB: mos7840: and USB: io_edgeport:.

I'm still getting the hang of it. :-)

Thank you for apply them.

>
> Thanks,
> Johan



-- 
Regards,

Geyslan G. Bem
hackingbits.com

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

* Re: [PATCH 1/2] usb: serial: remove redundant conditions
  2015-12-11 10:25   ` Geyslan G. Bem
@ 2015-12-11 10:30     ` Johan Hovold
  0 siblings, 0 replies; 7+ messages in thread
From: Johan Hovold @ 2015-12-11 10:30 UTC (permalink / raw)
  To: Geyslan G. Bem
  Cc: Johan Hovold, Peter Senna Tschudin, Greg Kroah-Hartman, linux-usb,
	LKML

On Fri, Dec 11, 2015 at 07:25:51AM -0300, Geyslan G. Bem wrote:
> 2015-12-11 7:13 GMT-03:00 Johan Hovold <johan@kernel.org>:
> > On Fri, Dec 11, 2015 at 06:46:41AM -0300, Geyslan G. Bem wrote:
> >> This patch removes redundant conditions.
> >>
> >>  (!A || (A && B)) is the same as (!A || B).
> >>
> >> Tested by compilation only.
> >> Caught by cppcheck.
> >>
> >> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
> >
> > You forgot to update the commit summary (to include the driver name)
> > when splitting the original patch. I fixed that up and applied both for
> > next.
> Sorry. I got it: USB: mos7840: and USB: io_edgeport:.
> 
> I'm still getting the hang of it. :-)

Looks like you got it. :)

> Thank you for apply them.

Thanks again for the patches.

Johan

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

* Re: [PATCH 2/2] usb: serial: remove redundant condition
  2015-12-11  9:46 ` [PATCH 2/2] usb: serial: remove redundant condition Geyslan G. Bem
@ 2015-12-11 12:30   ` Sergei Shtylyov
  2015-12-11 12:39     ` Geyslan G. Bem
  0 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2015-12-11 12:30 UTC (permalink / raw)
  To: Geyslan G. Bem, peter.senna
  Cc: Johan Hovold, Greg Kroah-Hartman, linux-usb, linux-kernel

Hello.

On 12/11/2015 12:46 PM, Geyslan G. Bem wrote:

    It's a bad idea to send 2 different patches with the same subject. I'd use 
"mos7840: " as a prefix in this case.

> This patch removes redundant condition.
>
>   (length && length > 5) can be reduced to a single evaluation.
>
> Tested by compilation only.
> Caught by cppcheck.
>
> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
[...]

MBR, Sergei


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

* Re: [PATCH 2/2] usb: serial: remove redundant condition
  2015-12-11 12:30   ` Sergei Shtylyov
@ 2015-12-11 12:39     ` Geyslan G. Bem
  0 siblings, 0 replies; 7+ messages in thread
From: Geyslan G. Bem @ 2015-12-11 12:39 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Peter Senna Tschudin, Johan Hovold, Greg Kroah-Hartman, linux-usb,
	LKML

2015-12-11 9:30 GMT-03:00 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>:
> Hello.
>
> On 12/11/2015 12:46 PM, Geyslan G. Bem wrote:
>
>    It's a bad idea to send 2 different patches with the same subject. I'd
> use "mos7840: " as a prefix in this case.
Sergei, tks for the advice. Johan already applied for next.


>
>> This patch removes redundant condition.
>>
>>   (length && length > 5) can be reduced to a single evaluation.
>>
>> Tested by compilation only.
>> Caught by cppcheck.
>>
>> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
>
> [...]
>
> MBR, Sergei
>



-- 
Regards,

Geyslan G. Bem
hackingbits.com

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

end of thread, other threads:[~2015-12-11 12:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-11  9:46 [PATCH 1/2] usb: serial: remove redundant conditions Geyslan G. Bem
2015-12-11  9:46 ` [PATCH 2/2] usb: serial: remove redundant condition Geyslan G. Bem
2015-12-11 12:30   ` Sergei Shtylyov
2015-12-11 12:39     ` Geyslan G. Bem
2015-12-11 10:13 ` [PATCH 1/2] usb: serial: remove redundant conditions Johan Hovold
2015-12-11 10:25   ` Geyslan G. Bem
2015-12-11 10:30     ` Johan Hovold

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