| .. | .. |
|---|
| 16 | 16 | * was written by Roman Weissgaerber <weissg@vienna.at>, Dag Brattli |
|---|
| 17 | 17 | * <dag@brattli.net>, and Jean Tourrilhes <jt@hpl.hp.com> |
|---|
| 18 | 18 | * |
|---|
| 19 | | - * See Documentation/usb/usb-serial.txt for more information on using this |
|---|
| 19 | + * See Documentation/usb/usb-serial.rst for more information on using this |
|---|
| 20 | 20 | * driver |
|---|
| 21 | 21 | */ |
|---|
| 22 | 22 | |
|---|
| .. | .. |
|---|
| 76 | 76 | .description = "IR Dongle", |
|---|
| 77 | 77 | .id_table = ir_id_table, |
|---|
| 78 | 78 | .num_ports = 1, |
|---|
| 79 | + .num_bulk_in = 1, |
|---|
| 80 | + .num_bulk_out = 1, |
|---|
| 79 | 81 | .set_termios = ir_set_termios, |
|---|
| 80 | 82 | .attach = ir_startup, |
|---|
| 81 | 83 | .write = ir_write, |
|---|
| .. | .. |
|---|
| 196 | 198 | { |
|---|
| 197 | 199 | struct usb_irda_cs_descriptor *irda_desc; |
|---|
| 198 | 200 | int rates; |
|---|
| 199 | | - |
|---|
| 200 | | - if (serial->num_bulk_in < 1 || serial->num_bulk_out < 1) |
|---|
| 201 | | - return -ENODEV; |
|---|
| 202 | 201 | |
|---|
| 203 | 202 | irda_desc = irda_usb_find_class_desc(serial, 0); |
|---|
| 204 | 203 | if (!irda_desc) { |
|---|
| .. | .. |
|---|
| 376 | 375 | tty_flip_buffer_push(&port->port); |
|---|
| 377 | 376 | } |
|---|
| 378 | 377 | |
|---|
| 379 | | -static void ir_set_termios_callback(struct urb *urb) |
|---|
| 380 | | -{ |
|---|
| 381 | | - kfree(urb->transfer_buffer); |
|---|
| 382 | | - |
|---|
| 383 | | - if (urb->status) |
|---|
| 384 | | - dev_dbg(&urb->dev->dev, "%s - non-zero urb status: %d\n", |
|---|
| 385 | | - __func__, urb->status); |
|---|
| 386 | | -} |
|---|
| 387 | | - |
|---|
| 388 | 378 | static void ir_set_termios(struct tty_struct *tty, |
|---|
| 389 | 379 | struct usb_serial_port *port, struct ktermios *old_termios) |
|---|
| 390 | 380 | { |
|---|
| 391 | | - struct urb *urb; |
|---|
| 381 | + struct usb_device *udev = port->serial->dev; |
|---|
| 392 | 382 | unsigned char *transfer_buffer; |
|---|
| 393 | | - int result; |
|---|
| 383 | + int actual_length; |
|---|
| 394 | 384 | speed_t baud; |
|---|
| 395 | 385 | int ir_baud; |
|---|
| 386 | + int ret; |
|---|
| 396 | 387 | |
|---|
| 397 | 388 | baud = tty_get_baud_rate(tty); |
|---|
| 398 | 389 | |
|---|
| .. | .. |
|---|
| 447 | 438 | /* |
|---|
| 448 | 439 | * send the baud change out on an "empty" data packet |
|---|
| 449 | 440 | */ |
|---|
| 450 | | - urb = usb_alloc_urb(0, GFP_KERNEL); |
|---|
| 451 | | - if (!urb) |
|---|
| 452 | | - return; |
|---|
| 453 | | - |
|---|
| 454 | 441 | transfer_buffer = kmalloc(1, GFP_KERNEL); |
|---|
| 455 | 442 | if (!transfer_buffer) |
|---|
| 456 | | - goto err_buf; |
|---|
| 443 | + return; |
|---|
| 457 | 444 | |
|---|
| 458 | 445 | *transfer_buffer = ir_xbof | ir_baud; |
|---|
| 459 | 446 | |
|---|
| 460 | | - usb_fill_bulk_urb( |
|---|
| 461 | | - urb, |
|---|
| 462 | | - port->serial->dev, |
|---|
| 463 | | - usb_sndbulkpipe(port->serial->dev, |
|---|
| 464 | | - port->bulk_out_endpointAddress), |
|---|
| 465 | | - transfer_buffer, |
|---|
| 466 | | - 1, |
|---|
| 467 | | - ir_set_termios_callback, |
|---|
| 468 | | - port); |
|---|
| 469 | | - |
|---|
| 470 | | - urb->transfer_flags = URB_ZERO_PACKET; |
|---|
| 471 | | - |
|---|
| 472 | | - result = usb_submit_urb(urb, GFP_KERNEL); |
|---|
| 473 | | - if (result) { |
|---|
| 474 | | - dev_err(&port->dev, "%s - failed to submit urb: %d\n", |
|---|
| 475 | | - __func__, result); |
|---|
| 476 | | - goto err_subm; |
|---|
| 447 | + ret = usb_bulk_msg(udev, |
|---|
| 448 | + usb_sndbulkpipe(udev, port->bulk_out_endpointAddress), |
|---|
| 449 | + transfer_buffer, 1, &actual_length, 5000); |
|---|
| 450 | + if (ret || actual_length != 1) { |
|---|
| 451 | + if (!ret) |
|---|
| 452 | + ret = -EIO; |
|---|
| 453 | + dev_err(&port->dev, "failed to change line speed: %d\n", ret); |
|---|
| 477 | 454 | } |
|---|
| 478 | 455 | |
|---|
| 479 | | - usb_free_urb(urb); |
|---|
| 480 | | - |
|---|
| 481 | | - return; |
|---|
| 482 | | -err_subm: |
|---|
| 483 | 456 | kfree(transfer_buffer); |
|---|
| 484 | | -err_buf: |
|---|
| 485 | | - usb_free_urb(urb); |
|---|
| 486 | 457 | } |
|---|
| 487 | 458 | |
|---|
| 488 | 459 | static int __init ir_init(void) |
|---|