diff options
Diffstat (limited to 'drivers/usb/serial/aircable.c')
-rw-r--r-- | drivers/usb/serial/aircable.c | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 9b1bb347dc2d..db6f97a93c02 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
@@ -147,7 +147,7 @@ static void serial_buf_free(struct circ_buf *cb) | |||
147 | */ | 147 | */ |
148 | static int serial_buf_data_avail(struct circ_buf *cb) | 148 | static int serial_buf_data_avail(struct circ_buf *cb) |
149 | { | 149 | { |
150 | return CIRC_CNT(cb->head,cb->tail,AIRCABLE_BUF_SIZE); | 150 | return CIRC_CNT(cb->head, cb->tail, AIRCABLE_BUF_SIZE); |
151 | } | 151 | } |
152 | 152 | ||
153 | /* | 153 | /* |
@@ -171,7 +171,7 @@ static int serial_buf_put(struct circ_buf *cb, const char *buf, int count) | |||
171 | cb->head = (cb->head + c) & (AIRCABLE_BUF_SIZE-1); | 171 | cb->head = (cb->head + c) & (AIRCABLE_BUF_SIZE-1); |
172 | buf += c; | 172 | buf += c; |
173 | count -= c; | 173 | count -= c; |
174 | ret= c; | 174 | ret = c; |
175 | } | 175 | } |
176 | return ret; | 176 | return ret; |
177 | } | 177 | } |
@@ -197,7 +197,7 @@ static int serial_buf_get(struct circ_buf *cb, char *buf, int count) | |||
197 | cb->tail = (cb->tail + c) & (AIRCABLE_BUF_SIZE-1); | 197 | cb->tail = (cb->tail + c) & (AIRCABLE_BUF_SIZE-1); |
198 | buf += c; | 198 | buf += c; |
199 | count -= c; | 199 | count -= c; |
200 | ret= c; | 200 | ret = c; |
201 | } | 201 | } |
202 | return ret; | 202 | return ret; |
203 | } | 203 | } |
@@ -208,7 +208,7 @@ static void aircable_send(struct usb_serial_port *port) | |||
208 | { | 208 | { |
209 | int count, result; | 209 | int count, result; |
210 | struct aircable_private *priv = usb_get_serial_port_data(port); | 210 | struct aircable_private *priv = usb_get_serial_port_data(port); |
211 | unsigned char* buf; | 211 | unsigned char *buf; |
212 | __le16 *dbuf; | 212 | __le16 *dbuf; |
213 | dbg("%s - port %d", __func__, port->number); | 213 | dbg("%s - port %d", __func__, port->number); |
214 | if (port->write_urb_busy) | 214 | if (port->write_urb_busy) |
@@ -229,7 +229,8 @@ static void aircable_send(struct usb_serial_port *port) | |||
229 | buf[1] = TX_HEADER_1; | 229 | buf[1] = TX_HEADER_1; |
230 | dbuf = (__le16 *)&buf[2]; | 230 | dbuf = (__le16 *)&buf[2]; |
231 | *dbuf = cpu_to_le16((u16)count); | 231 | *dbuf = cpu_to_le16((u16)count); |
232 | serial_buf_get(priv->tx_buf,buf + HCI_HEADER_LENGTH, MAX_HCI_FRAMESIZE); | 232 | serial_buf_get(priv->tx_buf, buf + HCI_HEADER_LENGTH, |
233 | MAX_HCI_FRAMESIZE); | ||
233 | 234 | ||
234 | memcpy(port->write_urb->transfer_buffer, buf, | 235 | memcpy(port->write_urb->transfer_buffer, buf, |
235 | count + HCI_HEADER_LENGTH); | 236 | count + HCI_HEADER_LENGTH); |
@@ -261,7 +262,7 @@ static void aircable_read(struct work_struct *work) | |||
261 | struct tty_struct *tty; | 262 | struct tty_struct *tty; |
262 | unsigned char *data; | 263 | unsigned char *data; |
263 | int count; | 264 | int count; |
264 | if (priv->rx_flags & THROTTLED){ | 265 | if (priv->rx_flags & THROTTLED) { |
265 | if (priv->rx_flags & ACTUALLY_THROTTLED) | 266 | if (priv->rx_flags & ACTUALLY_THROTTLED) |
266 | schedule_work(&priv->rx_work); | 267 | schedule_work(&priv->rx_work); |
267 | return; | 268 | return; |
@@ -282,10 +283,10 @@ static void aircable_read(struct work_struct *work) | |||
282 | count = min(64, serial_buf_data_avail(priv->rx_buf)); | 283 | count = min(64, serial_buf_data_avail(priv->rx_buf)); |
283 | 284 | ||
284 | if (count <= 0) | 285 | if (count <= 0) |
285 | return; //We have finished sending everything. | 286 | return; /* We have finished sending everything. */ |
286 | 287 | ||
287 | tty_prepare_flip_string(tty, &data, count); | 288 | tty_prepare_flip_string(tty, &data, count); |
288 | if (!data){ | 289 | if (!data) { |
289 | err("%s- kzalloc(%d) failed.", __func__, count); | 290 | err("%s- kzalloc(%d) failed.", __func__, count); |
290 | return; | 291 | return; |
291 | } | 292 | } |
@@ -304,9 +305,10 @@ static void aircable_read(struct work_struct *work) | |||
304 | static int aircable_probe(struct usb_serial *serial, | 305 | static int aircable_probe(struct usb_serial *serial, |
305 | const struct usb_device_id *id) | 306 | const struct usb_device_id *id) |
306 | { | 307 | { |
307 | struct usb_host_interface *iface_desc = serial->interface->cur_altsetting; | 308 | struct usb_host_interface *iface_desc = serial->interface-> |
309 | cur_altsetting; | ||
308 | struct usb_endpoint_descriptor *endpoint; | 310 | struct usb_endpoint_descriptor *endpoint; |
309 | int num_bulk_out=0; | 311 | int num_bulk_out = 0; |
310 | int i; | 312 | int i; |
311 | 313 | ||
312 | for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { | 314 | for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { |
@@ -325,13 +327,13 @@ static int aircable_probe(struct usb_serial *serial, | |||
325 | return 0; | 327 | return 0; |
326 | } | 328 | } |
327 | 329 | ||
328 | static int aircable_attach (struct usb_serial *serial) | 330 | static int aircable_attach(struct usb_serial *serial) |
329 | { | 331 | { |
330 | struct usb_serial_port *port = serial->port[0]; | 332 | struct usb_serial_port *port = serial->port[0]; |
331 | struct aircable_private *priv; | 333 | struct aircable_private *priv; |
332 | 334 | ||
333 | priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); | 335 | priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL); |
334 | if (!priv){ | 336 | if (!priv) { |
335 | err("%s- kmalloc(%Zd) failed.", __func__, | 337 | err("%s- kmalloc(%Zd) failed.", __func__, |
336 | sizeof(struct aircable_private)); | 338 | sizeof(struct aircable_private)); |
337 | return -ENOMEM; | 339 | return -ENOMEM; |
@@ -392,7 +394,7 @@ static int aircable_write(struct usb_serial_port *port, | |||
392 | 394 | ||
393 | usb_serial_debug_data(debug, &port->dev, __func__, count, source); | 395 | usb_serial_debug_data(debug, &port->dev, __func__, count, source); |
394 | 396 | ||
395 | if (!count){ | 397 | if (!count) { |
396 | dbg("%s - write request of 0 bytes", __func__); | 398 | dbg("%s - write request of 0 bytes", __func__); |
397 | return count; | 399 | return count; |
398 | } | 400 | } |
@@ -418,31 +420,31 @@ static void aircable_write_bulk_callback(struct urb *urb) | |||
418 | 420 | ||
419 | /* This has been taken from cypress_m8.c cypress_write_int_callback */ | 421 | /* This has been taken from cypress_m8.c cypress_write_int_callback */ |
420 | switch (status) { | 422 | switch (status) { |
421 | case 0: | 423 | case 0: |
422 | /* success */ | 424 | /* success */ |
423 | break; | 425 | break; |
424 | case -ECONNRESET: | 426 | case -ECONNRESET: |
425 | case -ENOENT: | 427 | case -ENOENT: |
426 | case -ESHUTDOWN: | 428 | case -ESHUTDOWN: |
427 | /* this urb is terminated, clean up */ | 429 | /* this urb is terminated, clean up */ |
428 | dbg("%s - urb shutting down with status: %d", | 430 | dbg("%s - urb shutting down with status: %d", |
429 | __func__, status); | 431 | __func__, status); |
430 | port->write_urb_busy = 0; | 432 | port->write_urb_busy = 0; |
433 | return; | ||
434 | default: | ||
435 | /* error in the urb, so we have to resubmit it */ | ||
436 | dbg("%s - Overflow in write", __func__); | ||
437 | dbg("%s - nonzero write bulk status received: %d", | ||
438 | __func__, status); | ||
439 | port->write_urb->transfer_buffer_length = 1; | ||
440 | port->write_urb->dev = port->serial->dev; | ||
441 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
442 | if (result) | ||
443 | dev_err(&urb->dev->dev, | ||
444 | "%s - failed resubmitting write urb, error %d\n", | ||
445 | __func__, result); | ||
446 | else | ||
431 | return; | 447 | return; |
432 | default: | ||
433 | /* error in the urb, so we have to resubmit it */ | ||
434 | dbg("%s - Overflow in write", __func__); | ||
435 | dbg("%s - nonzero write bulk status received: %d", | ||
436 | __func__, status); | ||
437 | port->write_urb->transfer_buffer_length = 1; | ||
438 | port->write_urb->dev = port->serial->dev; | ||
439 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | ||
440 | if (result) | ||
441 | dev_err(&urb->dev->dev, | ||
442 | "%s - failed resubmitting write urb, error %d\n", | ||
443 | __func__, result); | ||
444 | else | ||
445 | return; | ||
446 | } | 448 | } |
447 | 449 | ||
448 | port->write_urb_busy = 0; | 450 | port->write_urb_busy = 0; |
@@ -472,11 +474,11 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
472 | dbg("%s - caught -EPROTO, resubmitting the urb", | 474 | dbg("%s - caught -EPROTO, resubmitting the urb", |
473 | __func__); | 475 | __func__); |
474 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 476 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
475 | usb_rcvbulkpipe(port->serial->dev, | 477 | usb_rcvbulkpipe(port->serial->dev, |
476 | port->bulk_in_endpointAddress), | 478 | port->bulk_in_endpointAddress), |
477 | port->read_urb->transfer_buffer, | 479 | port->read_urb->transfer_buffer, |
478 | port->read_urb->transfer_buffer_length, | 480 | port->read_urb->transfer_buffer_length, |
479 | aircable_read_bulk_callback, port); | 481 | aircable_read_bulk_callback, port); |
480 | 482 | ||
481 | result = usb_submit_urb(urb, GFP_ATOMIC); | 483 | result = usb_submit_urb(urb, GFP_ATOMIC); |
482 | if (result) | 484 | if (result) |
@@ -490,7 +492,7 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
490 | } | 492 | } |
491 | 493 | ||
492 | usb_serial_debug_data(debug, &port->dev, __func__, | 494 | usb_serial_debug_data(debug, &port->dev, __func__, |
493 | urb->actual_length,urb->transfer_buffer); | 495 | urb->actual_length, urb->transfer_buffer); |
494 | 496 | ||
495 | tty = port->tty; | 497 | tty = port->tty; |
496 | if (tty && urb->actual_length) { | 498 | if (tty && urb->actual_length) { |
@@ -507,9 +509,9 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
507 | no_packages = urb->actual_length / (HCI_COMPLETE_FRAME); | 509 | no_packages = urb->actual_length / (HCI_COMPLETE_FRAME); |
508 | 510 | ||
509 | if (urb->actual_length % HCI_COMPLETE_FRAME != 0) | 511 | if (urb->actual_length % HCI_COMPLETE_FRAME != 0) |
510 | no_packages+=1; | 512 | no_packages++; |
511 | 513 | ||
512 | for (i = 0; i < no_packages ;i++) { | 514 | for (i = 0; i < no_packages; i++) { |
513 | if (remaining > (HCI_COMPLETE_FRAME)) | 515 | if (remaining > (HCI_COMPLETE_FRAME)) |
514 | package_length = HCI_COMPLETE_FRAME; | 516 | package_length = HCI_COMPLETE_FRAME; |
515 | else | 517 | else |
@@ -529,7 +531,7 @@ static void aircable_read_bulk_callback(struct urb *urb) | |||
529 | if (port->open_count) { | 531 | if (port->open_count) { |
530 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 532 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
531 | usb_rcvbulkpipe(port->serial->dev, | 533 | usb_rcvbulkpipe(port->serial->dev, |
532 | port->bulk_in_endpointAddress), | 534 | port->bulk_in_endpointAddress), |
533 | port->read_urb->transfer_buffer, | 535 | port->read_urb->transfer_buffer, |
534 | port->read_urb->transfer_buffer_length, | 536 | port->read_urb->transfer_buffer_length, |
535 | aircable_read_bulk_callback, port); | 537 | aircable_read_bulk_callback, port); |
@@ -602,7 +604,7 @@ static struct usb_serial_driver aircable_device = { | |||
602 | .unthrottle = aircable_unthrottle, | 604 | .unthrottle = aircable_unthrottle, |
603 | }; | 605 | }; |
604 | 606 | ||
605 | static int __init aircable_init (void) | 607 | static int __init aircable_init(void) |
606 | { | 608 | { |
607 | int retval; | 609 | int retval; |
608 | retval = usb_serial_register(&aircable_device); | 610 | retval = usb_serial_register(&aircable_device); |
@@ -619,7 +621,7 @@ failed_usb_register: | |||
619 | return retval; | 621 | return retval; |
620 | } | 622 | } |
621 | 623 | ||
622 | static void __exit aircable_exit (void) | 624 | static void __exit aircable_exit(void) |
623 | { | 625 | { |
624 | usb_deregister(&aircable_driver); | 626 | usb_deregister(&aircable_driver); |
625 | usb_serial_deregister(&aircable_device); | 627 | usb_serial_deregister(&aircable_device); |