diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 06:15:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:26 -0400 |
commit | a30fa793f35b9a72fdb9ea90a539c8c9cf7bee94 (patch) | |
tree | 17cb898fbfd769d1e9bb2a03611bd487e806b2cd /drivers/usb/serial | |
parent | 0487b583f268ea43ededd7897dbf519bdcb395ee (diff) |
tty-usb-ti-usb: Coding style
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r-- | drivers/usb/serial/ti_usb_3410_5052.c | 266 |
1 files changed, 151 insertions, 115 deletions
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 48831a755fc1..e39c779e4160 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -16,7 +16,7 @@ | |||
16 | * For questions or problems with this driver, contact Texas Instruments | 16 | * For questions or problems with this driver, contact Texas Instruments |
17 | * technical support, or Al Borchers <alborchers@steinerpoint.com>, or | 17 | * technical support, or Al Borchers <alborchers@steinerpoint.com>, or |
18 | * Peter Berger <pberger@brimson.com>. | 18 | * Peter Berger <pberger@brimson.com>. |
19 | * | 19 | * |
20 | * This driver needs this hotplug script in /etc/hotplug/usb/ti_usb_3410_5052 | 20 | * This driver needs this hotplug script in /etc/hotplug/usb/ti_usb_3410_5052 |
21 | * or in /etc/hotplug.d/usb/ti_usb_3410_5052.hotplug to set the device | 21 | * or in /etc/hotplug.d/usb/ti_usb_3410_5052.hotplug to set the device |
22 | * configuration. | 22 | * configuration. |
@@ -82,7 +82,7 @@ | |||
82 | #include <linux/serial.h> | 82 | #include <linux/serial.h> |
83 | #include <linux/circ_buf.h> | 83 | #include <linux/circ_buf.h> |
84 | #include <linux/mutex.h> | 84 | #include <linux/mutex.h> |
85 | #include <asm/uaccess.h> | 85 | #include <linux/uaccess.h> |
86 | #include <linux/usb.h> | 86 | #include <linux/usb.h> |
87 | #include <linux/usb/serial.h> | 87 | #include <linux/usb/serial.h> |
88 | #include <linux/firmware.h> | 88 | #include <linux/firmware.h> |
@@ -151,21 +151,22 @@ struct ti_device { | |||
151 | static int ti_startup(struct usb_serial *serial); | 151 | static int ti_startup(struct usb_serial *serial); |
152 | static void ti_shutdown(struct usb_serial *serial); | 152 | static void ti_shutdown(struct usb_serial *serial); |
153 | static int ti_open(struct tty_struct *tty, struct usb_serial_port *port, | 153 | static int ti_open(struct tty_struct *tty, struct usb_serial_port *port, |
154 | struct file *file); | 154 | struct file *file); |
155 | static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, | 155 | static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, |
156 | struct file *file); | 156 | struct file *file); |
157 | static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, | 157 | static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, |
158 | const unsigned char *data, int count); | 158 | const unsigned char *data, int count); |
159 | static int ti_write_room(struct tty_struct *tty); | 159 | static int ti_write_room(struct tty_struct *tty); |
160 | static int ti_chars_in_buffer(struct tty_struct *tty); | 160 | static int ti_chars_in_buffer(struct tty_struct *tty); |
161 | static void ti_throttle(struct tty_struct *tty); | 161 | static void ti_throttle(struct tty_struct *tty); |
162 | static void ti_unthrottle(struct tty_struct *tty); | 162 | static void ti_unthrottle(struct tty_struct *tty); |
163 | static int ti_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); | 163 | static int ti_ioctl(struct tty_struct *tty, struct file *file, |
164 | static void ti_set_termios(struct tty_struct *tty, struct usb_serial_port *port, | 164 | unsigned int cmd, unsigned long arg); |
165 | struct ktermios *old_termios); | 165 | static void ti_set_termios(struct tty_struct *tty, |
166 | struct usb_serial_port *port, struct ktermios *old_termios); | ||
166 | static int ti_tiocmget(struct tty_struct *tty, struct file *file); | 167 | static int ti_tiocmget(struct tty_struct *tty, struct file *file); |
167 | static int ti_tiocmset(struct tty_struct *tty, struct file *file, | 168 | static int ti_tiocmset(struct tty_struct *tty, struct file *file, |
168 | unsigned int set, unsigned int clear); | 169 | unsigned int set, unsigned int clear); |
169 | static void ti_break(struct tty_struct *tty, int break_state); | 170 | static void ti_break(struct tty_struct *tty, int break_state); |
170 | static void ti_interrupt_callback(struct urb *urb); | 171 | static void ti_interrupt_callback(struct urb *urb); |
171 | static void ti_bulk_in_callback(struct urb *urb); | 172 | static void ti_bulk_in_callback(struct urb *urb); |
@@ -327,19 +328,25 @@ module_param(debug, bool, S_IRUGO | S_IWUSR); | |||
327 | MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); | 328 | MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); |
328 | 329 | ||
329 | module_param(low_latency, bool, S_IRUGO | S_IWUSR); | 330 | module_param(low_latency, bool, S_IRUGO | S_IWUSR); |
330 | MODULE_PARM_DESC(low_latency, "TTY low_latency flag, 0=off, 1=on, default is off"); | 331 | MODULE_PARM_DESC(low_latency, |
332 | "TTY low_latency flag, 0=off, 1=on, default is off"); | ||
331 | 333 | ||
332 | module_param(closing_wait, int, S_IRUGO | S_IWUSR); | 334 | module_param(closing_wait, int, S_IRUGO | S_IWUSR); |
333 | MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain in close, in .01 secs, default is 4000"); | 335 | MODULE_PARM_DESC(closing_wait, |
336 | "Maximum wait for data to drain in close, in .01 secs, default is 4000"); | ||
334 | 337 | ||
335 | module_param_array(vendor_3410, ushort, &vendor_3410_count, S_IRUGO); | 338 | module_param_array(vendor_3410, ushort, &vendor_3410_count, S_IRUGO); |
336 | MODULE_PARM_DESC(vendor_3410, "Vendor ids for 3410 based devices, 1-5 short integers"); | 339 | MODULE_PARM_DESC(vendor_3410, |
340 | "Vendor ids for 3410 based devices, 1-5 short integers"); | ||
337 | module_param_array(product_3410, ushort, &product_3410_count, S_IRUGO); | 341 | module_param_array(product_3410, ushort, &product_3410_count, S_IRUGO); |
338 | MODULE_PARM_DESC(product_3410, "Product ids for 3410 based devices, 1-5 short integers"); | 342 | MODULE_PARM_DESC(product_3410, |
343 | "Product ids for 3410 based devices, 1-5 short integers"); | ||
339 | module_param_array(vendor_5052, ushort, &vendor_5052_count, S_IRUGO); | 344 | module_param_array(vendor_5052, ushort, &vendor_5052_count, S_IRUGO); |
340 | MODULE_PARM_DESC(vendor_5052, "Vendor ids for 5052 based devices, 1-5 short integers"); | 345 | MODULE_PARM_DESC(vendor_5052, |
346 | "Vendor ids for 5052 based devices, 1-5 short integers"); | ||
341 | module_param_array(product_5052, ushort, &product_5052_count, S_IRUGO); | 347 | module_param_array(product_5052, ushort, &product_5052_count, S_IRUGO); |
342 | MODULE_PARM_DESC(product_5052, "Product ids for 5052 based devices, 1-5 short integers"); | 348 | MODULE_PARM_DESC(product_5052, |
349 | "Product ids for 5052 based devices, 1-5 short integers"); | ||
343 | 350 | ||
344 | MODULE_DEVICE_TABLE(usb, ti_id_table_combined); | 351 | MODULE_DEVICE_TABLE(usb, ti_id_table_combined); |
345 | 352 | ||
@@ -348,18 +355,18 @@ MODULE_DEVICE_TABLE(usb, ti_id_table_combined); | |||
348 | 355 | ||
349 | static int __init ti_init(void) | 356 | static int __init ti_init(void) |
350 | { | 357 | { |
351 | int i,j; | 358 | int i, j; |
352 | int ret; | 359 | int ret; |
353 | 360 | ||
354 | /* insert extra vendor and product ids */ | 361 | /* insert extra vendor and product ids */ |
355 | j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1; | 362 | j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1; |
356 | for (i=0; i<min(vendor_3410_count,product_3410_count); i++,j++) { | 363 | for (i = 0; i < min(vendor_3410_count, product_3410_count); i++, j++) { |
357 | ti_id_table_3410[j].idVendor = vendor_3410[i]; | 364 | ti_id_table_3410[j].idVendor = vendor_3410[i]; |
358 | ti_id_table_3410[j].idProduct = product_3410[i]; | 365 | ti_id_table_3410[j].idProduct = product_3410[i]; |
359 | ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; | 366 | ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; |
360 | } | 367 | } |
361 | j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1; | 368 | j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1; |
362 | for (i=0; i<min(vendor_5052_count,product_5052_count); i++,j++) { | 369 | for (i = 0; i < min(vendor_5052_count, product_5052_count); i++, j++) { |
363 | ti_id_table_5052[j].idVendor = vendor_5052[i]; | 370 | ti_id_table_5052[j].idVendor = vendor_5052[i]; |
364 | ti_id_table_5052[j].idProduct = product_5052[i]; | 371 | ti_id_table_5052[j].idProduct = product_5052[i]; |
365 | ti_id_table_5052[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; | 372 | ti_id_table_5052[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; |
@@ -428,7 +435,8 @@ static int ti_startup(struct usb_serial *serial) | |||
428 | /* determine device type */ | 435 | /* determine device type */ |
429 | if (usb_match_id(serial->interface, ti_id_table_3410)) | 436 | if (usb_match_id(serial->interface, ti_id_table_3410)) |
430 | tdev->td_is_3410 = 1; | 437 | tdev->td_is_3410 = 1; |
431 | dbg("%s - device type is %s", __func__, tdev->td_is_3410 ? "3410" : "5052"); | 438 | dbg("%s - device type is %s", __func__, |
439 | tdev->td_is_3410 ? "3410" : "5052"); | ||
432 | 440 | ||
433 | /* if we have only 1 configuration, download firmware */ | 441 | /* if we have only 1 configuration, download firmware */ |
434 | if (dev->descriptor.bNumConfigurations == 1) { | 442 | if (dev->descriptor.bNumConfigurations == 1) { |
@@ -447,7 +455,7 @@ static int ti_startup(struct usb_serial *serial) | |||
447 | 455 | ||
448 | status = -ENODEV; | 456 | status = -ENODEV; |
449 | goto free_tdev; | 457 | goto free_tdev; |
450 | } | 458 | } |
451 | 459 | ||
452 | /* the second configuration must be set (in sysfs by hotplug script) */ | 460 | /* the second configuration must be set (in sysfs by hotplug script) */ |
453 | if (dev->actconfig->desc.bConfigurationValue == TI_BOOT_CONFIG) { | 461 | if (dev->actconfig->desc.bConfigurationValue == TI_BOOT_CONFIG) { |
@@ -464,7 +472,8 @@ static int ti_startup(struct usb_serial *serial) | |||
464 | goto free_tports; | 472 | goto free_tports; |
465 | } | 473 | } |
466 | spin_lock_init(&tport->tp_lock); | 474 | spin_lock_init(&tport->tp_lock); |
467 | tport->tp_uart_base_addr = (i == 0 ? TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR); | 475 | tport->tp_uart_base_addr = (i == 0 ? |
476 | TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR); | ||
468 | tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0; | 477 | tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0; |
469 | tport->tp_closing_wait = closing_wait; | 478 | tport->tp_closing_wait = closing_wait; |
470 | init_waitqueue_head(&tport->tp_msr_wait); | 479 | init_waitqueue_head(&tport->tp_msr_wait); |
@@ -481,11 +490,11 @@ static int ti_startup(struct usb_serial *serial) | |||
481 | usb_set_serial_port_data(serial->port[i], tport); | 490 | usb_set_serial_port_data(serial->port[i], tport); |
482 | tport->tp_uart_mode = 0; /* default is RS232 */ | 491 | tport->tp_uart_mode = 0; /* default is RS232 */ |
483 | } | 492 | } |
484 | 493 | ||
485 | return 0; | 494 | return 0; |
486 | 495 | ||
487 | free_tports: | 496 | free_tports: |
488 | for (--i; i>=0; --i) { | 497 | for (--i; i >= 0; --i) { |
489 | tport = usb_get_serial_port_data(serial->port[i]); | 498 | tport = usb_get_serial_port_data(serial->port[i]); |
490 | ti_buf_free(tport->tp_write_buf); | 499 | ti_buf_free(tport->tp_write_buf); |
491 | kfree(tport); | 500 | kfree(tport); |
@@ -506,7 +515,7 @@ static void ti_shutdown(struct usb_serial *serial) | |||
506 | 515 | ||
507 | dbg("%s", __func__); | 516 | dbg("%s", __func__); |
508 | 517 | ||
509 | for (i=0; i < serial->num_ports; ++i) { | 518 | for (i = 0; i < serial->num_ports; ++i) { |
510 | tport = usb_get_serial_port_data(serial->port[i]); | 519 | tport = usb_get_serial_port_data(serial->port[i]); |
511 | if (tport) { | 520 | if (tport) { |
512 | ti_buf_free(tport->tp_write_buf); | 521 | ti_buf_free(tport->tp_write_buf); |
@@ -529,8 +538,8 @@ static int ti_open(struct tty_struct *tty, | |||
529 | struct urb *urb; | 538 | struct urb *urb; |
530 | int port_number; | 539 | int port_number; |
531 | int status; | 540 | int status; |
532 | __u16 open_settings = (__u8)(TI_PIPE_MODE_CONTINOUS | | 541 | __u16 open_settings = (__u8)(TI_PIPE_MODE_CONTINOUS | |
533 | TI_PIPE_TIMEOUT_ENABLE | | 542 | TI_PIPE_TIMEOUT_ENABLE | |
534 | (TI_TRANSFER_TIMEOUT << 2)); | 543 | (TI_TRANSFER_TIMEOUT << 2)); |
535 | 544 | ||
536 | dbg("%s - port %d", __func__, port->number); | 545 | dbg("%s - port %d", __func__, port->number); |
@@ -561,7 +570,8 @@ static int ti_open(struct tty_struct *tty, | |||
561 | dbg("%s - start interrupt in urb", __func__); | 570 | dbg("%s - start interrupt in urb", __func__); |
562 | urb = tdev->td_serial->port[0]->interrupt_in_urb; | 571 | urb = tdev->td_serial->port[0]->interrupt_in_urb; |
563 | if (!urb) { | 572 | if (!urb) { |
564 | dev_err(&port->dev, "%s - no interrupt urb\n", __func__); | 573 | dev_err(&port->dev, "%s - no interrupt urb\n", |
574 | __func__); | ||
565 | status = -EINVAL; | 575 | status = -EINVAL; |
566 | goto release_lock; | 576 | goto release_lock; |
567 | } | 577 | } |
@@ -570,7 +580,9 @@ static int ti_open(struct tty_struct *tty, | |||
570 | urb->dev = dev; | 580 | urb->dev = dev; |
571 | status = usb_submit_urb(urb, GFP_KERNEL); | 581 | status = usb_submit_urb(urb, GFP_KERNEL); |
572 | if (status) { | 582 | if (status) { |
573 | dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __func__, status); | 583 | dev_err(&port->dev, |
584 | "%s - submit interrupt urb failed, %d\n", | ||
585 | __func__, status); | ||
574 | goto release_lock; | 586 | goto release_lock; |
575 | } | 587 | } |
576 | } | 588 | } |
@@ -582,7 +594,8 @@ static int ti_open(struct tty_struct *tty, | |||
582 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, | 594 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, |
583 | (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); | 595 | (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); |
584 | if (status) { | 596 | if (status) { |
585 | dev_err(&port->dev, "%s - cannot send open command, %d\n", __func__, status); | 597 | dev_err(&port->dev, "%s - cannot send open command, %d\n", |
598 | __func__, status); | ||
586 | goto unlink_int_urb; | 599 | goto unlink_int_urb; |
587 | } | 600 | } |
588 | 601 | ||
@@ -590,7 +603,8 @@ static int ti_open(struct tty_struct *tty, | |||
590 | status = ti_command_out_sync(tdev, TI_START_PORT, | 603 | status = ti_command_out_sync(tdev, TI_START_PORT, |
591 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); | 604 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); |
592 | if (status) { | 605 | if (status) { |
593 | dev_err(&port->dev, "%s - cannot send start command, %d\n", __func__, status); | 606 | dev_err(&port->dev, "%s - cannot send start command, %d\n", |
607 | __func__, status); | ||
594 | goto unlink_int_urb; | 608 | goto unlink_int_urb; |
595 | } | 609 | } |
596 | 610 | ||
@@ -598,13 +612,15 @@ static int ti_open(struct tty_struct *tty, | |||
598 | status = ti_command_out_sync(tdev, TI_PURGE_PORT, | 612 | status = ti_command_out_sync(tdev, TI_PURGE_PORT, |
599 | (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0); | 613 | (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0); |
600 | if (status) { | 614 | if (status) { |
601 | dev_err(&port->dev, "%s - cannot clear input buffers, %d\n", __func__, status); | 615 | dev_err(&port->dev, "%s - cannot clear input buffers, %d\n", |
616 | __func__, status); | ||
602 | goto unlink_int_urb; | 617 | goto unlink_int_urb; |
603 | } | 618 | } |
604 | status = ti_command_out_sync(tdev, TI_PURGE_PORT, | 619 | status = ti_command_out_sync(tdev, TI_PURGE_PORT, |
605 | (__u8)(TI_UART1_PORT + port_number), TI_PURGE_OUTPUT, NULL, 0); | 620 | (__u8)(TI_UART1_PORT + port_number), TI_PURGE_OUTPUT, NULL, 0); |
606 | if (status) { | 621 | if (status) { |
607 | dev_err(&port->dev, "%s - cannot clear output buffers, %d\n", __func__, status); | 622 | dev_err(&port->dev, "%s - cannot clear output buffers, %d\n", |
623 | __func__, status); | ||
608 | goto unlink_int_urb; | 624 | goto unlink_int_urb; |
609 | } | 625 | } |
610 | 626 | ||
@@ -620,7 +636,8 @@ static int ti_open(struct tty_struct *tty, | |||
620 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, | 636 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, |
621 | (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); | 637 | (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); |
622 | if (status) { | 638 | if (status) { |
623 | dev_err(&port->dev, "%s - cannot send open command (2), %d\n", __func__, status); | 639 | dev_err(&port->dev, "%s - cannot send open command (2), %d\n", |
640 | __func__, status); | ||
624 | goto unlink_int_urb; | 641 | goto unlink_int_urb; |
625 | } | 642 | } |
626 | 643 | ||
@@ -628,7 +645,8 @@ static int ti_open(struct tty_struct *tty, | |||
628 | status = ti_command_out_sync(tdev, TI_START_PORT, | 645 | status = ti_command_out_sync(tdev, TI_START_PORT, |
629 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); | 646 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); |
630 | if (status) { | 647 | if (status) { |
631 | dev_err(&port->dev, "%s - cannot send start command (2), %d\n", __func__, status); | 648 | dev_err(&port->dev, "%s - cannot send start command (2), %d\n", |
649 | __func__, status); | ||
632 | goto unlink_int_urb; | 650 | goto unlink_int_urb; |
633 | } | 651 | } |
634 | 652 | ||
@@ -646,7 +664,8 @@ static int ti_open(struct tty_struct *tty, | |||
646 | urb->dev = dev; | 664 | urb->dev = dev; |
647 | status = usb_submit_urb(urb, GFP_KERNEL); | 665 | status = usb_submit_urb(urb, GFP_KERNEL); |
648 | if (status) { | 666 | if (status) { |
649 | dev_err(&port->dev, "%s - submit read urb failed, %d\n", __func__, status); | 667 | dev_err(&port->dev, "%s - submit read urb failed, %d\n", |
668 | __func__, status); | ||
650 | goto unlink_int_urb; | 669 | goto unlink_int_urb; |
651 | } | 670 | } |
652 | 671 | ||
@@ -675,7 +694,7 @@ static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, | |||
675 | int do_unlock; | 694 | int do_unlock; |
676 | 695 | ||
677 | dbg("%s - port %d", __func__, port->number); | 696 | dbg("%s - port %d", __func__, port->number); |
678 | 697 | ||
679 | tdev = usb_get_serial_data(port->serial); | 698 | tdev = usb_get_serial_data(port->serial); |
680 | tport = usb_get_serial_port_data(port); | 699 | tport = usb_get_serial_port_data(port); |
681 | if (tdev == NULL || tport == NULL) | 700 | if (tdev == NULL || tport == NULL) |
@@ -695,7 +714,9 @@ static void ti_close(struct tty_struct *tty, struct usb_serial_port *port, | |||
695 | status = ti_command_out_sync(tdev, TI_CLOSE_PORT, | 714 | status = ti_command_out_sync(tdev, TI_CLOSE_PORT, |
696 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); | 715 | (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); |
697 | if (status) | 716 | if (status) |
698 | dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __func__, status); | 717 | dev_err(&port->dev, |
718 | "%s - cannot send close port command, %d\n" | ||
719 | , __func__, status); | ||
699 | 720 | ||
700 | /* if mutex_lock is interrupted, continue anyway */ | 721 | /* if mutex_lock is interrupted, continue anyway */ |
701 | do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock); | 722 | do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock); |
@@ -749,7 +770,7 @@ static int ti_write_room(struct tty_struct *tty) | |||
749 | 770 | ||
750 | if (tport == NULL) | 771 | if (tport == NULL) |
751 | return -ENODEV; | 772 | return -ENODEV; |
752 | 773 | ||
753 | spin_lock_irqsave(&tport->tp_lock, flags); | 774 | spin_lock_irqsave(&tport->tp_lock, flags); |
754 | room = ti_buf_space_avail(tport->tp_write_buf); | 775 | room = ti_buf_space_avail(tport->tp_write_buf); |
755 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 776 | spin_unlock_irqrestore(&tport->tp_lock, flags); |
@@ -810,7 +831,8 @@ static void ti_unthrottle(struct tty_struct *tty) | |||
810 | if (I_IXOFF(tty) || C_CRTSCTS(tty)) { | 831 | if (I_IXOFF(tty) || C_CRTSCTS(tty)) { |
811 | status = ti_restart_read(tport, tty); | 832 | status = ti_restart_read(tport, tty); |
812 | if (status) | 833 | if (status) |
813 | dev_err(&port->dev, "%s - cannot restart read, %d\n", __func__, status); | 834 | dev_err(&port->dev, "%s - cannot restart read, %d\n", |
835 | __func__, status); | ||
814 | } | 836 | } |
815 | } | 837 | } |
816 | 838 | ||
@@ -829,44 +851,42 @@ static int ti_ioctl(struct tty_struct *tty, struct file *file, | |||
829 | return -ENODEV; | 851 | return -ENODEV; |
830 | 852 | ||
831 | switch (cmd) { | 853 | switch (cmd) { |
832 | case TIOCGSERIAL: | 854 | case TIOCGSERIAL: |
833 | dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); | 855 | dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); |
834 | return ti_get_serial_info(tport, (struct serial_struct __user *)arg); | 856 | return ti_get_serial_info(tport, |
835 | break; | 857 | (struct serial_struct __user *)arg); |
836 | 858 | case TIOCSSERIAL: | |
837 | case TIOCSSERIAL: | 859 | dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); |
838 | dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); | 860 | return ti_set_serial_info(tport, |
839 | return ti_set_serial_info(tport, (struct serial_struct __user *)arg); | 861 | (struct serial_struct __user *)arg); |
840 | break; | 862 | case TIOCMIWAIT: |
841 | 863 | dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); | |
842 | case TIOCMIWAIT: | 864 | cprev = tport->tp_icount; |
843 | dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); | 865 | while (1) { |
844 | cprev = tport->tp_icount; | 866 | interruptible_sleep_on(&tport->tp_msr_wait); |
845 | while (1) { | 867 | if (signal_pending(current)) |
846 | interruptible_sleep_on(&tport->tp_msr_wait); | 868 | return -ERESTARTSYS; |
847 | if (signal_pending(current)) | 869 | cnow = tport->tp_icount; |
848 | return -ERESTARTSYS; | 870 | if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && |
849 | cnow = tport->tp_icount; | 871 | cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) |
850 | if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && | 872 | return -EIO; /* no change => error */ |
851 | cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) | 873 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || |
852 | return -EIO; /* no change => error */ | 874 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || |
853 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || | 875 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || |
854 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || | 876 | ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) |
855 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || | 877 | return 0; |
856 | ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) { | 878 | cprev = cnow; |
857 | return 0; | 879 | } |
858 | } | 880 | break; |
859 | cprev = cnow; | 881 | case TIOCGICOUNT: |
860 | } | 882 | dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", |
861 | break; | 883 | __func__, port->number, |
862 | 884 | tport->tp_icount.rx, tport->tp_icount.tx); | |
863 | case TIOCGICOUNT: | 885 | if (copy_to_user((void __user *)arg, &tport->tp_icount, |
864 | dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, tport->tp_icount.rx, tport->tp_icount.tx); | 886 | sizeof(tport->tp_icount))) |
865 | if (copy_to_user((void __user *)arg, &tport->tp_icount, sizeof(tport->tp_icount))) | 887 | return -EFAULT; |
866 | return -EFAULT; | 888 | return 0; |
867 | return 0; | ||
868 | } | 889 | } |
869 | |||
870 | return -ENOIOCTLCMD; | 890 | return -ENOIOCTLCMD; |
871 | } | 891 | } |
872 | 892 | ||
@@ -876,7 +896,7 @@ static void ti_set_termios(struct tty_struct *tty, | |||
876 | { | 896 | { |
877 | struct ti_port *tport = usb_get_serial_port_data(port); | 897 | struct ti_port *tport = usb_get_serial_port_data(port); |
878 | struct ti_uart_config *config; | 898 | struct ti_uart_config *config; |
879 | tcflag_t cflag,iflag; | 899 | tcflag_t cflag, iflag; |
880 | int baud; | 900 | int baud; |
881 | int status; | 901 | int status; |
882 | int port_number = port->number - port->serial->minor; | 902 | int port_number = port->number - port->serial->minor; |
@@ -888,7 +908,8 @@ static void ti_set_termios(struct tty_struct *tty, | |||
888 | iflag = tty->termios->c_iflag; | 908 | iflag = tty->termios->c_iflag; |
889 | 909 | ||
890 | dbg("%s - cflag %08x, iflag %08x", __func__, cflag, iflag); | 910 | dbg("%s - cflag %08x, iflag %08x", __func__, cflag, iflag); |
891 | dbg("%s - old clfag %08x, old iflag %08x", __func__, old_termios->c_cflag, old_termios->c_iflag); | 911 | dbg("%s - old clfag %08x, old iflag %08x", __func__, |
912 | old_termios->c_cflag, old_termios->c_iflag); | ||
892 | 913 | ||
893 | if (tport == NULL) | 914 | if (tport == NULL) |
894 | return; | 915 | return; |
@@ -907,19 +928,19 @@ static void ti_set_termios(struct tty_struct *tty, | |||
907 | config->bUartMode = (__u8)(tport->tp_uart_mode); | 928 | config->bUartMode = (__u8)(tport->tp_uart_mode); |
908 | 929 | ||
909 | switch (cflag & CSIZE) { | 930 | switch (cflag & CSIZE) { |
910 | case CS5: | 931 | case CS5: |
911 | config->bDataBits = TI_UART_5_DATA_BITS; | 932 | config->bDataBits = TI_UART_5_DATA_BITS; |
912 | break; | 933 | break; |
913 | case CS6: | 934 | case CS6: |
914 | config->bDataBits = TI_UART_6_DATA_BITS; | 935 | config->bDataBits = TI_UART_6_DATA_BITS; |
915 | break; | 936 | break; |
916 | case CS7: | 937 | case CS7: |
917 | config->bDataBits = TI_UART_7_DATA_BITS; | 938 | config->bDataBits = TI_UART_7_DATA_BITS; |
918 | break; | 939 | break; |
919 | default: | 940 | default: |
920 | case CS8: | 941 | case CS8: |
921 | config->bDataBits = TI_UART_8_DATA_BITS; | 942 | config->bDataBits = TI_UART_8_DATA_BITS; |
922 | break; | 943 | break; |
923 | } | 944 | } |
924 | 945 | ||
925 | /* CMSPAR isn't supported by this driver */ | 946 | /* CMSPAR isn't supported by this driver */ |
@@ -935,7 +956,7 @@ static void ti_set_termios(struct tty_struct *tty, | |||
935 | } | 956 | } |
936 | } else { | 957 | } else { |
937 | config->wFlags &= ~TI_UART_ENABLE_PARITY_CHECKING; | 958 | config->wFlags &= ~TI_UART_ENABLE_PARITY_CHECKING; |
938 | config->bParity = TI_UART_NO_PARITY; | 959 | config->bParity = TI_UART_NO_PARITY; |
939 | } | 960 | } |
940 | 961 | ||
941 | if (cflag & CSTOPB) | 962 | if (cflag & CSTOPB) |
@@ -988,7 +1009,8 @@ static void ti_set_termios(struct tty_struct *tty, | |||
988 | (__u8)(TI_UART1_PORT + port_number), 0, (__u8 *)config, | 1009 | (__u8)(TI_UART1_PORT + port_number), 0, (__u8 *)config, |
989 | sizeof(*config)); | 1010 | sizeof(*config)); |
990 | if (status) | 1011 | if (status) |
991 | dev_err(&port->dev, "%s - cannot set config on port %d, %d\n", __func__, port_number, status); | 1012 | dev_err(&port->dev, "%s - cannot set config on port %d, %d\n", |
1013 | __func__, port_number, status); | ||
992 | 1014 | ||
993 | /* SET_CONFIG asserts RTS and DTR, reset them correctly */ | 1015 | /* SET_CONFIG asserts RTS and DTR, reset them correctly */ |
994 | mcr = tport->tp_shadow_mcr; | 1016 | mcr = tport->tp_shadow_mcr; |
@@ -997,7 +1019,9 @@ static void ti_set_termios(struct tty_struct *tty, | |||
997 | mcr &= ~(TI_MCR_DTR | TI_MCR_RTS); | 1019 | mcr &= ~(TI_MCR_DTR | TI_MCR_RTS); |
998 | status = ti_set_mcr(tport, mcr); | 1020 | status = ti_set_mcr(tport, mcr); |
999 | if (status) | 1021 | if (status) |
1000 | dev_err(&port->dev, "%s - cannot set modem control on port %d, %d\n", __func__, port_number, status); | 1022 | dev_err(&port->dev, |
1023 | "%s - cannot set modem control on port %d, %d\n", | ||
1024 | __func__, port_number, status); | ||
1001 | 1025 | ||
1002 | kfree(config); | 1026 | kfree(config); |
1003 | } | 1027 | } |
@@ -1139,10 +1163,12 @@ static void ti_interrupt_callback(struct urb *urb) | |||
1139 | port_number = TI_GET_PORT_FROM_CODE(data[0]); | 1163 | port_number = TI_GET_PORT_FROM_CODE(data[0]); |
1140 | function = TI_GET_FUNC_FROM_CODE(data[0]); | 1164 | function = TI_GET_FUNC_FROM_CODE(data[0]); |
1141 | 1165 | ||
1142 | dbg("%s - port_number %d, function %d, data 0x%02X", __func__, port_number, function, data[1]); | 1166 | dbg("%s - port_number %d, function %d, data 0x%02X", |
1167 | __func__, port_number, function, data[1]); | ||
1143 | 1168 | ||
1144 | if (port_number >= serial->num_ports) { | 1169 | if (port_number >= serial->num_ports) { |
1145 | dev_err(dev, "%s - bad port number, %d\n", __func__, port_number); | 1170 | dev_err(dev, "%s - bad port number, %d\n", |
1171 | __func__, port_number); | ||
1146 | goto exit; | 1172 | goto exit; |
1147 | } | 1173 | } |
1148 | 1174 | ||
@@ -1154,7 +1180,8 @@ static void ti_interrupt_callback(struct urb *urb) | |||
1154 | 1180 | ||
1155 | switch (function) { | 1181 | switch (function) { |
1156 | case TI_CODE_DATA_ERROR: | 1182 | case TI_CODE_DATA_ERROR: |
1157 | dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", __func__, port_number, data[1]); | 1183 | dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", |
1184 | __func__, port_number, data[1]); | ||
1158 | break; | 1185 | break; |
1159 | 1186 | ||
1160 | case TI_CODE_MODEM_STATUS: | 1187 | case TI_CODE_MODEM_STATUS: |
@@ -1164,7 +1191,8 @@ static void ti_interrupt_callback(struct urb *urb) | |||
1164 | break; | 1191 | break; |
1165 | 1192 | ||
1166 | default: | 1193 | default: |
1167 | dev_err(dev, "%s - unknown interrupt code, 0x%02X\n", __func__, data[1]); | 1194 | dev_err(dev, "%s - unknown interrupt code, 0x%02X\n", |
1195 | __func__, data[1]); | ||
1168 | break; | 1196 | break; |
1169 | } | 1197 | } |
1170 | 1198 | ||
@@ -1198,7 +1226,7 @@ static void ti_bulk_in_callback(struct urb *urb) | |||
1198 | return; | 1226 | return; |
1199 | default: | 1227 | default: |
1200 | dev_err(dev, "%s - nonzero urb status, %d\n", | 1228 | dev_err(dev, "%s - nonzero urb status, %d\n", |
1201 | __func__, status ); | 1229 | __func__, status); |
1202 | tport->tp_tdev->td_urb_error = 1; | 1230 | tport->tp_tdev->td_urb_error = 1; |
1203 | wake_up_interruptible(&tport->tp_write_wait); | 1231 | wake_up_interruptible(&tport->tp_write_wait); |
1204 | } | 1232 | } |
@@ -1218,8 +1246,9 @@ static void ti_bulk_in_callback(struct urb *urb) | |||
1218 | if (!tport->tp_is_open) | 1246 | if (!tport->tp_is_open) |
1219 | dbg("%s - port closed, dropping data", __func__); | 1247 | dbg("%s - port closed, dropping data", __func__); |
1220 | else | 1248 | else |
1221 | ti_recv(&urb->dev->dev, port->port.tty, urb->transfer_buffer, | 1249 | ti_recv(&urb->dev->dev, port->port.tty, |
1222 | urb->actual_length); | 1250 | urb->transfer_buffer, |
1251 | urb->actual_length); | ||
1223 | 1252 | ||
1224 | spin_lock(&tport->tp_lock); | 1253 | spin_lock(&tport->tp_lock); |
1225 | tport->tp_icount.rx += urb->actual_length; | 1254 | tport->tp_icount.rx += urb->actual_length; |
@@ -1283,8 +1312,9 @@ static void ti_recv(struct device *dev, struct tty_struct *tty, | |||
1283 | do { | 1312 | do { |
1284 | cnt = tty_buffer_request_room(tty, length); | 1313 | cnt = tty_buffer_request_room(tty, length); |
1285 | if (cnt < length) { | 1314 | if (cnt < length) { |
1286 | dev_err(dev, "%s - dropping data, %d bytes lost\n", __func__, length - cnt); | 1315 | dev_err(dev, "%s - dropping data, %d bytes lost\n", |
1287 | if(cnt == 0) | 1316 | __func__, length - cnt); |
1317 | if (cnt == 0) | ||
1288 | break; | 1318 | break; |
1289 | } | 1319 | } |
1290 | tty_insert_flip_string(tty, data, cnt); | 1320 | tty_insert_flip_string(tty, data, cnt); |
@@ -1326,7 +1356,8 @@ static void ti_send(struct ti_port *tport) | |||
1326 | 1356 | ||
1327 | spin_unlock_irqrestore(&tport->tp_lock, flags); | 1357 | spin_unlock_irqrestore(&tport->tp_lock, flags); |
1328 | 1358 | ||
1329 | usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer); | 1359 | usb_serial_debug_data(debug, &port->dev, __func__, count, |
1360 | port->write_urb->transfer_buffer); | ||
1330 | 1361 | ||
1331 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | 1362 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, |
1332 | usb_sndbulkpipe(port->serial->dev, | 1363 | usb_sndbulkpipe(port->serial->dev, |
@@ -1336,8 +1367,9 @@ static void ti_send(struct ti_port *tport) | |||
1336 | 1367 | ||
1337 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 1368 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
1338 | if (result) { | 1369 | if (result) { |
1339 | dev_err(&port->dev, "%s - submit write urb failed, %d\n", __func__, result); | 1370 | dev_err(&port->dev, "%s - submit write urb failed, %d\n", |
1340 | tport->tp_write_urb_in_use = 0; | 1371 | __func__, result); |
1372 | tport->tp_write_urb_in_use = 0; | ||
1341 | /* TODO: reschedule ti_send */ | 1373 | /* TODO: reschedule ti_send */ |
1342 | } else { | 1374 | } else { |
1343 | spin_lock_irqsave(&tport->tp_lock, flags); | 1375 | spin_lock_irqsave(&tport->tp_lock, flags); |
@@ -1372,7 +1404,7 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr) | |||
1372 | 1404 | ||
1373 | static int ti_get_lsr(struct ti_port *tport) | 1405 | static int ti_get_lsr(struct ti_port *tport) |
1374 | { | 1406 | { |
1375 | int size,status; | 1407 | int size, status; |
1376 | struct ti_device *tdev = tport->tp_tdev; | 1408 | struct ti_device *tdev = tport->tp_tdev; |
1377 | struct usb_serial_port *port = tport->tp_port; | 1409 | struct usb_serial_port *port = tport->tp_port; |
1378 | int port_number = port->number - port->serial->minor; | 1410 | int port_number = port->number - port->serial->minor; |
@@ -1390,7 +1422,9 @@ static int ti_get_lsr(struct ti_port *tport) | |||
1390 | status = ti_command_in_sync(tdev, TI_GET_PORT_STATUS, | 1422 | status = ti_command_in_sync(tdev, TI_GET_PORT_STATUS, |
1391 | (__u8)(TI_UART1_PORT+port_number), 0, (__u8 *)data, size); | 1423 | (__u8)(TI_UART1_PORT+port_number), 0, (__u8 *)data, size); |
1392 | if (status) { | 1424 | if (status) { |
1393 | dev_err(&port->dev, "%s - get port status command failed, %d\n", __func__, status); | 1425 | dev_err(&port->dev, |
1426 | "%s - get port status command failed, %d\n", | ||
1427 | __func__, status); | ||
1394 | goto free_data; | 1428 | goto free_data; |
1395 | } | 1429 | } |
1396 | 1430 | ||
@@ -1626,7 +1660,8 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr, | |||
1626 | struct ti_write_data_bytes *data; | 1660 | struct ti_write_data_bytes *data; |
1627 | struct device *dev = &tdev->td_serial->dev->dev; | 1661 | struct device *dev = &tdev->td_serial->dev->dev; |
1628 | 1662 | ||
1629 | dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", __func__, addr, mask, byte); | 1663 | dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", |
1664 | __func__, addr, mask, byte); | ||
1630 | 1665 | ||
1631 | size = sizeof(struct ti_write_data_bytes) + 2; | 1666 | size = sizeof(struct ti_write_data_bytes) + 2; |
1632 | data = kmalloc(size, GFP_KERNEL); | 1667 | data = kmalloc(size, GFP_KERNEL); |
@@ -1663,12 +1698,12 @@ static int ti_do_download(struct usb_device *dev, int pipe, | |||
1663 | struct ti_firmware_header *header; | 1698 | struct ti_firmware_header *header; |
1664 | int status; | 1699 | int status; |
1665 | int len; | 1700 | int len; |
1666 | 1701 | ||
1667 | for(pos = sizeof(struct ti_firmware_header); pos < size; pos++) | 1702 | for (pos = sizeof(struct ti_firmware_header); pos < size; pos++) |
1668 | cs = (__u8)(cs + buffer[pos]); | 1703 | cs = (__u8)(cs + buffer[pos]); |
1669 | 1704 | ||
1670 | header = (struct ti_firmware_header *)buffer; | 1705 | header = (struct ti_firmware_header *)buffer; |
1671 | header->wLength = cpu_to_le16((__u16)(size | 1706 | header->wLength = cpu_to_le16((__u16)(size |
1672 | - sizeof(struct ti_firmware_header))); | 1707 | - sizeof(struct ti_firmware_header))); |
1673 | header->bCheckSum = cs; | 1708 | header->bCheckSum = cs; |
1674 | 1709 | ||
@@ -1714,7 +1749,8 @@ static int ti_download_firmware(struct ti_device *tdev, int type) | |||
1714 | } | 1749 | } |
1715 | release_firmware(fw_p); | 1750 | release_firmware(fw_p); |
1716 | if (status) { | 1751 | if (status) { |
1717 | dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status); | 1752 | dev_err(&dev->dev, "%s - error downloading firmware, %d\n", |
1753 | __func__, status); | ||
1718 | return status; | 1754 | return status; |
1719 | } | 1755 | } |
1720 | 1756 | ||
@@ -1786,7 +1822,7 @@ static void ti_buf_clear(struct circ_buf *cb) | |||
1786 | 1822 | ||
1787 | static int ti_buf_data_avail(struct circ_buf *cb) | 1823 | static int ti_buf_data_avail(struct circ_buf *cb) |
1788 | { | 1824 | { |
1789 | return CIRC_CNT(cb->head,cb->tail,TI_WRITE_BUF_SIZE); | 1825 | return CIRC_CNT(cb->head, cb->tail, TI_WRITE_BUF_SIZE); |
1790 | } | 1826 | } |
1791 | 1827 | ||
1792 | 1828 | ||
@@ -1799,7 +1835,7 @@ static int ti_buf_data_avail(struct circ_buf *cb) | |||
1799 | 1835 | ||
1800 | static int ti_buf_space_avail(struct circ_buf *cb) | 1836 | static int ti_buf_space_avail(struct circ_buf *cb) |
1801 | { | 1837 | { |
1802 | return CIRC_SPACE(cb->head,cb->tail,TI_WRITE_BUF_SIZE); | 1838 | return CIRC_SPACE(cb->head, cb->tail, TI_WRITE_BUF_SIZE); |
1803 | } | 1839 | } |
1804 | 1840 | ||
1805 | 1841 | ||