All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] usb: serial: remove redundant conditions
@ 2015-12-10 20:50 Geyslan G. Bem
  2015-12-10 20:50 ` [PATCH 2/4] usb: gadget: remove redundant condition Geyslan G. Bem
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Geyslan G. Bem @ 2015-12-10 20:50 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).
 (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/io_edgeport.c | 35 ++++++++++++++---------------------
 drivers/usb/serial/mos7840.c     |  2 +-
 2 files changed, 15 insertions(+), 22 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);
 
 
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] 6+ messages in thread

* [PATCH 2/4] usb: gadget: remove redundant condition
  2015-12-10 20:50 [PATCH 1/4] usb: serial: remove redundant conditions Geyslan G. Bem
@ 2015-12-10 20:50 ` Geyslan G. Bem
  2015-12-10 20:50 ` [PATCH 3/4] usb: host: " Geyslan G. Bem
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Geyslan G. Bem @ 2015-12-10 20:50 UTC (permalink / raw)
  To: peter.senna
  Cc: Geyslan G. Bem, Felipe Balbi, Greg Kroah-Hartman, Robert Baldyga,
	linux-usb, linux-kernel

This patch removes redundant condition.

 (!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/gadget/udc/s3c-hsudc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c b/drivers/usb/gadget/udc/s3c-hsudc.c
index e9def42..82a9e2a 100644
--- a/drivers/usb/gadget/udc/s3c-hsudc.c
+++ b/drivers/usb/gadget/udc/s3c-hsudc.c
@@ -569,7 +569,7 @@ static int s3c_hsudc_handle_reqfeat(struct s3c_hsudc *hsudc,
 		hsep = &hsudc->ep[ep_num];
 		switch (le16_to_cpu(ctrl->wValue)) {
 		case USB_ENDPOINT_HALT:
-			if (set || (!set && !hsep->wedge))
+			if (set || !hsep->wedge)
 				s3c_hsudc_set_halt(&hsep->ep, set);
 			return 0;
 		}
-- 
2.6.3


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

* [PATCH 3/4] usb: host: remove redundant condition
  2015-12-10 20:50 [PATCH 1/4] usb: serial: remove redundant conditions Geyslan G. Bem
  2015-12-10 20:50 ` [PATCH 2/4] usb: gadget: remove redundant condition Geyslan G. Bem
@ 2015-12-10 20:50 ` Geyslan G. Bem
  2015-12-10 20:50 ` [PATCH 4/4] usb: musb: " Geyslan G. Bem
  2015-12-11  9:16 ` [PATCH 1/4] usb: serial: remove redundant conditions Johan Hovold
  3 siblings, 0 replies; 6+ messages in thread
From: Geyslan G. Bem @ 2015-12-10 20:50 UTC (permalink / raw)
  To: peter.senna; +Cc: Geyslan G. Bem, Greg Kroah-Hartman, linux-usb, linux-kernel

This patch removes redundant condition.

 (!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/host/fhci-sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/fhci-sched.c b/drivers/usb/host/fhci-sched.c
index 95ca598..23ecac5 100644
--- a/drivers/usb/host/fhci-sched.c
+++ b/drivers/usb/host/fhci-sched.c
@@ -288,7 +288,7 @@ static int scan_ed_list(struct fhci_usb *usb,
 	list_for_each_entry(ed, list, node) {
 		td = ed->td_head;
 
-		if (!td || (td && td->status == USB_TD_INPROGRESS))
+		if (!td || (td->status == USB_TD_INPROGRESS))
 			continue;
 
 		if (ed->state != FHCI_ED_OPER) {
-- 
2.6.3


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

* [PATCH 4/4] usb: musb: remove redundant condition
  2015-12-10 20:50 [PATCH 1/4] usb: serial: remove redundant conditions Geyslan G. Bem
  2015-12-10 20:50 ` [PATCH 2/4] usb: gadget: remove redundant condition Geyslan G. Bem
  2015-12-10 20:50 ` [PATCH 3/4] usb: host: " Geyslan G. Bem
@ 2015-12-10 20:50 ` Geyslan G. Bem
  2015-12-11  9:16 ` [PATCH 1/4] usb: serial: remove redundant conditions Johan Hovold
  3 siblings, 0 replies; 6+ messages in thread
From: Geyslan G. Bem @ 2015-12-10 20:50 UTC (permalink / raw)
  To: peter.senna
  Cc: Geyslan G. Bem, Felipe Balbi, Greg Kroah-Hartman, linux-usb,
	linux-kernel

This patch removes redundant condition.

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

Fixes indentation too.

Tested by: compilation only
Caught by: cppcheck

Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
---
 drivers/usb/musb/musb_gadget.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 67ad630..87bd578 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -353,9 +353,8 @@ static void txstate(struct musb *musb, struct musb_request *req)
 					 *	1	>0	Yes(FS bulk)
 					 */
 					if (!musb_ep->hb_mult ||
-						(musb_ep->hb_mult &&
-						 can_bulk_split(musb,
-						    musb_ep->type)))
+					    can_bulk_split(musb,
+							   musb_ep->type))
 						csr |= MUSB_TXCSR_AUTOSET;
 				}
 				csr &= ~MUSB_TXCSR_P_UNDERRUN;
-- 
2.6.3


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

* Re: [PATCH 1/4] usb: serial: remove redundant conditions
  2015-12-10 20:50 [PATCH 1/4] usb: serial: remove redundant conditions Geyslan G. Bem
                   ` (2 preceding siblings ...)
  2015-12-10 20:50 ` [PATCH 4/4] usb: musb: " Geyslan G. Bem
@ 2015-12-11  9:16 ` Johan Hovold
  2015-12-11  9:35   ` Geyslan G. Bem
  3 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2015-12-11  9:16 UTC (permalink / raw)
  To: Geyslan G. Bem
  Cc: peter.senna, Johan Hovold, Greg Kroah-Hartman, linux-usb, linux-kernel

On Thu, Dec 10, 2015 at 05:50:09PM -0300, Geyslan G. Bem wrote:
> This patch removes redundant conditions.
> 
>  (!A || (A && B)) is the same as (!A || B).
>  (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/io_edgeport.c | 35 ++++++++++++++---------------------
>  drivers/usb/serial/mos7840.c     |  2 +-
>  2 files changed, 15 insertions(+), 22 deletions(-)

Please split this up per driver as I (and Felipe) asked.

You can send these two separate from the rest, and remember to CC
the USB list.

Thanks,
Johan

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

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

2015-12-11 6:16 GMT-03:00 Johan Hovold <johan@kernel.org>:
> On Thu, Dec 10, 2015 at 05:50:09PM -0300, Geyslan G. Bem wrote:
>> This patch removes redundant conditions.
>>
>>  (!A || (A && B)) is the same as (!A || B).
>>  (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/io_edgeport.c | 35 ++++++++++++++---------------------
>>  drivers/usb/serial/mos7840.c     |  2 +-
>>  2 files changed, 15 insertions(+), 22 deletions(-)
>
> Please split this up per driver as I (and Felipe) asked.
Sorry. get_maintainer give same maintainers, but the question here is
the different drivers. Ok, I'll send them splitted.

>
> You can send these two separate from the rest, and remember to CC
> the USB list.
Ok, tks.

>
> Thanks,
> Johan



-- 
Regards,

Geyslan G. Bem
hackingbits.com

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-10 20:50 [PATCH 1/4] usb: serial: remove redundant conditions Geyslan G. Bem
2015-12-10 20:50 ` [PATCH 2/4] usb: gadget: remove redundant condition Geyslan G. Bem
2015-12-10 20:50 ` [PATCH 3/4] usb: host: " Geyslan G. Bem
2015-12-10 20:50 ` [PATCH 4/4] usb: musb: " Geyslan G. Bem
2015-12-11  9:16 ` [PATCH 1/4] usb: serial: remove redundant conditions Johan Hovold
2015-12-11  9:35   ` Geyslan G. Bem

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.