Commit 7b2706c3 authored by Ganesh Varadarajan's avatar Ganesh Varadarajan Committed by Trond Myklebust

[PATCH] bugfix for drivers/usb/serial/ipaq.c

Buggy error handling fixed. Retry the "kickstart" packet much harder -
this greatly reduces instances of connection failures.
parent 315310ec
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* (26/7/2002) ganesh
* Fixed up broken error handling in ipaq_open. Retry the "kickstart"
* packet much harder - this drastically reduces connection failures.
*
* (30/4/2002) ganesh * (30/4/2002) ganesh
* Added support for the Casio EM500. Completely untested. Thanks * Added support for the Casio EM500. Completely untested. Thanks
* to info from Nathan <wfilardo@fuse.net> * to info from Nathan <wfilardo@fuse.net>
...@@ -54,6 +58,8 @@ ...@@ -54,6 +58,8 @@
#include "usb-serial.h" #include "usb-serial.h"
#include "ipaq.h" #include "ipaq.h"
#define KP_RETRIES 100
/* /*
* Version Information * Version Information
*/ */
...@@ -118,6 +124,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) ...@@ -118,6 +124,7 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
struct ipaq_private *priv; struct ipaq_private *priv;
struct ipaq_packet *pkt; struct ipaq_packet *pkt;
int i, result = 0; int i, result = 0;
int retries = KP_RETRIES;
if (port_paranoia_check(port, __FUNCTION__)) { if (port_paranoia_check(port, __FUNCTION__)) {
return -ENODEV; return -ENODEV;
...@@ -192,31 +199,35 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) ...@@ -192,31 +199,35 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
result = usb_submit_urb(port->read_urb, GFP_KERNEL); result = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (result) { if (result) {
err(__FUNCTION__ " - failed submitting read urb, error %d", result); err(__FUNCTION__ " - failed submitting read urb, error %d", result);
goto error;
} }
/* /*
* Send out two control messages observed in win98 sniffs. Not sure what * Send out control message observed in win98 sniffs. Not sure what
* they do. * it does, but from empirical observations, it seems that the device
* will start the chat sequence once one of these messages gets
* through. Since this has a reasonably high failure rate, we retry
* several times.
*/ */
result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21, while (retries--) {
0x1, 0, NULL, 0, 5 * HZ); result = usb_control_msg(serial->dev,
if (result < 0) { usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21,
err(__FUNCTION__ " - failed doing control urb, error %d", result); 0x1, 0, NULL, 0, HZ / 10 + 1);
} if (result == 0) {
result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21, return 0;
0x1, 0, NULL, 0, 5 * HZ); }
if (result < 0) {
err(__FUNCTION__ " - failed doing control urb, error %d", result);
} }
err(__FUNCTION__ " - failed doing control urb, error %d", result);
return result; goto error;
enomem: enomem:
result = -ENOMEM;
err(__FUNCTION__ " - Out of memory");
error:
ipaq_destroy_lists(port); ipaq_destroy_lists(port);
kfree(priv); kfree(priv);
err(__FUNCTION__ " - Out of memory"); return result;
return -ENOMEM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment