[PATCH v3] USB: mos7840: looping issue: avoid the return value overriden by looping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  inside the 'for' looping:
    the return value 'rv' may override if not have a check in time.

  the next checking (outside the 'for' looping):
    can not find failure which generated during the 'for' looping

  the fix is for:
    let outside know about the failure, and not stop servicing the
    other ports just because there is an error in another port.


Signed-off-by: Chen Gang <gang.chen@xxxxxxxxxxx>
Signed-off-by: Oliver Neukum <oneukum@xxxxxxx>
---
 drivers/usb/serial/mos7840.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index a0d5ea5..20cab64 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -585,7 +585,8 @@ static void mos7840_interrupt_callback(struct urb *urb)
 	__u16 Data;
 	unsigned char *data;
 	__u8 sp[5], st;
-	int i, rv = 0;
+	int i;
+	bool rv = true;
 	__u16 wval, wreg = 0;
 	int status = urb->status;
 
@@ -651,11 +652,16 @@ static void mos7840_interrupt_callback(struct urb *urb)
 					wreg = MODEM_STATUS_REGISTER;
 					break;
 				}
-				rv = mos7840_get_reg(mos7840_port, wval, wreg, &Data);
+				if (mos7840_get_reg(mos7840_port, wval, wreg,
+				    &Data) < 0)
+					/*
+					 * mark failure, but still need continue
+					 */
+					rv = false;
 			}
 		}
 	}
-	if (!(rv < 0))
+	if (rv)
 		/* the completion handler for the control urb will resubmit */
 		return;
 exit:
-- 
1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux