ChangeSet 1.1848, 2004/06/07 14:05:59-07:00, Siegfried.Hildebrand@FernUni-Hagen.de

[PATCH] USB: Fix problems with cyberjack usb-serial-module since kernel 2.6.2

> Send me a patch to back those changes out to fix your device and I'll
> apply it.  If the author is around to realize this, that should wake
> them up :)

Ok, here you are! :)
Attached is a patch for linux-2.6.7-rc2. (though the patch hasn't changed
since -rc1)

Again a short description:
(the patch removes most of the changes done in linux-2.6.2)
1. Removed the local buffer of cyberjack_write, because something goes wrong
upon a write-request bigger than the buffer. Without this, a write-request
stalls with error -3.
2. Removed some usb_clear_halt() lines. Without this, the device doesn't even
open and returns -7.

It works for my cyberjack pinpad USB card reader on
- nforce2 chipset
- VIA KM266 chipset
- AMD Irongate chipset

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


 drivers/usb/serial/cyberjack.c |   21 ++++++---------------
 1 files changed, 6 insertions(+), 15 deletions(-)


diff -Nru a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
--- a/drivers/usb/serial/cyberjack.c	Mon Jun  7 14:42:14 2004
+++ b/drivers/usb/serial/cyberjack.c	Mon Jun  7 14:42:14 2004
@@ -109,7 +109,7 @@
 	short		rdtodo;		/* Bytes still to read */
 	unsigned char	wrbuf[5*64];	/* Buffer for collecting data to write */
 	short		wrfilled;	/* Overall data size we already got */
-	short		wrsent;		/* Data akready sent */
+	short		wrsent;		/* Data already sent */
 };
 
 /* do some startup allocations not currently performed by usb_serial_probe() */
@@ -159,8 +159,6 @@
 
 	dbg("%s - usb_clear_halt", __FUNCTION__ );
 	usb_clear_halt(port->serial->dev, port->write_urb->pipe);
-	usb_clear_halt(port->serial->dev, port->read_urb->pipe);
-	usb_clear_halt(port->serial->dev, port->interrupt_in_urb->pipe);
 
 	/* force low_latency on so that our tty_push actually forces
 	 * the data through, otherwise it is scheduled, and with high
@@ -212,7 +210,6 @@
 	unsigned long flags;
 	int result;
 	int wrexpected;
-	unsigned char localbuf[CYBERJACK_LOCAL_BUF_SIZE];	/* Buffer for collecting data to write */
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
 	dbg("%s - from_user %d", __FUNCTION__, from_user);
@@ -229,28 +226,22 @@
 
 	spin_lock_irqsave(&priv->lock, flags);
 
-	if( (count+priv->wrfilled)>sizeof(priv->wrbuf) ||
-		(count>sizeof(localbuf)) ) {
-		/* To much data  for buffer. Reset buffer. */
+	if( (count+priv->wrfilled)>sizeof(priv->wrbuf) ) {
+		/* To much data for buffer. Reset buffer. */
 		priv->wrfilled=0;
 		spin_unlock_irqrestore(&priv->lock, flags);
 		return (0);
 	}
 
-	spin_unlock_irqrestore(&priv->lock, flags);
-
 	/* Copy data */
 	if (from_user) {
-		if (copy_from_user(localbuf, buf, count)) {
+		if (copy_from_user(priv->wrbuf+priv->wrfilled, buf, count)) {
+			spin_unlock_irqrestore(&priv->lock, flags);
 			return -EFAULT;
 		}
 	} else {
-		memcpy (localbuf, buf, count);
+		memcpy (priv->wrbuf+priv->wrfilled, buf, count);
 	}  
-
-	spin_lock_irqsave(&priv->lock, flags);
-
-	memcpy (priv->wrbuf+priv->wrfilled, localbuf, count);
 
 	usb_serial_debug_data (__FILE__, __FUNCTION__, count,
 		priv->wrbuf+priv->wrfilled);