aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/cyberjack.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2008-04-08 12:16:06 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-04-25 00:16:55 -0400
commita5b6f60c5a30c494017c7a2d11c4067f90d3d0df (patch)
tree2f80d1a6c2655c5c12f40cafbc47516284934d42 /drivers/usb/serial/cyberjack.c
parent441b62c1edb986827154768d89bbac0ba779984f (diff)
usb serial: more fixes and groundwork for tty changes
- If a termios change fails due to lack of memory we should copy the old settings back over as the device has not changed - Note various locking problems - kl5kusb105 had various remaining tty flag handling problems - Make safe_serial use tty_insert_flip_string not open coded loops - set termios speed properly in usb_serial Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/cyberjack.c')
-rw-r--r--drivers/usb/serial/cyberjack.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 5348e97b52b5..d077534ceaeb 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -151,7 +151,7 @@ static void cyberjack_shutdown (struct usb_serial *serial)
151 151
152 dbg("%s", __func__); 152 dbg("%s", __func__);
153 153
154 for (i=0; i < serial->num_ports; ++i) { 154 for (i = 0; i < serial->num_ports; ++i) {
155 usb_kill_urb(serial->port[i]->interrupt_in_urb); 155 usb_kill_urb(serial->port[i]->interrupt_in_urb);
156 /* My special items, the standard routines free my urbs */ 156 /* My special items, the standard routines free my urbs */
157 kfree(usb_get_serial_port_data(serial->port[i])); 157 kfree(usb_get_serial_port_data(serial->port[i]));
@@ -209,7 +209,7 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
209 209
210 if (count == 0) { 210 if (count == 0) {
211 dbg("%s - write request of 0 bytes", __func__); 211 dbg("%s - write request of 0 bytes", __func__);
212 return (0); 212 return 0;
213 } 213 }
214 214
215 spin_lock_bh(&port->lock); 215 spin_lock_bh(&port->lock);
@@ -223,12 +223,12 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
223 223
224 spin_lock_irqsave(&priv->lock, flags); 224 spin_lock_irqsave(&priv->lock, flags);
225 225
226 if( (count+priv->wrfilled)>sizeof(priv->wrbuf) ) { 226 if( (count+priv->wrfilled) > sizeof(priv->wrbuf) ) {
227 /* To much data for buffer. Reset buffer. */ 227 /* To much data for buffer. Reset buffer. */
228 priv->wrfilled=0; 228 priv->wrfilled = 0;
229 spin_unlock_irqrestore(&priv->lock, flags);
230 port->write_urb_busy = 0; 229 port->write_urb_busy = 0;
231 return (0); 230 spin_unlock_irqrestore(&priv->lock, flags);
231 return 0;
232 } 232 }
233 233
234 /* Copy data */ 234 /* Copy data */
@@ -269,8 +269,8 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
269 if (result) { 269 if (result) {
270 err("%s - failed submitting write urb, error %d", __func__, result); 270 err("%s - failed submitting write urb, error %d", __func__, result);
271 /* Throw away data. No better idea what to do with it. */ 271 /* Throw away data. No better idea what to do with it. */
272 priv->wrfilled=0; 272 priv->wrfilled = 0;
273 priv->wrsent=0; 273 priv->wrsent = 0;
274 spin_unlock_irqrestore(&priv->lock, flags); 274 spin_unlock_irqrestore(&priv->lock, flags);
275 port->write_urb_busy = 0; 275 port->write_urb_busy = 0;
276 return 0; 276 return 0;
@@ -282,8 +282,8 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
282 if( priv->wrsent>=priv->wrfilled ) { 282 if( priv->wrsent>=priv->wrfilled ) {
283 dbg("%s - buffer cleaned", __func__); 283 dbg("%s - buffer cleaned", __func__);
284 memset( priv->wrbuf, 0, sizeof(priv->wrbuf) ); 284 memset( priv->wrbuf, 0, sizeof(priv->wrbuf) );
285 priv->wrfilled=0; 285 priv->wrfilled = 0;
286 priv->wrsent=0; 286 priv->wrsent = 0;
287 } 287 }
288 } 288 }
289 289
@@ -294,6 +294,7 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
294 294
295static int cyberjack_write_room( struct usb_serial_port *port ) 295static int cyberjack_write_room( struct usb_serial_port *port )
296{ 296{
297 /* FIXME: .... */
297 return CYBERJACK_LOCAL_BUF_SIZE; 298 return CYBERJACK_LOCAL_BUF_SIZE;
298} 299}
299 300
@@ -314,7 +315,7 @@ static void cyberjack_read_int_callback( struct urb *urb )
314 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); 315 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
315 316
316 /* React only to interrupts signaling a bulk_in transfer */ 317 /* React only to interrupts signaling a bulk_in transfer */
317 if( (urb->actual_length==4) && (data[0]==0x01) ) { 318 if( (urb->actual_length == 4) && (data[0] == 0x01) ) {
318 short old_rdtodo; 319 short old_rdtodo;
319 320
320 /* This is a announcement of coming bulk_ins. */ 321 /* This is a announcement of coming bulk_ins. */
@@ -450,8 +451,8 @@ static void cyberjack_write_bulk_callback (struct urb *urb)
450 if (result) { 451 if (result) {
451 err("%s - failed submitting write urb, error %d", __func__, result); 452 err("%s - failed submitting write urb, error %d", __func__, result);
452 /* Throw away data. No better idea what to do with it. */ 453 /* Throw away data. No better idea what to do with it. */
453 priv->wrfilled=0; 454 priv->wrfilled = 0;
454 priv->wrsent=0; 455 priv->wrsent = 0;
455 goto exit; 456 goto exit;
456 } 457 }
457 458
@@ -463,8 +464,8 @@ static void cyberjack_write_bulk_callback (struct urb *urb)
463 if( (priv->wrsent>=priv->wrfilled) || (priv->wrsent>=blksize) ) { 464 if( (priv->wrsent>=priv->wrfilled) || (priv->wrsent>=blksize) ) {
464 dbg("%s - buffer cleaned", __func__); 465 dbg("%s - buffer cleaned", __func__);
465 memset( priv->wrbuf, 0, sizeof(priv->wrbuf) ); 466 memset( priv->wrbuf, 0, sizeof(priv->wrbuf) );
466 priv->wrfilled=0; 467 priv->wrfilled = 0;
467 priv->wrsent=0; 468 priv->wrsent = 0;
468 } 469 }
469 } 470 }
470 471