summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYAMANE Toshiaki <yamanetoshi@gmail.com>2012-11-17 05:19:22 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-16 15:03:10 -0800
commit9d36976fad3008fcc4209789566f7f3e7763f212 (patch)
treefccba2f70550cdd6fb5bd14b9d264310ea3b7c11
parent27cf2d1b873fc50a2c0388253ec666fa4c61bfd4 (diff)
staging/serqt_usb2: Refactor qt_status_change_check() in serqt_usb2.c
Modify qt_status_change_check() and delete qt_status_change(). Signed-off-by: YAMANE Toshiaki <yamanetoshi@gmail.com> Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/serqt_usb2/serqt_usb2.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
index f68a855199fc..1b3e995d3a27 100644
--- a/drivers/staging/serqt_usb2/serqt_usb2.c
+++ b/drivers/staging/serqt_usb2/serqt_usb2.c
@@ -291,33 +291,6 @@ static void qt_interrupt_callback(struct urb *urb)
/* FIXME */
}
-static int qt_status_change(unsigned int limit,
- unsigned char *data,
- int i,
- struct quatech_port *qt_port,
- struct usb_serial_port *port)
-{
- void (*fn)(struct quatech_port *, unsigned char);
-
- if (0x00 == data[i + 2]) {
- dev_dbg(&port->dev, "Line status status.\n");
- fn = ProcessLineStatus;
- } else {
- dev_dbg(&port->dev, "Modem status status.\n");
- fn = ProcessModemStatus;
- }
-
- if (i > limit) {
- dev_dbg(&port->dev,
- "Illegal escape seuences in received data\n");
- return 0;
- }
-
- (*fn)(qt_port, data[i + 3]);
-
- return 1;
-}
-
static void qt_status_change_check(struct tty_struct *tty,
struct urb *urb,
struct quatech_port *qt_port,
@@ -334,11 +307,29 @@ static void qt_status_change_check(struct tty_struct *tty,
flag = 0;
switch (data[i + 2]) {
case 0x00:
+ if (i > (RxCount - 4)) {
+ dev_dbg(&port->dev,
+ "Illegal escape seuences in received data\n");
+ break;
+ }
+
+ ProcessLineStatus(qt_port, data[i + 3]);
+
+ i += 3;
+ flag = 1;
+ break;
+
case 0x01:
- flag = qt_status_change((RxCount - 4), data, i,
- qt_port, port);
- if (flag == 1)
- i += 3;
+ if (i > (RxCount - 4)) {
+ dev_dbg(&port->dev,
+ "Illegal escape seuences in received data\n");
+ break;
+ }
+
+ ProcessModemStatus(qt_port, data[i + 3]);
+
+ i += 3;
+ flag = 1;
break;
case 0xff: