public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: YAMANE Toshiaki <yamanetoshi@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Joe Perches <joe@perches.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	YAMANE Toshiaki <yamanetoshi@gmail.com>
Subject: [PATCH v2] staging/serqt_usb2: Refactor qt_status_change_check() in  serqt_usb2.c
Date: Sat, 17 Nov 2012 15:48:35 +0900	[thread overview]
Message-ID: <1353134915-11265-1-git-send-email-yamanetoshi@gmail.com> (raw)
In-Reply-To: <1353115941.6139.10.camel@joe-AO722>

Modify qt_status_change_check() and delete qt_status_change().

Signed-off-by: YAMANE Toshiaki <yamanetoshi@gmail.com>
---
 drivers/staging/serqt_usb2/serqt_usb2.c |   53 +++++++++++++------------------
 1 file changed, 22 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
index f68a855..13722b2 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 sequences in received data\n");
+					break;
+				}
+
+				i += 3;
+				ProcessLineStatus(qt_port, data[i]);
+
+				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 sequences in received data\n");
+					break;
+				}
+
+				i += 3;
+				ProcessModemStatus(qt_port, data[i]);
+
+				flag = 1;
 				break;
 
 			case 0xff:
-- 
1.7.9.5


      reply	other threads:[~2012-11-17  6:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-16 20:19 [PATCH] staging/serqt_usb2: Refactor qt_status_change_check() in serqt_usb2.c YAMANE Toshiaki
2012-11-16 20:58 ` Dan Carpenter
2012-11-17  1:32 ` Joe Perches
2012-11-17  6:48   ` YAMANE Toshiaki [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353134915-11265-1-git-send-email-yamanetoshi@gmail.com \
    --to=yamanetoshi@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox