diff options
| author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-03-24 12:39:28 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-04-03 17:54:27 -0400 |
| commit | c23ee6c30e951521cc1371094d8cf472610b7026 (patch) | |
| tree | 2f75911276ac6e0440c77f8bd73f4f07f4c3bf19 | |
| parent | 68bf9916d5ba55c81edee7cc9dfb1ab63792cb4f (diff) | |
Staging: serqt_usb: fix checkpatch errors
Clean up the code so it's at least readable now, fixing the
checkpatch errors.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | drivers/staging/serqt_usb/serqt_usb.c | 705 |
1 files changed, 343 insertions, 362 deletions
diff --git a/drivers/staging/serqt_usb/serqt_usb.c b/drivers/staging/serqt_usb/serqt_usb.c index c9a7499c7866..3b73c782e3c9 100644 --- a/drivers/staging/serqt_usb/serqt_usb.c +++ b/drivers/staging/serqt_usb/serqt_usb.c | |||
| @@ -13,12 +13,11 @@ | |||
| 13 | #include <linux/wait.h> | 13 | #include <linux/wait.h> |
| 14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
| 15 | #include <linux/version.h> | 15 | #include <linux/version.h> |
| 16 | 16 | #include <linux/uaccess.h> | |
| 17 | #include <asm/uaccess.h> | ||
| 18 | 17 | ||
| 19 | /* Use our own dbg macro */ | 18 | /* Use our own dbg macro */ |
| 20 | //#define DEBUG_ON | 19 | /* #define DEBUG_ON */ |
| 21 | //#undef dbg | 20 | /* #undef dbg */ |
| 22 | #ifdef DEBUG_ON | 21 | #ifdef DEBUG_ON |
| 23 | #define mydbg(const...) printk(const) | 22 | #define mydbg(const...) printk(const) |
| 24 | #else | 23 | #else |
| @@ -34,14 +33,14 @@ | |||
| 34 | #define PREFUFF_LEVEL_CONSERVATIVE 128 | 33 | #define PREFUFF_LEVEL_CONSERVATIVE 128 |
| 35 | #define ATC_DISABLED 0x00 | 34 | #define ATC_DISABLED 0x00 |
| 36 | 35 | ||
| 37 | #define RR_BITS 0x03 //for clearing clock bits | 36 | #define RR_BITS 0x03 /* for clearing clock bits */ |
| 38 | #define DUPMODE_BITS 0xc0 | 37 | #define DUPMODE_BITS 0xc0 |
| 39 | 38 | ||
| 40 | #define RS232_MODE 0x00 | 39 | #define RS232_MODE 0x00 |
| 41 | #define RTSCTS_TO_CONNECTOR 0x40 | 40 | #define RTSCTS_TO_CONNECTOR 0x40 |
| 42 | #define CLKS_X4 0x02 /// | 41 | #define CLKS_X4 0x02 |
| 43 | 42 | ||
| 44 | #define LOOPMODE_BITS 0x41 //LOOP1 = b6, LOOP0 = b0 (PORT B) | 43 | #define LOOPMODE_BITS 0x41 /* LOOP1 = b6, LOOP0 = b0 (PORT B) */ |
| 45 | #define ALL_LOOPBACK 0x01 | 44 | #define ALL_LOOPBACK 0x01 |
| 46 | #define MODEM_CTRL 0x40 | 45 | #define MODEM_CTRL 0x40 |
| 47 | 46 | ||
| @@ -50,8 +49,9 @@ | |||
| 50 | #define THIRDCHAR data[i + 2] | 49 | #define THIRDCHAR data[i + 2] |
| 51 | #define FOURTHCHAR data[i + 3] | 50 | #define FOURTHCHAR data[i + 3] |
| 52 | 51 | ||
| 53 | //************************************************* | 52 | /* |
| 54 | // Useful defintions for port A, Port B and Port C | 53 | * Useful defintions for port A, Port B and Port C |
| 54 | */ | ||
| 55 | #define FULLPWRBIT 0x00000080 | 55 | #define FULLPWRBIT 0x00000080 |
| 56 | #define NEXT_BOARD_POWER_BIT 0x00000004 | 56 | #define NEXT_BOARD_POWER_BIT 0x00000004 |
| 57 | 57 | ||
| @@ -113,7 +113,7 @@ | |||
| 113 | #define SERIALQT_GET_THIS_UNIT _IOR(SERIALQT_PCI_IOC_MAGIC, 3, void *) | 113 | #define SERIALQT_GET_THIS_UNIT _IOR(SERIALQT_PCI_IOC_MAGIC, 3, void *) |
| 114 | #define SERIALQT_READ_QOPR _IOR(SERIALQT_PCI_IOC_MAGIC, 4, int) | 114 | #define SERIALQT_READ_QOPR _IOR(SERIALQT_PCI_IOC_MAGIC, 4, int) |
| 115 | #define SERIALQT_READ_QMCR _IOR(SERIALQT_PCI_IOC_MAGIC, 5, int) | 115 | #define SERIALQT_READ_QMCR _IOR(SERIALQT_PCI_IOC_MAGIC, 5, int) |
| 116 | #define SERIALQT_IS422_EXTENDED _IOR(SERIALQT_PCI_IOC_MAGIC, 6, int) //returns successful if 422 extended | 116 | #define SERIALQT_IS422_EXTENDED _IOR(SERIALQT_PCI_IOC_MAGIC, 6, int) /* returns successful if 422 extended */ |
| 117 | 117 | ||
| 118 | #define USBD_TRANSFER_DIRECTION_IN 0xc0 | 118 | #define USBD_TRANSFER_DIRECTION_IN 0xc0 |
| 119 | #define USBD_TRANSFER_DIRECTION_OUT 0x40 | 119 | #define USBD_TRANSFER_DIRECTION_OUT 0x40 |
| @@ -122,7 +122,7 @@ | |||
| 122 | #define ATC_RTS_ENABLED 0x02 | 122 | #define ATC_RTS_ENABLED 0x02 |
| 123 | #define ATC_DTR_ENABLED 0x01 | 123 | #define ATC_DTR_ENABLED 0x01 |
| 124 | 124 | ||
| 125 | #define RR_BITS 0x03 //for clearing clock bits | 125 | #define RR_BITS 0x03 /* for clearing clock bits */ |
| 126 | #define DUPMODE_BITS 0xc0 | 126 | #define DUPMODE_BITS 0xc0 |
| 127 | 127 | ||
| 128 | #define FULL_DUPLEX 0x00 | 128 | #define FULL_DUPLEX 0x00 |
| @@ -304,7 +304,7 @@ static int BoxOPenCloseChannel(struct usb_serial *serial, __u16 Uart_Number, | |||
| 304 | struct qt_open_channel_data *pDeviceData); | 304 | struct qt_open_channel_data *pDeviceData); |
| 305 | static void qt_close(struct usb_serial_port *port, struct file *filp); | 305 | static void qt_close(struct usb_serial_port *port, struct file *filp); |
| 306 | static int BoxGetRegister(struct usb_serial *serial, unsigned short Uart_Number, | 306 | static int BoxGetRegister(struct usb_serial *serial, unsigned short Uart_Number, |
| 307 | unsigned short Register_Num, __u8 * pValue); | 307 | unsigned short Register_Num, __u8 *pValue); |
| 308 | static int BoxSetRegister(struct usb_serial *serial, unsigned short Uart_Number, | 308 | static int BoxSetRegister(struct usb_serial *serial, unsigned short Uart_Number, |
| 309 | unsigned short Register_Num, unsigned short Value); | 309 | unsigned short Register_Num, unsigned short Value); |
| 310 | static void qt_write_bulk_callback(struct urb *urb); | 310 | static void qt_write_bulk_callback(struct urb *urb); |
| @@ -323,7 +323,7 @@ static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber); | |||
| 323 | static int EmulateWriteQMCR_Reg(int index, unsigned uc_value); | 323 | static int EmulateWriteQMCR_Reg(int index, unsigned uc_value); |
| 324 | static int EmulateReadQMCR_Reg(int index, unsigned *uc_value); | 324 | static int EmulateReadQMCR_Reg(int index, unsigned *uc_value); |
| 325 | static struct usb_serial *find_the_box(unsigned int index); | 325 | static struct usb_serial *find_the_box(unsigned int index); |
| 326 | int ioctl_serial_usb(struct inode *innod, struct file *filp, unsigned int cmd, | 326 | static int ioctl_serial_usb(struct inode *innod, struct file *filp, unsigned int cmd, |
| 327 | unsigned long arg); | 327 | unsigned long arg); |
| 328 | 328 | ||
| 329 | static int BoxSetSW_FlowCtrl(struct usb_serial *serial, __u16 Uart, | 329 | static int BoxSetSW_FlowCtrl(struct usb_serial *serial, __u16 Uart, |
| @@ -348,25 +348,25 @@ static int qt_tiocmget(struct usb_serial_port *port, struct file *file); | |||
| 348 | #define DRIVER_AUTHOR "Tim Gobeli, Quatech, Inc" | 348 | #define DRIVER_AUTHOR "Tim Gobeli, Quatech, Inc" |
| 349 | #define DRIVER_DESC "Quatech USB to Serial Driver" | 349 | #define DRIVER_DESC "Quatech USB to Serial Driver" |
| 350 | 350 | ||
| 351 | #define USB_VENDOR_ID_QUATECH 0x061d // Quatech VID | 351 | #define USB_VENDOR_ID_QUATECH 0x061d /* Quatech VID */ |
| 352 | #define DEVICE_ID_QUATECH_RS232_SINGLE_PORT 0xC020 //SSU100 | 352 | #define DEVICE_ID_QUATECH_RS232_SINGLE_PORT 0xC020 /* SSU100 */ |
| 353 | #define DEVICE_ID_QUATECH_RS422_SINGLE_PORT 0xC030 //SSU200 | 353 | #define DEVICE_ID_QUATECH_RS422_SINGLE_PORT 0xC030 /* SSU200 */ |
| 354 | #define DEVICE_ID_QUATECH_RS232_DUAL_PORT 0xC040 //DSU100 | 354 | #define DEVICE_ID_QUATECH_RS232_DUAL_PORT 0xC040 /* DSU100 */ |
| 355 | #define DEVICE_ID_QUATECH_RS422_DUAL_PORT 0xC050 //DSU200 | 355 | #define DEVICE_ID_QUATECH_RS422_DUAL_PORT 0xC050 /* DSU200 */ |
| 356 | #define DEVICE_ID_QUATECH_RS232_FOUR_PORT 0xC060 //QSU100 | 356 | #define DEVICE_ID_QUATECH_RS232_FOUR_PORT 0xC060 /* QSU100 */ |
| 357 | #define DEVICE_ID_QUATECH_RS422_FOUR_PORT 0xC070 //QSU200 | 357 | #define DEVICE_ID_QUATECH_RS422_FOUR_PORT 0xC070 /* QSU200 */ |
| 358 | #define DEVICE_ID_QUATECH_RS232_EIGHT_PORT_A 0xC080 //ESU100A | 358 | #define DEVICE_ID_QUATECH_RS232_EIGHT_PORT_A 0xC080 /* ESU100A */ |
| 359 | #define DEVICE_ID_QUATECH_RS232_EIGHT_PORT_B 0xC081 //ESU100B | 359 | #define DEVICE_ID_QUATECH_RS232_EIGHT_PORT_B 0xC081 /* ESU100B */ |
| 360 | #define DEVICE_ID_QUATECH_RS422_EIGHT_PORT_A 0xC0A0 //ESU200A | 360 | #define DEVICE_ID_QUATECH_RS422_EIGHT_PORT_A 0xC0A0 /* ESU200A */ |
| 361 | #define DEVICE_ID_QUATECH_RS422_EIGHT_PORT_B 0xC0A1 //ESU200B | 361 | #define DEVICE_ID_QUATECH_RS422_EIGHT_PORT_B 0xC0A1 /* ESU200B */ |
| 362 | #define DEVICE_ID_QUATECH_RS232_16_PORT_A 0xC090 //HSU100A | 362 | #define DEVICE_ID_QUATECH_RS232_16_PORT_A 0xC090 /* HSU100A */ |
| 363 | #define DEVICE_ID_QUATECH_RS232_16_PORT_B 0xC091 //HSU100B | 363 | #define DEVICE_ID_QUATECH_RS232_16_PORT_B 0xC091 /* HSU100B */ |
| 364 | #define DEVICE_ID_QUATECH_RS232_16_PORT_C 0xC092 //HSU100C | 364 | #define DEVICE_ID_QUATECH_RS232_16_PORT_C 0xC092 /* HSU100C */ |
| 365 | #define DEVICE_ID_QUATECH_RS232_16_PORT_D 0xC093 //HSU100D | 365 | #define DEVICE_ID_QUATECH_RS232_16_PORT_D 0xC093 /* HSU100D */ |
| 366 | #define DEVICE_ID_QUATECH_RS422_16_PORT_A 0xC0B0 //HSU200A | 366 | #define DEVICE_ID_QUATECH_RS422_16_PORT_A 0xC0B0 /* HSU200A */ |
| 367 | #define DEVICE_ID_QUATECH_RS422_16_PORT_B 0xC0B1 //HSU200B | 367 | #define DEVICE_ID_QUATECH_RS422_16_PORT_B 0xC0B1 /* HSU200B */ |
| 368 | #define DEVICE_ID_QUATECH_RS422_16_PORT_C 0xC0B2 //HSU200C | 368 | #define DEVICE_ID_QUATECH_RS422_16_PORT_C 0xC0B2 /* HSU200C */ |
| 369 | #define DEVICE_ID_QUATECH_RS422_16_PORT_D 0xC0B3 //HSU200D | 369 | #define DEVICE_ID_QUATECH_RS422_16_PORT_D 0xC0B3 /* HSU200D */ |
| 370 | 370 | ||
| 371 | /* table of Quatech devices */ | 371 | /* table of Quatech devices */ |
| 372 | static struct usb_device_id serqt_table[] = { | 372 | static struct usb_device_id serqt_table[] = { |
| @@ -465,10 +465,9 @@ static struct tty_driver serial_tty_driver = { | |||
| 465 | ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN, | 465 | ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN, |
| 466 | }; | 466 | }; |
| 467 | 467 | ||
| 468 | //fops for parent device | 468 | /* fops for parent device */ |
| 469 | static struct file_operations serialqt_usb_fops = { | 469 | static const struct file_operations serialqt_usb_fops = { |
| 470 | .ioctl = ioctl_serial_usb, | 470 | .ioctl = ioctl_serial_usb, |
| 471 | |||
| 472 | }; | 471 | }; |
| 473 | 472 | ||
| 474 | /** | 473 | /** |
| @@ -499,7 +498,7 @@ static int serqt_probe(struct usb_interface *interface, | |||
| 499 | struct qt_get_device_data DeviceData; | 498 | struct qt_get_device_data DeviceData; |
| 500 | int status; | 499 | int status; |
| 501 | 500 | ||
| 502 | mydbg("In %s\n", __FUNCTION__); | 501 | mydbg("In %s\n", __func__); |
| 503 | 502 | ||
| 504 | /* let's find the endpoints needed */ | 503 | /* let's find the endpoints needed */ |
| 505 | /* check out the endpoints */ | 504 | /* check out the endpoints */ |
| @@ -605,10 +604,9 @@ static int serqt_probe(struct usb_interface *interface, | |||
| 605 | 604 | ||
| 606 | } | 605 | } |
| 607 | 606 | ||
| 608 | //For us numb of bulkin or out = number of ports | 607 | /* For us numb of bulkin or out = number of ports */ |
| 609 | |||
| 610 | mydbg("%s - setting up %d port structures for this device\n", | 608 | mydbg("%s - setting up %d port structures for this device\n", |
| 611 | __FUNCTION__, num_bulk_in); | 609 | __func__, num_bulk_in); |
| 612 | for (i = 0; i < num_bulk_in; ++i) { | 610 | for (i = 0; i < num_bulk_in; ++i) { |
| 613 | port = &serial->port[i]; | 611 | port = &serial->port[i]; |
| 614 | port->number = i + serial->minor; | 612 | port->number = i + serial->minor; |
| @@ -643,16 +641,18 @@ static int serqt_probe(struct usb_interface *interface, | |||
| 643 | serial->port[i].number, serial->port[i].number); | 641 | serial->port[i].number, serial->port[i].number); |
| 644 | } | 642 | } |
| 645 | 643 | ||
| 646 | //usb_serial_console_init (debug, minor); | 644 | /* usb_serial_console_init (debug, minor); */ |
| 647 | 645 | ||
| 648 | ///***********TAG add start next board here ****/// | 646 | /***********TAG add start next board here ****/ |
| 649 | status = box_get_device(serial, &DeviceData); | 647 | status = box_get_device(serial, &DeviceData); |
| 650 | if (status < 0) { | 648 | if (status < 0) { |
| 651 | mydbg(__FILE__ "box_get_device failed"); | 649 | mydbg(__FILE__ "box_get_device failed"); |
| 652 | goto probe_error; | 650 | goto probe_error; |
| 653 | } | 651 | } |
| 654 | //*****************and before we power up lets initialiaze parnent device stuff here before | 652 | /* |
| 655 | //*****************we set thmem via any other method such as the property pages | 653 | * and before we power up lets initialiaze parnent device stuff here before |
| 654 | * we set thmem via any other method such as the property pages | ||
| 655 | */ | ||
| 656 | switch (serial->product) { | 656 | switch (serial->product) { |
| 657 | case DEVICE_ID_QUATECH_RS232_SINGLE_PORT: | 657 | case DEVICE_ID_QUATECH_RS232_SINGLE_PORT: |
| 658 | case DEVICE_ID_QUATECH_RS232_DUAL_PORT: | 658 | case DEVICE_ID_QUATECH_RS232_DUAL_PORT: |
| @@ -691,7 +691,7 @@ static int serqt_probe(struct usb_interface *interface, | |||
| 691 | break; | 691 | break; |
| 692 | 692 | ||
| 693 | } | 693 | } |
| 694 | status = BoxSetPrebufferLevel(serial); //sets to default vaue | 694 | status = BoxSetPrebufferLevel(serial); /* sets to default vaue */ |
| 695 | if (status < 0) { | 695 | if (status < 0) { |
| 696 | mydbg(__FILE__ "BoxSetPrebufferLevel failed\n"); | 696 | mydbg(__FILE__ "BoxSetPrebufferLevel failed\n"); |
| 697 | goto probe_error; | 697 | goto probe_error; |
| @@ -702,7 +702,7 @@ static int serqt_probe(struct usb_interface *interface, | |||
| 702 | mydbg(__FILE__ "BoxSetATC failed\n"); | 702 | mydbg(__FILE__ "BoxSetATC failed\n"); |
| 703 | goto probe_error; | 703 | goto probe_error; |
| 704 | } | 704 | } |
| 705 | //**************************************************************************** | 705 | /**********************************************************/ |
| 706 | mydbg(__FILE__ "DeviceData.portb = 0x%x", DeviceData.portb); | 706 | mydbg(__FILE__ "DeviceData.portb = 0x%x", DeviceData.portb); |
| 707 | 707 | ||
| 708 | DeviceData.portb |= NEXT_BOARD_POWER_BIT; | 708 | DeviceData.portb |= NEXT_BOARD_POWER_BIT; |
| @@ -714,7 +714,7 @@ static int serqt_probe(struct usb_interface *interface, | |||
| 714 | goto probe_error; | 714 | goto probe_error; |
| 715 | } | 715 | } |
| 716 | 716 | ||
| 717 | mydbg("Exit Success %s\n", __FUNCTION__); | 717 | mydbg("Exit Success %s\n", __func__); |
| 718 | 718 | ||
| 719 | usb_set_intfdata(interface, serial); | 719 | usb_set_intfdata(interface, serial); |
| 720 | return 0; | 720 | return 0; |
| @@ -723,69 +723,64 @@ probe_error: | |||
| 723 | 723 | ||
| 724 | for (i = 0; i < num_bulk_in; ++i) { | 724 | for (i = 0; i < num_bulk_in; ++i) { |
| 725 | port = &serial->port[i]; | 725 | port = &serial->port[i]; |
| 726 | if (port->read_urb) | 726 | usb_free_urb(port->read_urb); |
| 727 | usb_free_urb(port->read_urb); | 727 | kfree(port->bulk_in_buffer); |
| 728 | if (port->bulk_in_buffer) | ||
| 729 | kfree(port->bulk_in_buffer); | ||
| 730 | } | 728 | } |
| 731 | for (i = 0; i < num_bulk_out; ++i) { | 729 | for (i = 0; i < num_bulk_out; ++i) { |
| 732 | port = &serial->port[i]; | 730 | port = &serial->port[i]; |
| 733 | if (port->write_urb) | 731 | usb_free_urb(port->write_urb); |
| 734 | usb_free_urb(port->write_urb); | 732 | kfree(port->bulk_out_buffer); |
| 735 | if (port->bulk_out_buffer) | 733 | kfree(port->xfer_to_tty_buffer); |
| 736 | kfree(port->bulk_out_buffer); | ||
| 737 | |||
| 738 | if (port->xfer_to_tty_buffer) | ||
| 739 | kfree(port->xfer_to_tty_buffer); | ||
| 740 | } | 734 | } |
| 741 | for (i = 0; i < num_interrupt_in; ++i) { | 735 | for (i = 0; i < num_interrupt_in; ++i) { |
| 742 | port = &serial->port[i]; | 736 | port = &serial->port[i]; |
| 743 | if (port->interrupt_in_urb) | 737 | usb_free_urb(port->interrupt_in_urb); |
| 744 | usb_free_urb(port->interrupt_in_urb); | 738 | kfree(port->interrupt_in_buffer); |
| 745 | if (port->interrupt_in_buffer) | ||
| 746 | kfree(port->interrupt_in_buffer); | ||
| 747 | } | 739 | } |
| 748 | 740 | ||
| 749 | /* return the minor range that this device had */ | 741 | /* return the minor range that this device had */ |
| 750 | return_serial(serial); | 742 | return_serial(serial); |
| 751 | mydbg("Exit fail %s\n", __FUNCTION__); | 743 | mydbg("Exit fail %s\n", __func__); |
| 752 | 744 | ||
| 753 | /* free up any memory that we allocated */ | 745 | /* free up any memory that we allocated */ |
| 754 | kfree(serial); | 746 | kfree(serial); |
| 755 | return -EIO; | 747 | return -EIO; |
| 756 | } | 748 | } |
| 757 | 749 | ||
| 758 | //returns the serial_table array pointers that are taken | 750 | /* |
| 759 | //up in consecutive positions for each port to a common usb_serial structure | 751 | * returns the serial_table array pointers that are taken |
| 760 | //back to NULL | 752 | * up in consecutive positions for each port to a common usb_serial structure |
| 753 | * back to NULL | ||
| 754 | */ | ||
| 761 | static void return_serial(struct usb_serial *serial) | 755 | static void return_serial(struct usb_serial *serial) |
| 762 | { | 756 | { |
| 763 | int i; | 757 | int i; |
| 764 | 758 | ||
| 765 | mydbg("%s\n", __FUNCTION__); | 759 | mydbg("%s\n", __func__); |
| 766 | 760 | ||
| 767 | if (serial == NULL) | 761 | if (serial == NULL) |
| 768 | return; | 762 | return; |
| 769 | 763 | ||
| 770 | for (i = 0; i < serial->num_ports; ++i) { | 764 | for (i = 0; i < serial->num_ports; ++i) |
| 771 | serial_table[serial->minor + i] = NULL; | 765 | serial_table[serial->minor + i] = NULL; |
| 772 | } | ||
| 773 | 766 | ||
| 774 | return; | 767 | return; |
| 775 | } | 768 | } |
| 776 | 769 | ||
| 777 | //Finds the first locatio int the serial_table array where it can fit | 770 | /* |
| 778 | //num_ports number of consecutive points to a common usb_serial structure | 771 | * Finds the first locatio int the serial_table array where it can fit |
| 779 | //,allocates a stucture points to it in all the structures, and returns the index | 772 | * num_ports number of consecutive points to a common usb_serial |
| 780 | //to the first location in the array in the "minor" variable. | 773 | * structure,allocates a stucture points to it in all the structures, and |
| 781 | 774 | * returns the index to the first location in the array in the "minor" | |
| 775 | * variable. | ||
| 776 | */ | ||
| 782 | static struct usb_serial *get_free_serial(int num_ports, int *minor) | 777 | static struct usb_serial *get_free_serial(int num_ports, int *minor) |
| 783 | { | 778 | { |
| 784 | struct usb_serial *serial = NULL; | 779 | struct usb_serial *serial = NULL; |
| 785 | int i, j; | 780 | int i, j; |
| 786 | int good_spot; | 781 | int good_spot; |
| 787 | 782 | ||
| 788 | mydbg("%s %d\n", __FUNCTION__, num_ports); | 783 | mydbg("%s %d\n", __func__, num_ports); |
| 789 | 784 | ||
| 790 | *minor = 0; | 785 | *minor = 0; |
| 791 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { | 786 | for (i = 0; i < SERIAL_TTY_MINORS; ++i) { |
| @@ -793,25 +788,31 @@ static struct usb_serial *get_free_serial(int num_ports, int *minor) | |||
| 793 | continue; | 788 | continue; |
| 794 | 789 | ||
| 795 | good_spot = 1; | 790 | good_spot = 1; |
| 796 | //find a spot in the array where you can fit consecutive positions | 791 | /* |
| 797 | //to put the pointers to the usb_serail allocated structure for all | 792 | * find a spot in the array where you can fit consecutive |
| 798 | //the minor numbers (ie. ports) | 793 | * positions to put the pointers to the usb_serail allocated |
| 794 | * structure for all the minor numbers (ie. ports) | ||
| 795 | */ | ||
| 799 | for (j = 1; j <= num_ports - 1; ++j) | 796 | for (j = 1; j <= num_ports - 1; ++j) |
| 800 | if (serial_table[i + j]) | 797 | if (serial_table[i + j]) |
| 801 | good_spot = 0; | 798 | good_spot = 0; |
| 802 | if (good_spot == 0) | 799 | if (good_spot == 0) |
| 803 | continue; | 800 | continue; |
| 804 | 801 | ||
| 805 | if (!(serial = kmalloc(sizeof(struct usb_serial), GFP_KERNEL))) { | 802 | serial = kmalloc(sizeof(struct usb_serial), GFP_KERNEL); |
| 806 | err("%s - Out of memory", __FUNCTION__); | 803 | if (!serial) { |
| 804 | err("%s - Out of memory", __func__); | ||
| 807 | return NULL; | 805 | return NULL; |
| 808 | } | 806 | } |
| 809 | memset(serial, 0, sizeof(struct usb_serial)); | 807 | memset(serial, 0, sizeof(struct usb_serial)); |
| 810 | serial_table[i] = serial; | 808 | serial_table[i] = serial; |
| 811 | *minor = i; | 809 | *minor = i; |
| 812 | mydbg("%s - minor base = %d\n", __FUNCTION__, *minor); | 810 | mydbg("%s - minor base = %d\n", __func__, *minor); |
| 813 | //copy in the pointer into the array starting a the *minor position | 811 | |
| 814 | //*minor is the index into the array | 812 | /* |
| 813 | * copy in the pointer into the array starting a the *minor | ||
| 814 | * position minor is the index into the array. | ||
| 815 | */ | ||
| 815 | for (i = *minor + 1; | 816 | for (i = *minor + 1; |
| 816 | (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i) | 817 | (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i) |
| 817 | serial_table[i] = serial; | 818 | serial_table[i] = serial; |
| @@ -828,11 +829,11 @@ static int flip_that(struct tty_struct *tty, __u16 UartNumber, | |||
| 828 | return 0; | 829 | return 0; |
| 829 | } | 830 | } |
| 830 | 831 | ||
| 831 | //Handles processing and moving data to the tty layer | 832 | /* Handles processing and moving data to the tty layer */ |
| 832 | static void port_sofrint(void *private) | 833 | static void port_sofrint(void *private) |
| 833 | { | 834 | { |
| 834 | struct usb_serial_port *port = (struct usb_serial_port *)private; | 835 | struct usb_serial_port *port = (struct usb_serial_port *)private; |
| 835 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 836 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 836 | struct tty_struct *tty = port->tty; | 837 | struct tty_struct *tty = port->tty; |
| 837 | unsigned char *data = port->read_urb->transfer_buffer; | 838 | unsigned char *data = port->read_urb->transfer_buffer; |
| 838 | unsigned int UartNumber; | 839 | unsigned int UartNumber; |
| @@ -841,30 +842,34 @@ static void port_sofrint(void *private) | |||
| 841 | int i, result; | 842 | int i, result; |
| 842 | int flag, flag_data; | 843 | int flag, flag_data; |
| 843 | 844 | ||
| 844 | //UartNumber = MINOR(port->tty->device) - serial->minor; | 845 | /* UartNumber = MINOR(port->tty->device) - serial->minor; */ |
| 845 | UartNumber = tty->index - serial->minor; | 846 | UartNumber = tty->index - serial->minor; |
| 846 | 847 | ||
| 847 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 848 | mydbg("%s - port %d\n", __func__, port->number); |
| 848 | mydbg("%s - port->RxHolding = %d\n", __FUNCTION__, port->RxHolding); | 849 | mydbg("%s - port->RxHolding = %d\n", __func__, port->RxHolding); |
| 849 | 850 | ||
| 850 | if (port_paranoia_check(port, __FUNCTION__) != 0) { | 851 | if (port_paranoia_check(port, __func__) != 0) { |
| 851 | mydbg("%s - port_paranoia_check, exiting\n", __FUNCTION__); | 852 | mydbg("%s - port_paranoia_check, exiting\n", __func__); |
| 852 | port->ReadBulkStopped = 1; | 853 | port->ReadBulkStopped = 1; |
| 853 | return; | 854 | return; |
| 854 | } | 855 | } |
| 855 | 856 | ||
| 856 | if (!serial) { | 857 | if (!serial) { |
| 857 | mydbg("%s - bad serial pointer, exiting\n", __FUNCTION__); | 858 | mydbg("%s - bad serial pointer, exiting\n", __func__); |
| 858 | return; | 859 | return; |
| 859 | } | 860 | } |
| 860 | if (port->closePending == 1) //Were closing , stop reading | 861 | if (port->closePending == 1) { |
| 861 | { | 862 | /* Were closing , stop reading */ |
| 862 | mydbg("%s - (port->closepending == 1\n", __FUNCTION__); | 863 | mydbg("%s - (port->closepending == 1\n", __func__); |
| 863 | port->ReadBulkStopped = 1; | 864 | port->ReadBulkStopped = 1; |
| 864 | return; | 865 | return; |
| 865 | } | 866 | } |
| 866 | //RxHolding is asserted by throttle, if we assert it, we're not receiving any more | 867 | |
| 867 | //characters and let the box handle the flow control | 868 | /* |
| 869 | * RxHolding is asserted by throttle, if we assert it, we're not | ||
| 870 | * receiving any more characters and let the box handle the flow | ||
| 871 | * control | ||
| 872 | */ | ||
| 868 | if (port->RxHolding == 1) { | 873 | if (port->RxHolding == 1) { |
| 869 | port->ReadBulkStopped = 1; | 874 | port->ReadBulkStopped = 1; |
| 870 | return; | 875 | return; |
| @@ -874,27 +879,25 @@ static void port_sofrint(void *private) | |||
| 874 | port->ReadBulkStopped = 1; | 879 | port->ReadBulkStopped = 1; |
| 875 | 880 | ||
| 876 | mydbg("%s - nonzero read bulk status received: %d\n", | 881 | mydbg("%s - nonzero read bulk status received: %d\n", |
| 877 | __FUNCTION__, urb->status); | 882 | __func__, urb->status); |
| 878 | return; | 883 | return; |
| 879 | } | 884 | } |
| 880 | 885 | ||
| 881 | tty = port->tty; | 886 | tty = port->tty; |
| 882 | mydbg("%s - port %d, tty =0x%p\n", __FUNCTION__, port->number, tty); | 887 | mydbg("%s - port %d, tty =0x%p\n", __func__, port->number, tty); |
| 883 | 888 | ||
| 884 | if (tty && RxCount) { | 889 | if (tty && RxCount) { |
| 885 | flag_data = 0; | 890 | flag_data = 0; |
| 886 | for (i = 0; i < RxCount; ++i) { | 891 | for (i = 0; i < RxCount; ++i) { |
| 887 | //Look ahead code here | 892 | /* Look ahead code here */ |
| 888 | |||
| 889 | if ((i <= (RxCount - 3)) && (THISCHAR == 0x1b) | 893 | if ((i <= (RxCount - 3)) && (THISCHAR == 0x1b) |
| 890 | && (NEXTCHAR == 0x1b)) { | 894 | && (NEXTCHAR == 0x1b)) { |
| 891 | flag = 0; | 895 | flag = 0; |
| 892 | switch (THIRDCHAR) { | 896 | switch (THIRDCHAR) { |
| 893 | case 0x00: | 897 | case 0x00: |
| 894 | //Line status change 4th byte must follow | 898 | /* Line status change 4th byte must follow */ |
| 895 | if (i > (RxCount - 4)) { | 899 | if (i > (RxCount - 4)) { |
| 896 | mydbg | 900 | mydbg("Illegal escape sequences in received data\n"); |
| 897 | ("Illegal escape sequences in received data\n"); | ||
| 898 | break; | 901 | break; |
| 899 | } | 902 | } |
| 900 | ProcessLineStatus(port, FOURTHCHAR); | 903 | ProcessLineStatus(port, FOURTHCHAR); |
| @@ -903,9 +906,8 @@ static void port_sofrint(void *private) | |||
| 903 | break; | 906 | break; |
| 904 | 907 | ||
| 905 | case 0x01: | 908 | case 0x01: |
| 906 | //Modem status status change 4th byte must follow | 909 | /* Modem status status change 4th byte must follow */ |
| 907 | mydbg("Modem status status. \n"); | 910 | mydbg("Modem status status. \n"); |
| 908 | |||
| 909 | if (i > (RxCount - 4)) { | 911 | if (i > (RxCount - 4)) { |
| 910 | mydbg | 912 | mydbg |
| 911 | ("Illegal escape sequences in received data\n"); | 913 | ("Illegal escape sequences in received data\n"); |
| @@ -922,22 +924,19 @@ static void port_sofrint(void *private) | |||
| 922 | ProcessRxChar(port, NEXTCHAR); | 924 | ProcessRxChar(port, NEXTCHAR); |
| 923 | i += 2; | 925 | i += 2; |
| 924 | break; | 926 | break; |
| 925 | 927 | } | |
| 926 | } //end switch | ||
| 927 | if (flag == 1) | 928 | if (flag == 1) |
| 928 | continue; | 929 | continue; |
| 929 | } //endif | 930 | } |
| 930 | 931 | ||
| 931 | if (tty && urb->actual_length) { | 932 | if (tty && urb->actual_length) { |
| 932 | tty_buffer_request_room(tty, 1); | 933 | tty_buffer_request_room(tty, 1); |
| 933 | tty_insert_flip_string(tty, (data + i), 1); | 934 | tty_insert_flip_string(tty, (data + i), 1); |
| 934 | } | 935 | } |
| 935 | 936 | ||
| 936 | } //endfor | 937 | } |
| 937 | |||
| 938 | tty_flip_buffer_push(tty); | 938 | tty_flip_buffer_push(tty); |
| 939 | 939 | } | |
| 940 | } //endif | ||
| 941 | 940 | ||
| 942 | /* Continue trying to always read */ | 941 | /* Continue trying to always read */ |
| 943 | usb_fill_bulk_urb(port->read_urb, serial->dev, | 942 | usb_fill_bulk_urb(port->read_urb, serial->dev, |
| @@ -949,7 +948,7 @@ static void port_sofrint(void *private) | |||
| 949 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 948 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
| 950 | if (result) | 949 | if (result) |
| 951 | mydbg("%s - failed resubmitting read urb, error %d", | 950 | mydbg("%s - failed resubmitting read urb, error %d", |
| 952 | __FUNCTION__, result); | 951 | __func__, result); |
| 953 | else { | 952 | else { |
| 954 | if (tty && RxCount) | 953 | if (tty && RxCount) |
| 955 | flip_that(tty, UartNumber, serial); | 954 | flip_that(tty, UartNumber, serial); |
| @@ -965,10 +964,9 @@ static void qt_read_bulk_callback(struct urb *urb) | |||
| 965 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | 964 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; |
| 966 | 965 | ||
| 967 | if (urb->status) { | 966 | if (urb->status) { |
| 968 | |||
| 969 | port->ReadBulkStopped = 1; | 967 | port->ReadBulkStopped = 1; |
| 970 | mydbg("%s - nonzero write bulk status received: %d\n", | 968 | mydbg("%s - nonzero write bulk status received: %d\n", |
| 971 | __FUNCTION__, urb->status); | 969 | __func__, urb->status); |
| 972 | return; | 970 | return; |
| 973 | } | 971 | } |
| 974 | 972 | ||
| @@ -986,8 +984,7 @@ static void ProcessRxChar(struct usb_serial_port *port, unsigned char Data) | |||
| 986 | if (tty && urb->actual_length) { | 984 | if (tty && urb->actual_length) { |
| 987 | tty_buffer_request_room(tty, 1); | 985 | tty_buffer_request_room(tty, 1); |
| 988 | tty_insert_flip_string(tty, &Data, 1); | 986 | tty_insert_flip_string(tty, &Data, 1); |
| 989 | //tty_flip_buffer_push(tty); | 987 | /* tty_flip_buffer_push(tty); */ |
| 990 | |||
| 991 | } | 988 | } |
| 992 | 989 | ||
| 993 | return; | 990 | return; |
| @@ -1015,11 +1012,11 @@ static void ProcessModemStatus(struct usb_serial_port *port, | |||
| 1015 | static void serqt_usb_disconnect(struct usb_interface *interface) | 1012 | static void serqt_usb_disconnect(struct usb_interface *interface) |
| 1016 | { | 1013 | { |
| 1017 | struct usb_serial *serial = usb_get_intfdata(interface); | 1014 | struct usb_serial *serial = usb_get_intfdata(interface); |
| 1018 | //struct device *dev = &interface->dev; | 1015 | /* struct device *dev = &interface->dev; */ |
| 1019 | struct usb_serial_port *port; | 1016 | struct usb_serial_port *port; |
| 1020 | int i; | 1017 | int i; |
| 1021 | 1018 | ||
| 1022 | mydbg("%s\n", __FUNCTION__); | 1019 | mydbg("%s\n", __func__); |
| 1023 | if (serial) { | 1020 | if (serial) { |
| 1024 | 1021 | ||
| 1025 | serial->dev = NULL; | 1022 | serial->dev = NULL; |
| @@ -1029,31 +1026,22 @@ static void serqt_usb_disconnect(struct usb_interface *interface) | |||
| 1029 | 1026 | ||
| 1030 | for (i = 0; i < serial->num_bulk_in; ++i) { | 1027 | for (i = 0; i < serial->num_bulk_in; ++i) { |
| 1031 | port = &serial->port[i]; | 1028 | port = &serial->port[i]; |
| 1032 | if (port->read_urb) { | 1029 | usb_unlink_urb(port->read_urb); |
| 1033 | usb_unlink_urb(port->read_urb); | 1030 | usb_free_urb(port->read_urb); |
| 1034 | usb_free_urb(port->read_urb); | 1031 | kfree(port->bulk_in_buffer); |
| 1035 | } | ||
| 1036 | if (port->bulk_in_buffer) | ||
| 1037 | kfree(port->bulk_in_buffer); | ||
| 1038 | } | 1032 | } |
| 1039 | for (i = 0; i < serial->num_bulk_out; ++i) { | 1033 | for (i = 0; i < serial->num_bulk_out; ++i) { |
| 1040 | port = &serial->port[i]; | 1034 | port = &serial->port[i]; |
| 1041 | if (port->write_urb) { | 1035 | usb_unlink_urb(port->write_urb); |
| 1042 | usb_unlink_urb(port->write_urb); | 1036 | usb_free_urb(port->write_urb); |
| 1043 | usb_free_urb(port->write_urb); | 1037 | kfree(port->bulk_out_buffer); |
| 1044 | } | ||
| 1045 | if (port->bulk_out_buffer) | ||
| 1046 | kfree(port->bulk_out_buffer); | ||
| 1047 | } | 1038 | } |
| 1048 | for (i = 0; i < serial->num_interrupt_in; ++i) { | 1039 | for (i = 0; i < serial->num_interrupt_in; ++i) { |
| 1049 | port = &serial->port[i]; | 1040 | port = &serial->port[i]; |
| 1050 | if (port->interrupt_in_urb) { | 1041 | usb_unlink_urb(port->interrupt_in_urb); |
| 1051 | usb_unlink_urb(port->interrupt_in_urb); | 1042 | usb_free_urb(port->interrupt_in_urb); |
| 1052 | usb_free_urb(port->interrupt_in_urb); | 1043 | kfree(port->interrupt_in_buffer); |
| 1053 | } | 1044 | } |
| 1054 | if (port->interrupt_in_buffer) | ||
| 1055 | kfree(port->interrupt_in_buffer); | ||
| 1056 | } | ||
| 1057 | 1045 | ||
| 1058 | /* return the minor range that this device had */ | 1046 | /* return the minor range that this device had */ |
| 1059 | return_serial(serial); | 1047 | return_serial(serial); |
| @@ -1082,18 +1070,18 @@ static int serial_open(struct tty_struct *tty, struct file *filp) | |||
| 1082 | unsigned int portNumber; | 1070 | unsigned int portNumber; |
| 1083 | int retval = 0; | 1071 | int retval = 0; |
| 1084 | 1072 | ||
| 1085 | mydbg("%s\n", __FUNCTION__); | 1073 | mydbg("%s\n", __func__); |
| 1086 | 1074 | ||
| 1087 | /* initialize the pointer incase something fails */ | 1075 | /* initialize the pointer incase something fails */ |
| 1088 | tty->driver_data = NULL; | 1076 | tty->driver_data = NULL; |
| 1089 | 1077 | ||
| 1090 | /* get the serial object associated with this tty pointer */ | 1078 | /* get the serial object associated with this tty pointer */ |
| 1091 | //serial = get_serial_by_minor (MINOR(tty->device)); | 1079 | /* serial = get_serial_by_minor (MINOR(tty->device)); */ |
| 1092 | 1080 | ||
| 1093 | /* get the serial object associated with this tty pointer */ | 1081 | /* get the serial object associated with this tty pointer */ |
| 1094 | serial = get_serial_by_minor(tty->index); | 1082 | serial = get_serial_by_minor(tty->index); |
| 1095 | 1083 | ||
| 1096 | if (serial_paranoia_check(serial, __FUNCTION__)) | 1084 | if (serial_paranoia_check(serial, __func__)) |
| 1097 | return -ENODEV; | 1085 | return -ENODEV; |
| 1098 | 1086 | ||
| 1099 | /* set up our port structure making the tty driver remember our port object, and us it */ | 1087 | /* set up our port structure making the tty driver remember our port object, and us it */ |
| @@ -1107,18 +1095,17 @@ static int serial_open(struct tty_struct *tty, struct file *filp) | |||
| 1107 | ++port->open_count; | 1095 | ++port->open_count; |
| 1108 | if (port->open_count == 1) { | 1096 | if (port->open_count == 1) { |
| 1109 | port->closePending = 0; | 1097 | port->closePending = 0; |
| 1110 | mydbg("%s port->closepending = 0\n", __FUNCTION__); | 1098 | mydbg("%s port->closepending = 0\n", __func__); |
| 1111 | 1099 | ||
| 1112 | port->RxHolding = 0; | 1100 | port->RxHolding = 0; |
| 1113 | mydbg("%s port->RxHolding = 0\n", __FUNCTION__); | 1101 | mydbg("%s port->RxHolding = 0\n", __func__); |
| 1114 | 1102 | ||
| 1115 | retval = qt_open(port, filp); | 1103 | retval = qt_open(port, filp); |
| 1116 | } | 1104 | } |
| 1117 | 1105 | ||
| 1118 | if (retval) { | 1106 | if (retval) |
| 1119 | port->open_count = 0; | 1107 | port->open_count = 0; |
| 1120 | } | 1108 | mydbg("%s returning port->closePending = %d\n", __func__, |
| 1121 | mydbg("%s returning port->closePending = %d\n", __FUNCTION__, | ||
| 1122 | port->closePending); | 1109 | port->closePending); |
| 1123 | 1110 | ||
| 1124 | up(&port->sem); | 1111 | up(&port->sem); |
| @@ -1135,14 +1122,14 @@ static int qt_open(struct usb_serial_port *port, struct file *filp) | |||
| 1135 | unsigned int UartNumber; | 1122 | unsigned int UartNumber; |
| 1136 | struct qt_get_device_data DeviceData; | 1123 | struct qt_get_device_data DeviceData; |
| 1137 | struct qt_open_channel_data ChannelData; | 1124 | struct qt_open_channel_data ChannelData; |
| 1138 | unsigned short default_divisor = 0x30; //gives 9600 baud rate | 1125 | unsigned short default_divisor = 0x30; /* gives 9600 baud rate */ |
| 1139 | unsigned char default_LCR = SERIAL_8_DATA; // 8, none , 1 | 1126 | unsigned char default_LCR = SERIAL_8_DATA; /* 8, none , 1 */ |
| 1140 | int status = 0; | 1127 | int status = 0; |
| 1141 | 1128 | ||
| 1142 | if (port_paranoia_check(port, __FUNCTION__)) | 1129 | if (port_paranoia_check(port, __func__)) |
| 1143 | return -ENODEV; | 1130 | return -ENODEV; |
| 1144 | 1131 | ||
| 1145 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1132 | mydbg("%s - port %d\n", __func__, port->number); |
| 1146 | 1133 | ||
| 1147 | /* force low_latency on so that our tty_push actually forces the data through, | 1134 | /* force low_latency on so that our tty_push actually forces the data through, |
| 1148 | otherwise it is scheduled, and with high data rates (like with OHCI) data | 1135 | otherwise it is scheduled, and with high data rates (like with OHCI) data |
| @@ -1158,11 +1145,11 @@ static int qt_open(struct usb_serial_port *port, struct file *filp) | |||
| 1158 | return status; | 1145 | return status; |
| 1159 | } | 1146 | } |
| 1160 | serial->num_OpenCount++; | 1147 | serial->num_OpenCount++; |
| 1161 | mydbg("%s serial->num_OpenCount = %d\n", __FUNCTION__, | 1148 | mydbg("%s serial->num_OpenCount = %d\n", __func__, |
| 1162 | serial->num_OpenCount); | 1149 | serial->num_OpenCount); |
| 1163 | //Open uart channel | 1150 | /* Open uart channel */ |
| 1164 | 1151 | ||
| 1165 | //Port specific setups | 1152 | /* Port specific setups */ |
| 1166 | status = BoxOPenCloseChannel(serial, UartNumber, 1, &ChannelData); | 1153 | status = BoxOPenCloseChannel(serial, UartNumber, 1, &ChannelData); |
| 1167 | if (status < 0) { | 1154 | if (status < 0) { |
| 1168 | mydbg(__FILE__ "BoxOPenCloseChannel failed\n"); | 1155 | mydbg(__FILE__ "BoxOPenCloseChannel failed\n"); |
| @@ -1176,7 +1163,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp) | |||
| 1176 | port->shadowMSR = ChannelData.modem_status & | 1163 | port->shadowMSR = ChannelData.modem_status & |
| 1177 | (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_CD); | 1164 | (SERIAL_MSR_CTS | SERIAL_MSR_DSR | SERIAL_MSR_RI | SERIAL_MSR_CD); |
| 1178 | 1165 | ||
| 1179 | //Set Baud rate to default and turn off (default)flow control here | 1166 | /* Set Baud rate to default and turn off (default)flow control here */ |
| 1180 | status = BoxSetUart(serial, UartNumber, default_divisor, default_LCR); | 1167 | status = BoxSetUart(serial, UartNumber, default_divisor, default_LCR); |
| 1181 | if (status < 0) { | 1168 | if (status < 0) { |
| 1182 | mydbg(__FILE__ "BoxSetUart failed\n"); | 1169 | mydbg(__FILE__ "BoxSetUart failed\n"); |
| @@ -1184,10 +1171,10 @@ static int qt_open(struct usb_serial_port *port, struct file *filp) | |||
| 1184 | } | 1171 | } |
| 1185 | mydbg(__FILE__ "BoxSetUart completed.\n"); | 1172 | mydbg(__FILE__ "BoxSetUart completed.\n"); |
| 1186 | 1173 | ||
| 1187 | //Put this here to make it responsive to stty and defauls set by the tty layer | 1174 | /* Put this here to make it responsive to stty and defauls set by the tty layer */ |
| 1188 | qt_set_termios(port, NULL); | 1175 | qt_set_termios(port, NULL); |
| 1189 | 1176 | ||
| 1190 | //Initialize the wait que head | 1177 | /* Initialize the wait que head */ |
| 1191 | init_waitqueue_head(&(port->wait)); | 1178 | init_waitqueue_head(&(port->wait)); |
| 1192 | 1179 | ||
| 1193 | /* if we have a bulk endpoint, start reading from it */ | 1180 | /* if we have a bulk endpoint, start reading from it */ |
| @@ -1207,7 +1194,7 @@ static int qt_open(struct usb_serial_port *port, struct file *filp) | |||
| 1207 | 1194 | ||
| 1208 | if (result) { | 1195 | if (result) { |
| 1209 | err("%s - failed resubmitting read urb, error %d\n", | 1196 | err("%s - failed resubmitting read urb, error %d\n", |
| 1210 | __FUNCTION__, result); | 1197 | __func__, result); |
| 1211 | port->ReadBulkStopped = 1; | 1198 | port->ReadBulkStopped = 1; |
| 1212 | } | 1199 | } |
| 1213 | 1200 | ||
| @@ -1220,26 +1207,26 @@ static void serial_close(struct tty_struct *tty, struct file *filp) | |||
| 1220 | { | 1207 | { |
| 1221 | struct usb_serial_port *port = | 1208 | struct usb_serial_port *port = |
| 1222 | (struct usb_serial_port *)tty->driver_data; | 1209 | (struct usb_serial_port *)tty->driver_data; |
| 1223 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1210 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1224 | 1211 | ||
| 1225 | if (!serial) | 1212 | if (!serial) |
| 1226 | return; | 1213 | return; |
| 1227 | 1214 | ||
| 1228 | down(&port->sem); | 1215 | down(&port->sem); |
| 1229 | 1216 | ||
| 1230 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1217 | mydbg("%s - port %d\n", __func__, port->number); |
| 1231 | 1218 | ||
| 1232 | /* if disconnect beat us to the punch here, there's nothing to do */ | 1219 | /* if disconnect beat us to the punch here, there's nothing to do */ |
| 1233 | if (tty->driver_data) { | 1220 | if (tty->driver_data) { |
| 1234 | if (!port->open_count) { | 1221 | if (!port->open_count) { |
| 1235 | mydbg("%s - port not opened\n", __FUNCTION__); | 1222 | mydbg("%s - port not opened\n", __func__); |
| 1236 | goto exit; | 1223 | goto exit; |
| 1237 | } | 1224 | } |
| 1238 | 1225 | ||
| 1239 | --port->open_count; | 1226 | --port->open_count; |
| 1240 | if (port->open_count <= 0) { | 1227 | if (port->open_count <= 0) { |
| 1241 | port->closePending = 1; | 1228 | port->closePending = 1; |
| 1242 | mydbg("%s - port->closePending = 1\n", __FUNCTION__); | 1229 | mydbg("%s - port->closePending = 1\n", __func__); |
| 1243 | 1230 | ||
| 1244 | if (serial->dev) { | 1231 | if (serial->dev) { |
| 1245 | qt_close(port, filp); | 1232 | qt_close(port, filp); |
| @@ -1252,7 +1239,7 @@ static void serial_close(struct tty_struct *tty, struct file *filp) | |||
| 1252 | exit: | 1239 | exit: |
| 1253 | up(&port->sem); | 1240 | up(&port->sem); |
| 1254 | 1241 | ||
| 1255 | mydbg("%s - %d return\n", __FUNCTION__, port->number); | 1242 | mydbg("%s - %d return\n", __func__, port->number); |
| 1256 | 1243 | ||
| 1257 | } | 1244 | } |
| 1258 | 1245 | ||
| @@ -1268,7 +1255,7 @@ static void qt_close(struct usb_serial_port *port, struct file *filp) | |||
| 1268 | status = 0; | 1255 | status = 0; |
| 1269 | LSR_Value = 0; | 1256 | LSR_Value = 0; |
| 1270 | 1257 | ||
| 1271 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1258 | mydbg("%s - port %d\n", __func__, port->number); |
| 1272 | UartNumber = port->tty->index - serial->minor; | 1259 | UartNumber = port->tty->index - serial->minor; |
| 1273 | 1260 | ||
| 1274 | /* shutdown any bulk reads that might be going on */ | 1261 | /* shutdown any bulk reads that might be going on */ |
| @@ -1277,11 +1264,9 @@ static void qt_close(struct usb_serial_port *port, struct file *filp) | |||
| 1277 | if (serial->num_bulk_in) | 1264 | if (serial->num_bulk_in) |
| 1278 | usb_unlink_urb(port->read_urb); | 1265 | usb_unlink_urb(port->read_urb); |
| 1279 | 1266 | ||
| 1280 | //wait up to 30 seconds for transmitter to empty | 1267 | /* wait up to 30 seconds for transmitter to empty */ |
| 1281 | do { | 1268 | do { |
| 1282 | status = | 1269 | status = BoxGetRegister(serial, UartNumber, LINE_STATUS_REGISTER, &LSR_Value); |
| 1283 | BoxGetRegister(serial, UartNumber, LINE_STATUS_REGISTER, | ||
| 1284 | &LSR_Value); | ||
| 1285 | if (status < 0) { | 1270 | if (status < 0) { |
| 1286 | mydbg(__FILE__ "box_get_device failed\n"); | 1271 | mydbg(__FILE__ "box_get_device failed\n"); |
| 1287 | break; | 1272 | break; |
| @@ -1293,14 +1278,15 @@ static void qt_close(struct usb_serial_port *port, struct file *filp) | |||
| 1293 | schedule(); | 1278 | schedule(); |
| 1294 | 1279 | ||
| 1295 | } | 1280 | } |
| 1296 | while (jiffies <= jift); | 1281 | while (jiffies <= jift) |
| 1282 | ; | ||
| 1297 | 1283 | ||
| 1298 | if (jiffies > jift) | 1284 | if (jiffies > jift) |
| 1299 | mydbg("%s - port %d timout of checking transmitter empty\n", | 1285 | mydbg("%s - port %d timout of checking transmitter empty\n", |
| 1300 | __FUNCTION__, port->number); | 1286 | __func__, port->number); |
| 1301 | else | 1287 | else |
| 1302 | mydbg("%s - port %d checking transmitter empty succeded\n", | 1288 | mydbg("%s - port %d checking transmitter empty succeded\n", |
| 1303 | __FUNCTION__, port->number); | 1289 | __func__, port->number); |
| 1304 | 1290 | ||
| 1305 | status = | 1291 | status = |
| 1306 | BoxGetRegister(serial, UartNumber, MODEM_CONTROL_REGISTER, | 1292 | BoxGetRegister(serial, UartNumber, MODEM_CONTROL_REGISTER, |
| @@ -1309,14 +1295,14 @@ static void qt_close(struct usb_serial_port *port, struct file *filp) | |||
| 1309 | 1295 | ||
| 1310 | if (status >= 0) { | 1296 | if (status >= 0) { |
| 1311 | MCR_Value &= ~(SERIAL_MCR_DTR | SERIAL_MCR_RTS); | 1297 | MCR_Value &= ~(SERIAL_MCR_DTR | SERIAL_MCR_RTS); |
| 1312 | // status = BoxSetRegister(serial, UartNumber, MODEM_CONTROL_REGISTER, MCR_Value); | 1298 | /* status = BoxSetRegister(serial, UartNumber, MODEM_CONTROL_REGISTER, MCR_Value); */ |
| 1313 | } | 1299 | } |
| 1314 | 1300 | ||
| 1315 | //Close uart channel | 1301 | /* Close uart channel */ |
| 1316 | status = BoxOPenCloseChannel(serial, UartNumber, 0, &ChannelData); | 1302 | status = BoxOPenCloseChannel(serial, UartNumber, 0, &ChannelData); |
| 1317 | if (status < 0) | 1303 | if (status < 0) |
| 1318 | mydbg("%s - port %d BoxOPenCloseChannel failed.\n", | 1304 | mydbg("%s - port %d BoxOPenCloseChannel failed.\n", |
| 1319 | __FUNCTION__, port->number); | 1305 | __func__, port->number); |
| 1320 | 1306 | ||
| 1321 | serial->num_OpenCount--; | 1307 | serial->num_OpenCount--; |
| 1322 | 1308 | ||
| @@ -1332,20 +1318,19 @@ static int serial_write(struct tty_struct *tty, const unsigned char *buf, | |||
| 1332 | unsigned int UartNumber; | 1318 | unsigned int UartNumber; |
| 1333 | int from_user = 0; | 1319 | int from_user = 0; |
| 1334 | 1320 | ||
| 1335 | serial = get_usb_serial(port, __FUNCTION__); | 1321 | serial = get_usb_serial(port, __func__); |
| 1336 | if (serial == NULL) | 1322 | if (serial == NULL) |
| 1337 | return -ENODEV; | 1323 | return -ENODEV; |
| 1338 | //This can happen if we get disconnected a | 1324 | /* This can happen if we get disconnected a */ |
| 1339 | if (port->open_count == 0) { | 1325 | if (port->open_count == 0) |
| 1340 | return -ENODEV; | 1326 | return -ENODEV; |
| 1341 | } | ||
| 1342 | UartNumber = port->tty->index - serial->minor; | 1327 | UartNumber = port->tty->index - serial->minor; |
| 1343 | 1328 | ||
| 1344 | mydbg("%s - port %d, %d byte(s)\n", __FUNCTION__, port->number, count); | 1329 | mydbg("%s - port %d, %d byte(s)\n", __func__, port->number, count); |
| 1345 | mydbg("%s - port->RxHolding = %d\n", __FUNCTION__, port->RxHolding); | 1330 | mydbg("%s - port->RxHolding = %d\n", __func__, port->RxHolding); |
| 1346 | 1331 | ||
| 1347 | if (!port->open_count) { | 1332 | if (!port->open_count) { |
| 1348 | mydbg("%s - port not opened\n", __FUNCTION__); | 1333 | mydbg("%s - port not opened\n", __func__); |
| 1349 | goto exit; | 1334 | goto exit; |
| 1350 | } | 1335 | } |
| 1351 | 1336 | ||
| @@ -1361,23 +1346,23 @@ static int qt_write(struct usb_serial_port *port, int from_user, | |||
| 1361 | int result; | 1346 | int result; |
| 1362 | unsigned int UartNumber; | 1347 | unsigned int UartNumber; |
| 1363 | 1348 | ||
| 1364 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1349 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1365 | if (serial == NULL) | 1350 | if (serial == NULL) |
| 1366 | return -ENODEV; | 1351 | return -ENODEV; |
| 1367 | 1352 | ||
| 1368 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1353 | mydbg("%s - port %d\n", __func__, port->number); |
| 1369 | 1354 | ||
| 1370 | if (count == 0) { | 1355 | if (count == 0) { |
| 1371 | mydbg("%s - write request of 0 bytes\n", __FUNCTION__); | 1356 | mydbg("%s - write request of 0 bytes\n", __func__); |
| 1372 | return (0); | 1357 | return 0; |
| 1373 | } | 1358 | } |
| 1374 | 1359 | ||
| 1375 | UartNumber = port->tty->index - serial->minor; | 1360 | UartNumber = port->tty->index - serial->minor; |
| 1376 | /* only do something if we have a bulk out endpoint */ | 1361 | /* only do something if we have a bulk out endpoint */ |
| 1377 | if (serial->num_bulk_out) { | 1362 | if (serial->num_bulk_out) { |
| 1378 | if (port->write_urb->status == -EINPROGRESS) { | 1363 | if (port->write_urb->status == -EINPROGRESS) { |
| 1379 | mydbg("%s - already writing\n", __FUNCTION__); | 1364 | mydbg("%s - already writing\n", __func__); |
| 1380 | return (0); | 1365 | return 0; |
| 1381 | } | 1366 | } |
| 1382 | 1367 | ||
| 1383 | count = | 1368 | count = |
| @@ -1391,7 +1376,7 @@ static int qt_write(struct usb_serial_port *port, int from_user, | |||
| 1391 | memcpy(port->write_urb->transfer_buffer, buf, count); | 1376 | memcpy(port->write_urb->transfer_buffer, buf, count); |
| 1392 | } | 1377 | } |
| 1393 | 1378 | ||
| 1394 | //usb_serial_debug_data(__FILE__, __FUNCTION__, count, port->write_urb->transfer_buffer); | 1379 | /* usb_serial_debug_data(__FILE__, __func__, count, port->write_urb->transfer_buffer); */ |
| 1395 | 1380 | ||
| 1396 | /* set up our urb */ | 1381 | /* set up our urb */ |
| 1397 | 1382 | ||
| @@ -1406,7 +1391,7 @@ static int qt_write(struct usb_serial_port *port, int from_user, | |||
| 1406 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 1391 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
| 1407 | if (result) | 1392 | if (result) |
| 1408 | mydbg("%s - failed submitting write urb, error %d\n", | 1393 | mydbg("%s - failed submitting write urb, error %d\n", |
| 1409 | __FUNCTION__, result); | 1394 | __func__, result); |
| 1410 | else | 1395 | else |
| 1411 | result = count; | 1396 | result = count; |
| 1412 | 1397 | ||
| @@ -1414,27 +1399,26 @@ static int qt_write(struct usb_serial_port *port, int from_user, | |||
| 1414 | } | 1399 | } |
| 1415 | 1400 | ||
| 1416 | /* no bulk out, so return 0 bytes written */ | 1401 | /* no bulk out, so return 0 bytes written */ |
| 1417 | return (0); | 1402 | return 0; |
| 1418 | } | 1403 | } |
| 1419 | 1404 | ||
| 1420 | static void qt_write_bulk_callback(struct urb *urb) | 1405 | static void qt_write_bulk_callback(struct urb *urb) |
| 1421 | { | 1406 | { |
| 1422 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; | 1407 | struct usb_serial_port *port = (struct usb_serial_port *)urb->context; |
| 1423 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1408 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1424 | 1409 | ||
| 1425 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1410 | mydbg("%s - port %d\n", __func__, port->number); |
| 1426 | 1411 | ||
| 1427 | if (!serial) { | 1412 | if (!serial) { |
| 1428 | mydbg("%s - bad serial pointer, exiting\n", __FUNCTION__); | 1413 | mydbg("%s - bad serial pointer, exiting\n", __func__); |
| 1429 | return; | 1414 | return; |
| 1430 | } | 1415 | } |
| 1431 | 1416 | ||
| 1432 | if (urb->status) { | 1417 | if (urb->status) { |
| 1433 | mydbg("%s - nonzero write bulk status received: %d\n", | 1418 | mydbg("%s - nonzero write bulk status received: %d\n", |
| 1434 | __FUNCTION__, urb->status); | 1419 | __func__, urb->status); |
| 1435 | return; | 1420 | return; |
| 1436 | } | 1421 | } |
| 1437 | // | ||
| 1438 | port_softint(&port->work); | 1422 | port_softint(&port->work); |
| 1439 | schedule_work(&port->work); | 1423 | schedule_work(&port->work); |
| 1440 | 1424 | ||
| @@ -1445,10 +1429,10 @@ static void port_softint(struct work_struct *work) | |||
| 1445 | { | 1429 | { |
| 1446 | struct usb_serial_port *port = | 1430 | struct usb_serial_port *port = |
| 1447 | container_of(work, struct usb_serial_port, work); | 1431 | container_of(work, struct usb_serial_port, work); |
| 1448 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1432 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1449 | struct tty_struct *tty; | 1433 | struct tty_struct *tty; |
| 1450 | 1434 | ||
| 1451 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1435 | mydbg("%s - port %d\n", __func__, port->number); |
| 1452 | 1436 | ||
| 1453 | if (!serial) | 1437 | if (!serial) |
| 1454 | return; | 1438 | return; |
| @@ -1459,7 +1443,7 @@ static void port_softint(struct work_struct *work) | |||
| 1459 | #if 0 | 1443 | #if 0 |
| 1460 | if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) | 1444 | if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) |
| 1461 | && tty->ldisc.write_wakeup) { | 1445 | && tty->ldisc.write_wakeup) { |
| 1462 | mydbg("%s - write wakeup call.\n", __FUNCTION__); | 1446 | mydbg("%s - write wakeup call.\n", __func__); |
| 1463 | (tty->ldisc.write_wakeup) (tty); | 1447 | (tty->ldisc.write_wakeup) (tty); |
| 1464 | } | 1448 | } |
| 1465 | #endif | 1449 | #endif |
| @@ -1470,7 +1454,7 @@ static int serial_write_room(struct tty_struct *tty) | |||
| 1470 | { | 1454 | { |
| 1471 | struct usb_serial_port *port = | 1455 | struct usb_serial_port *port = |
| 1472 | (struct usb_serial_port *)tty->driver_data; | 1456 | (struct usb_serial_port *)tty->driver_data; |
| 1473 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1457 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1474 | int retval = -EINVAL; | 1458 | int retval = -EINVAL; |
| 1475 | 1459 | ||
| 1476 | if (!serial) | 1460 | if (!serial) |
| @@ -1478,10 +1462,10 @@ static int serial_write_room(struct tty_struct *tty) | |||
| 1478 | 1462 | ||
| 1479 | down(&port->sem); | 1463 | down(&port->sem); |
| 1480 | 1464 | ||
| 1481 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1465 | mydbg("%s - port %d\n", __func__, port->number); |
| 1482 | 1466 | ||
| 1483 | if (!port->open_count) { | 1467 | if (!port->open_count) { |
| 1484 | mydbg("%s - port not open\n", __FUNCTION__); | 1468 | mydbg("%s - port not open\n", __func__); |
| 1485 | goto exit; | 1469 | goto exit; |
| 1486 | } | 1470 | } |
| 1487 | 1471 | ||
| @@ -1496,25 +1480,25 @@ static int qt_write_room(struct usb_serial_port *port) | |||
| 1496 | struct usb_serial *serial = port->serial; | 1480 | struct usb_serial *serial = port->serial; |
| 1497 | int room = 0; | 1481 | int room = 0; |
| 1498 | if (port->closePending == 1) { | 1482 | if (port->closePending == 1) { |
| 1499 | mydbg("%s - port->closePending == 1\n", __FUNCTION__); | 1483 | mydbg("%s - port->closePending == 1\n", __func__); |
| 1500 | return -ENODEV; | 1484 | return -ENODEV; |
| 1501 | } | 1485 | } |
| 1502 | 1486 | ||
| 1503 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1487 | mydbg("%s - port %d\n", __func__, port->number); |
| 1504 | 1488 | ||
| 1505 | if (serial->num_bulk_out) { | 1489 | if (serial->num_bulk_out) { |
| 1506 | if (port->write_urb->status != -EINPROGRESS) | 1490 | if (port->write_urb->status != -EINPROGRESS) |
| 1507 | room = port->bulk_out_size; | 1491 | room = port->bulk_out_size; |
| 1508 | } | 1492 | } |
| 1509 | 1493 | ||
| 1510 | mydbg("%s - returns %d\n", __FUNCTION__, room); | 1494 | mydbg("%s - returns %d\n", __func__, room); |
| 1511 | return (room); | 1495 | return room; |
| 1512 | } | 1496 | } |
| 1513 | static int serial_chars_in_buffer(struct tty_struct *tty) | 1497 | static int serial_chars_in_buffer(struct tty_struct *tty) |
| 1514 | { | 1498 | { |
| 1515 | struct usb_serial_port *port = | 1499 | struct usb_serial_port *port = |
| 1516 | (struct usb_serial_port *)tty->driver_data; | 1500 | (struct usb_serial_port *)tty->driver_data; |
| 1517 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1501 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1518 | int retval = -EINVAL; | 1502 | int retval = -EINVAL; |
| 1519 | 1503 | ||
| 1520 | if (!serial) | 1504 | if (!serial) |
| @@ -1522,10 +1506,10 @@ static int serial_chars_in_buffer(struct tty_struct *tty) | |||
| 1522 | 1506 | ||
| 1523 | down(&port->sem); | 1507 | down(&port->sem); |
| 1524 | 1508 | ||
| 1525 | mydbg("%s = port %d\n", __FUNCTION__, port->number); | 1509 | mydbg("%s = port %d\n", __func__, port->number); |
| 1526 | 1510 | ||
| 1527 | if (!port->open_count) { | 1511 | if (!port->open_count) { |
| 1528 | mydbg("%s - port not open\n", __FUNCTION__); | 1512 | mydbg("%s - port not open\n", __func__); |
| 1529 | goto exit; | 1513 | goto exit; |
| 1530 | } | 1514 | } |
| 1531 | 1515 | ||
| @@ -1541,15 +1525,15 @@ static int qt_chars_in_buffer(struct usb_serial_port *port) | |||
| 1541 | struct usb_serial *serial = port->serial; | 1525 | struct usb_serial *serial = port->serial; |
| 1542 | int chars = 0; | 1526 | int chars = 0; |
| 1543 | 1527 | ||
| 1544 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1528 | mydbg("%s - port %d\n", __func__, port->number); |
| 1545 | 1529 | ||
| 1546 | if (serial->num_bulk_out) { | 1530 | if (serial->num_bulk_out) { |
| 1547 | if (port->write_urb->status == -EINPROGRESS) | 1531 | if (port->write_urb->status == -EINPROGRESS) |
| 1548 | chars = port->write_urb->transfer_buffer_length; | 1532 | chars = port->write_urb->transfer_buffer_length; |
| 1549 | } | 1533 | } |
| 1550 | 1534 | ||
| 1551 | mydbg("%s - returns %d\n", __FUNCTION__, chars); | 1535 | mydbg("%s - returns %d\n", __func__, chars); |
| 1552 | return (chars); | 1536 | return chars; |
| 1553 | } | 1537 | } |
| 1554 | 1538 | ||
| 1555 | static int serial_tiocmset(struct tty_struct *tty, struct file *file, | 1539 | static int serial_tiocmset(struct tty_struct *tty, struct file *file, |
| @@ -1558,10 +1542,10 @@ static int serial_tiocmset(struct tty_struct *tty, struct file *file, | |||
| 1558 | 1542 | ||
| 1559 | struct usb_serial_port *port = | 1543 | struct usb_serial_port *port = |
| 1560 | (struct usb_serial_port *)tty->driver_data; | 1544 | (struct usb_serial_port *)tty->driver_data; |
| 1561 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1545 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1562 | int retval = -ENODEV; | 1546 | int retval = -ENODEV; |
| 1563 | unsigned int UartNumber; | 1547 | unsigned int UartNumber; |
| 1564 | mydbg("In %s \n", __FUNCTION__); | 1548 | mydbg("In %s \n", __func__); |
| 1565 | 1549 | ||
| 1566 | if (!serial) | 1550 | if (!serial) |
| 1567 | return -ENODEV; | 1551 | return -ENODEV; |
| @@ -1570,11 +1554,11 @@ static int serial_tiocmset(struct tty_struct *tty, struct file *file, | |||
| 1570 | 1554 | ||
| 1571 | down(&port->sem); | 1555 | down(&port->sem); |
| 1572 | 1556 | ||
| 1573 | mydbg("%s - port %d \n", __FUNCTION__, port->number); | 1557 | mydbg("%s - port %d \n", __func__, port->number); |
| 1574 | mydbg("%s - port->RxHolding = %d\n", __FUNCTION__, port->RxHolding); | 1558 | mydbg("%s - port->RxHolding = %d\n", __func__, port->RxHolding); |
| 1575 | 1559 | ||
| 1576 | if (!port->open_count) { | 1560 | if (!port->open_count) { |
| 1577 | mydbg("%s - port not open\n", __FUNCTION__); | 1561 | mydbg("%s - port not open\n", __func__); |
| 1578 | goto exit; | 1562 | goto exit; |
| 1579 | } | 1563 | } |
| 1580 | 1564 | ||
| @@ -1593,11 +1577,11 @@ static int qt_tiocmset(struct usb_serial_port *port, struct file *file, | |||
| 1593 | int status; | 1577 | int status; |
| 1594 | unsigned int UartNumber; | 1578 | unsigned int UartNumber; |
| 1595 | 1579 | ||
| 1596 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1580 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1597 | if (serial == NULL) | 1581 | if (serial == NULL) |
| 1598 | return -ENODEV; | 1582 | return -ENODEV; |
| 1599 | 1583 | ||
| 1600 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1584 | mydbg("%s - port %d\n", __func__, port->number); |
| 1601 | 1585 | ||
| 1602 | /**************************************************************************************/ | 1586 | /**************************************************************************************/ |
| 1603 | /** TIOCMGET | 1587 | /** TIOCMGET |
| @@ -1609,8 +1593,10 @@ static int qt_tiocmset(struct usb_serial_port *port, struct file *file, | |||
| 1609 | if (status < 0) | 1593 | if (status < 0) |
| 1610 | return -ESPIPE; | 1594 | return -ESPIPE; |
| 1611 | 1595 | ||
| 1612 | //Turn off the RTS and DTR and loopbcck and then only | 1596 | /* |
| 1613 | //trun on what was asked for | 1597 | * Turn off the RTS and DTR and loopbcck and then only turn on what was |
| 1598 | * asked for | ||
| 1599 | */ | ||
| 1614 | MCR_Value &= ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR | SERIAL_MCR_LOOP); | 1600 | MCR_Value &= ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR | SERIAL_MCR_LOOP); |
| 1615 | if (value & TIOCM_RTS) | 1601 | if (value & TIOCM_RTS) |
| 1616 | MCR_Value |= SERIAL_MCR_RTS; | 1602 | MCR_Value |= SERIAL_MCR_RTS; |
| @@ -1634,10 +1620,10 @@ static int serial_tiocmget(struct tty_struct *tty, struct file *file) | |||
| 1634 | struct usb_serial_port *port = | 1620 | struct usb_serial_port *port = |
| 1635 | (struct usb_serial_port *)tty->driver_data; | 1621 | (struct usb_serial_port *)tty->driver_data; |
| 1636 | 1622 | ||
| 1637 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1623 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1638 | int retval = -ENODEV; | 1624 | int retval = -ENODEV; |
| 1639 | unsigned int UartNumber; | 1625 | unsigned int UartNumber; |
| 1640 | mydbg("In %s \n", __FUNCTION__); | 1626 | mydbg("In %s \n", __func__); |
| 1641 | 1627 | ||
| 1642 | if (!serial) | 1628 | if (!serial) |
| 1643 | return -ENODEV; | 1629 | return -ENODEV; |
| @@ -1646,11 +1632,11 @@ static int serial_tiocmget(struct tty_struct *tty, struct file *file) | |||
| 1646 | 1632 | ||
| 1647 | down(&port->sem); | 1633 | down(&port->sem); |
| 1648 | 1634 | ||
| 1649 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1635 | mydbg("%s - port %d\n", __func__, port->number); |
| 1650 | mydbg("%s - port->RxHolding = %d\n", __FUNCTION__, port->RxHolding); | 1636 | mydbg("%s - port->RxHolding = %d\n", __func__, port->RxHolding); |
| 1651 | 1637 | ||
| 1652 | if (!port->open_count) { | 1638 | if (!port->open_count) { |
| 1653 | mydbg("%s - port not open\n", __FUNCTION__); | 1639 | mydbg("%s - port not open\n", __func__); |
| 1654 | goto exit; | 1640 | goto exit; |
| 1655 | } | 1641 | } |
| 1656 | 1642 | ||
| @@ -1671,12 +1657,12 @@ static int qt_tiocmget(struct usb_serial_port *port, struct file *file) | |||
| 1671 | unsigned int UartNumber; | 1657 | unsigned int UartNumber; |
| 1672 | struct tty_struct *tty; | 1658 | struct tty_struct *tty; |
| 1673 | 1659 | ||
| 1674 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1660 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1675 | if (serial == NULL) | 1661 | if (serial == NULL) |
| 1676 | return -ENODEV; | 1662 | return -ENODEV; |
| 1677 | tty = port->tty; | 1663 | tty = port->tty; |
| 1678 | 1664 | ||
| 1679 | mydbg("%s - port %d, tty =0x%p\n", __FUNCTION__, port->number, tty); | 1665 | mydbg("%s - port %d, tty =0x%p\n", __func__, port->number, tty); |
| 1680 | 1666 | ||
| 1681 | /**************************************************************************************/ | 1667 | /**************************************************************************************/ |
| 1682 | /** TIOCMGET | 1668 | /** TIOCMGET |
| @@ -1694,22 +1680,21 @@ static int qt_tiocmget(struct usb_serial_port *port, struct file *file) | |||
| 1694 | 1680 | ||
| 1695 | if (status >= 0) { | 1681 | if (status >= 0) { |
| 1696 | result = ((MCR_Value & SERIAL_MCR_DTR) ? TIOCM_DTR : 0) | 1682 | result = ((MCR_Value & SERIAL_MCR_DTR) ? TIOCM_DTR : 0) |
| 1697 | //DTR IS SET | 1683 | /* DTR IS SET */ |
| 1698 | | ((MCR_Value & SERIAL_MCR_RTS) ? TIOCM_RTS : 0) | 1684 | | ((MCR_Value & SERIAL_MCR_RTS) ? TIOCM_RTS : 0) |
| 1699 | //RTS IS SET | 1685 | /* RTS IS SET */ |
| 1700 | | ((MSR_Value & SERIAL_MSR_CTS) ? TIOCM_CTS : 0) | 1686 | | ((MSR_Value & SERIAL_MSR_CTS) ? TIOCM_CTS : 0) |
| 1701 | //CTS is set | 1687 | /* CTS is set */ |
| 1702 | | ((MSR_Value & SERIAL_MSR_CD) ? TIOCM_CAR : 0) | 1688 | | ((MSR_Value & SERIAL_MSR_CD) ? TIOCM_CAR : 0) |
| 1703 | //Carrier detect is set | 1689 | /* Carrier detect is set */ |
| 1704 | | ((MSR_Value & SERIAL_MSR_RI) ? TIOCM_RI : 0) | 1690 | | ((MSR_Value & SERIAL_MSR_RI) ? TIOCM_RI : 0) |
| 1705 | //Ring indicator set | 1691 | /* Ring indicator set */ |
| 1706 | | ((MSR_Value & SERIAL_MSR_DSR) ? TIOCM_DSR : 0); | 1692 | | ((MSR_Value & SERIAL_MSR_DSR) ? TIOCM_DSR : 0); |
| 1707 | //DSR is set | 1693 | /* DSR is set */ |
| 1708 | return result; | 1694 | return result; |
| 1709 | 1695 | ||
| 1710 | } else | 1696 | } else |
| 1711 | return -ESPIPE; | 1697 | return -ESPIPE; |
| 1712 | //endif tatus => 0 | ||
| 1713 | } | 1698 | } |
| 1714 | 1699 | ||
| 1715 | static int serial_ioctl(struct tty_struct *tty, struct file *file, | 1700 | static int serial_ioctl(struct tty_struct *tty, struct file *file, |
| @@ -1718,10 +1703,10 @@ static int serial_ioctl(struct tty_struct *tty, struct file *file, | |||
| 1718 | 1703 | ||
| 1719 | struct usb_serial_port *port = | 1704 | struct usb_serial_port *port = |
| 1720 | (struct usb_serial_port *)tty->driver_data; | 1705 | (struct usb_serial_port *)tty->driver_data; |
| 1721 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1706 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1722 | int retval = -ENODEV; | 1707 | int retval = -ENODEV; |
| 1723 | unsigned int UartNumber; | 1708 | unsigned int UartNumber; |
| 1724 | mydbg("In %s \n", __FUNCTION__); | 1709 | mydbg("In %s \n", __func__); |
| 1725 | 1710 | ||
| 1726 | if (!serial) | 1711 | if (!serial) |
| 1727 | return -ENODEV; | 1712 | return -ENODEV; |
| @@ -1730,11 +1715,11 @@ static int serial_ioctl(struct tty_struct *tty, struct file *file, | |||
| 1730 | 1715 | ||
| 1731 | down(&port->sem); | 1716 | down(&port->sem); |
| 1732 | 1717 | ||
| 1733 | mydbg("%s - port %d, cmd 0x%.4x\n", __FUNCTION__, port->number, cmd); | 1718 | mydbg("%s - port %d, cmd 0x%.4x\n", __func__, port->number, cmd); |
| 1734 | mydbg("%s - port->RxHolding = %d\n", __FUNCTION__, port->RxHolding); | 1719 | mydbg("%s - port->RxHolding = %d\n", __func__, port->RxHolding); |
| 1735 | 1720 | ||
| 1736 | if (!port->open_count) { | 1721 | if (!port->open_count) { |
| 1737 | mydbg("%s - port not open\n", __FUNCTION__); | 1722 | mydbg("%s - port not open\n", __func__); |
| 1738 | goto exit; | 1723 | goto exit; |
| 1739 | } | 1724 | } |
| 1740 | 1725 | ||
| @@ -1755,16 +1740,14 @@ static int qt_ioctl(struct usb_serial_port *port, struct file *file, | |||
| 1755 | unsigned int UartNumber; | 1740 | unsigned int UartNumber; |
| 1756 | struct tty_struct *tty; | 1741 | struct tty_struct *tty; |
| 1757 | 1742 | ||
| 1758 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1743 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1759 | if (serial == NULL) | 1744 | if (serial == NULL) |
| 1760 | return -ENODEV; | 1745 | return -ENODEV; |
| 1761 | tty = port->tty; | 1746 | tty = port->tty; |
| 1762 | 1747 | ||
| 1763 | mydbg("%s - port %d, tty =0x%p\n", __FUNCTION__, port->number, tty); | 1748 | mydbg("%s - port %d, tty =0x%p\n", __func__, port->number, tty); |
| 1764 | 1749 | ||
| 1765 | /**************************************************************************************/ | 1750 | /* TIOCMGET */ |
| 1766 | /** TIOCMGET | ||
| 1767 | */ | ||
| 1768 | UartNumber = port->tty->index - serial->minor; | 1751 | UartNumber = port->tty->index - serial->minor; |
| 1769 | 1752 | ||
| 1770 | if (cmd == TIOCMGET) { | 1753 | if (cmd == TIOCMGET) { |
| @@ -1773,34 +1756,27 @@ static int qt_ioctl(struct usb_serial_port *port, struct file *file, | |||
| 1773 | 1756 | ||
| 1774 | { | 1757 | { |
| 1775 | result = ((MCR_Value & SERIAL_MCR_DTR) ? TIOCM_DTR : 0) | 1758 | result = ((MCR_Value & SERIAL_MCR_DTR) ? TIOCM_DTR : 0) |
| 1776 | //DTR IS SET | 1759 | /* DTR IS SET */ |
| 1777 | | ((MCR_Value & SERIAL_MCR_RTS) ? TIOCM_RTS : 0) | 1760 | | ((MCR_Value & SERIAL_MCR_RTS) ? TIOCM_RTS : 0) |
| 1778 | //RTS IS SET | 1761 | /* RTS IS SET */ |
| 1779 | | ((MSR_Value & SERIAL_MSR_CTS) ? TIOCM_CTS : 0) | 1762 | | ((MSR_Value & SERIAL_MSR_CTS) ? TIOCM_CTS : 0) |
| 1780 | //CTS is set | 1763 | /* CTS is set */ |
| 1781 | | ((MSR_Value & SERIAL_MSR_CD) ? TIOCM_CAR : 0) | 1764 | | ((MSR_Value & SERIAL_MSR_CD) ? TIOCM_CAR : 0) |
| 1782 | //Carrier detect is set | 1765 | /* Carrier detect is set */ |
| 1783 | | ((MSR_Value & SERIAL_MSR_RI) ? TIOCM_RI : 0) | 1766 | | ((MSR_Value & SERIAL_MSR_RI) ? TIOCM_RI : 0) |
| 1784 | //Ring indicator set | 1767 | /* Ring indicator set */ |
| 1785 | | ((MSR_Value & SERIAL_MSR_DSR) ? TIOCM_DSR : 0); | 1768 | | ((MSR_Value & SERIAL_MSR_DSR) ? TIOCM_DSR : 0); |
| 1786 | //DSR is set | 1769 | /* DSR is set */ |
| 1787 | if (copy_to_user | 1770 | if (copy_to_user |
| 1788 | ((unsigned int *)arg, &result, | 1771 | ((unsigned int *)arg, &result, |
| 1789 | sizeof(unsigned int))) | 1772 | sizeof(unsigned int))) |
| 1790 | return -EFAULT; | 1773 | return -EFAULT; |
| 1791 | return 0; | 1774 | return 0; |
| 1792 | 1775 | ||
| 1793 | } //endif tatus => 0 | 1776 | } |
| 1794 | 1777 | } | |
| 1795 | } //endif(cmd == TIOCMGET) | ||
| 1796 | /**************************************************************************************/ | ||
| 1797 | /** End TIOCMGET | ||
| 1798 | */ | ||
| 1799 | /**************************************************************************************/ | ||
| 1800 | /** TIOCMBIS, TIOCMBIC, AND TIOCMSET */ | ||
| 1801 | |||
| 1802 | /**************************************************************************************/ | ||
| 1803 | 1778 | ||
| 1779 | /* TIOCMBIS, TIOCMBIC, AND TIOCMSET */ | ||
| 1804 | if (cmd == TIOCMBIS || cmd == TIOCMBIC || cmd == TIOCMSET) { | 1780 | if (cmd == TIOCMBIS || cmd == TIOCMBIC || cmd == TIOCMSET) { |
| 1805 | status = | 1781 | status = |
| 1806 | BoxGetRegister(port->serial, UartNumber, | 1782 | BoxGetRegister(port->serial, UartNumber, |
| @@ -1829,8 +1805,10 @@ static int qt_ioctl(struct usb_serial_port *port, struct file *file, | |||
| 1829 | MCR_Value &= ~SERIAL_MCR_LOOP; | 1805 | MCR_Value &= ~SERIAL_MCR_LOOP; |
| 1830 | break; | 1806 | break; |
| 1831 | case TIOCMSET: | 1807 | case TIOCMSET: |
| 1832 | //Turn off the RTS and DTR and loopbcck and then only | 1808 | /* |
| 1833 | //trun on what was asked for | 1809 | * Turn off the RTS and DTR and loopbcck and then only |
| 1810 | * turn on what was asked for | ||
| 1811 | */ | ||
| 1834 | MCR_Value &= | 1812 | MCR_Value &= |
| 1835 | ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR | | 1813 | ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR | |
| 1836 | SERIAL_MCR_LOOP); | 1814 | SERIAL_MCR_LOOP); |
| @@ -1874,7 +1852,7 @@ static int qt_ioctl(struct usb_serial_port *port, struct file *file, | |||
| 1874 | return -ERESTARTSYS; | 1852 | return -ERESTARTSYS; |
| 1875 | MSR_Value = port->shadowMSR & SERIAL_MSR_MASK; | 1853 | MSR_Value = port->shadowMSR & SERIAL_MSR_MASK; |
| 1876 | if (MSR_Value == Prev_MSR_Value) | 1854 | if (MSR_Value == Prev_MSR_Value) |
| 1877 | return -EIO; //no change error | 1855 | return -EIO; /* no change error */ |
| 1878 | 1856 | ||
| 1879 | if ((arg & TIOCM_RNG | 1857 | if ((arg & TIOCM_RNG |
| 1880 | && ((Prev_MSR_Value & SERIAL_MSR_RI) == | 1858 | && ((Prev_MSR_Value & SERIAL_MSR_RI) == |
| @@ -1891,10 +1869,10 @@ static int qt_ioctl(struct usb_serial_port *port, struct file *file, | |||
| 1891 | return 0; | 1869 | return 0; |
| 1892 | } | 1870 | } |
| 1893 | 1871 | ||
| 1894 | } //endwhile | 1872 | } |
| 1895 | 1873 | ||
| 1896 | } | 1874 | } |
| 1897 | mydbg("%s -No ioctl for that one. port = %d\n", __FUNCTION__, | 1875 | mydbg("%s -No ioctl for that one. port = %d\n", __func__, |
| 1898 | port->number); | 1876 | port->number); |
| 1899 | 1877 | ||
| 1900 | return -ENOIOCTLCMD; | 1878 | return -ENOIOCTLCMD; |
| @@ -1904,17 +1882,17 @@ static void serial_set_termios(struct tty_struct *tty, struct ktermios *old) | |||
| 1904 | { | 1882 | { |
| 1905 | struct usb_serial_port *port = | 1883 | struct usb_serial_port *port = |
| 1906 | (struct usb_serial_port *)tty->driver_data; | 1884 | (struct usb_serial_port *)tty->driver_data; |
| 1907 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 1885 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 1908 | 1886 | ||
| 1909 | if (!serial) | 1887 | if (!serial) |
| 1910 | return; | 1888 | return; |
| 1911 | 1889 | ||
| 1912 | down(&port->sem); | 1890 | down(&port->sem); |
| 1913 | 1891 | ||
| 1914 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1892 | mydbg("%s - port %d\n", __func__, port->number); |
| 1915 | 1893 | ||
| 1916 | if (!port->open_count) { | 1894 | if (!port->open_count) { |
| 1917 | mydbg("%s - port not open\n", __FUNCTION__); | 1895 | mydbg("%s - port not open\n", __func__); |
| 1918 | goto exit; | 1896 | goto exit; |
| 1919 | } | 1897 | } |
| 1920 | 1898 | ||
| @@ -1937,14 +1915,14 @@ static void qt_set_termios(struct usb_serial_port *port, | |||
| 1937 | __u16 UartNumber; | 1915 | __u16 UartNumber; |
| 1938 | __u16 tmp, tmp2; | 1916 | __u16 tmp, tmp2; |
| 1939 | 1917 | ||
| 1940 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 1918 | mydbg("%s - port %d\n", __func__, port->number); |
| 1941 | 1919 | ||
| 1942 | tmp = port->tty->index; | 1920 | tmp = port->tty->index; |
| 1943 | mydbg("%s - MINOR(port->tty->index) = %d\n", __FUNCTION__, tmp); | 1921 | mydbg("%s - MINOR(port->tty->index) = %d\n", __func__, tmp); |
| 1944 | 1922 | ||
| 1945 | serial = port->serial; | 1923 | serial = port->serial; |
| 1946 | tmp2 = serial->minor; | 1924 | tmp2 = serial->minor; |
| 1947 | mydbg("%s - serial->minor = %d\n", __FUNCTION__, tmp2); | 1925 | mydbg("%s - serial->minor = %d\n", __func__, tmp2); |
| 1948 | 1926 | ||
| 1949 | UartNumber = port->tty->index - serial->minor; | 1927 | UartNumber = port->tty->index - serial->minor; |
| 1950 | 1928 | ||
| @@ -1956,13 +1934,13 @@ static void qt_set_termios(struct usb_serial_port *port, | |||
| 1956 | if ((cflag == old_termios->c_cflag) | 1934 | if ((cflag == old_termios->c_cflag) |
| 1957 | && (RELEVANT_IFLAG(tty->termios->c_iflag) == | 1935 | && (RELEVANT_IFLAG(tty->termios->c_iflag) == |
| 1958 | RELEVANT_IFLAG(old_termios->c_iflag))) { | 1936 | RELEVANT_IFLAG(old_termios->c_iflag))) { |
| 1959 | mydbg("%s - Nothing to change\n", __FUNCTION__); | 1937 | mydbg("%s - Nothing to change\n", __func__); |
| 1960 | return; | 1938 | return; |
| 1961 | } | 1939 | } |
| 1962 | 1940 | ||
| 1963 | } | 1941 | } |
| 1964 | 1942 | ||
| 1965 | mydbg("%s - 3\n", __FUNCTION__); | 1943 | mydbg("%s - 3\n", __func__); |
| 1966 | 1944 | ||
| 1967 | switch (cflag) { | 1945 | switch (cflag) { |
| 1968 | case CS5: | 1946 | case CS5: |
| @@ -1980,7 +1958,7 @@ static void qt_set_termios(struct usb_serial_port *port, | |||
| 1980 | break; | 1958 | break; |
| 1981 | } | 1959 | } |
| 1982 | 1960 | ||
| 1983 | //Parity stuff | 1961 | /* Parity stuff */ |
| 1984 | if (cflag & PARENB) { | 1962 | if (cflag & PARENB) { |
| 1985 | if (cflag & PARODD) | 1963 | if (cflag & PARODD) |
| 1986 | LCR_change_to |= SERIAL_ODD_PARITY; | 1964 | LCR_change_to |= SERIAL_ODD_PARITY; |
| @@ -1992,23 +1970,25 @@ static void qt_set_termios(struct usb_serial_port *port, | |||
| 1992 | else | 1970 | else |
| 1993 | LCR_change_to |= SERIAL_TWO_STOPB; | 1971 | LCR_change_to |= SERIAL_TWO_STOPB; |
| 1994 | 1972 | ||
| 1995 | mydbg("%s - 4\n", __FUNCTION__); | 1973 | mydbg("%s - 4\n", __func__); |
| 1996 | //Thats the LCR stuff, go ahead and set it | 1974 | /* Thats the LCR stuff, go ahead and set it */ |
| 1997 | baud = tty_get_baud_rate(tty); | 1975 | baud = tty_get_baud_rate(tty); |
| 1998 | if (!baud) { | 1976 | if (!baud) { |
| 1999 | /* pick a default, any default... */ | 1977 | /* pick a default, any default... */ |
| 2000 | baud = 9600; | 1978 | baud = 9600; |
| 2001 | } | 1979 | } |
| 2002 | 1980 | ||
| 2003 | mydbg("%s - got baud = %d\n", __FUNCTION__, baud); | 1981 | mydbg("%s - got baud = %d\n", __func__, baud); |
| 2004 | 1982 | ||
| 2005 | divisor = MAX_BAUD_RATE / baud; | 1983 | divisor = MAX_BAUD_RATE / baud; |
| 2006 | remainder = MAX_BAUD_RATE % baud; | 1984 | remainder = MAX_BAUD_RATE % baud; |
| 2007 | //Round to nearest divisor | 1985 | /* Round to nearest divisor */ |
| 2008 | if (((remainder * 2) >= baud) && (baud != 110)) | 1986 | if (((remainder * 2) >= baud) && (baud != 110)) |
| 2009 | divisor++; | 1987 | divisor++; |
| 2010 | 1988 | ||
| 2011 | //Set Baud rate to default and turn off (default)flow control here | 1989 | /* |
| 1990 | * Set Baud rate to default and turn off (default)flow control here | ||
| 1991 | */ | ||
| 2012 | status = | 1992 | status = |
| 2013 | BoxSetUart(serial, UartNumber, (unsigned short)divisor, | 1993 | BoxSetUart(serial, UartNumber, (unsigned short)divisor, |
| 2014 | LCR_change_to); | 1994 | LCR_change_to); |
| @@ -2016,13 +1996,13 @@ static void qt_set_termios(struct usb_serial_port *port, | |||
| 2016 | mydbg(__FILE__ "BoxSetUart failed\n"); | 1996 | mydbg(__FILE__ "BoxSetUart failed\n"); |
| 2017 | return; | 1997 | return; |
| 2018 | } | 1998 | } |
| 2019 | //************************Now determine flow control | ||
| 2020 | 1999 | ||
| 2000 | /* Now determine flow control */ | ||
| 2021 | if (cflag & CRTSCTS) { | 2001 | if (cflag & CRTSCTS) { |
| 2022 | mydbg("%s - Enabling HW flow control port %d\n", __FUNCTION__, | 2002 | mydbg("%s - Enabling HW flow control port %d\n", __func__, |
| 2023 | port->number); | 2003 | port->number); |
| 2024 | 2004 | ||
| 2025 | //Enable RTS/CTS flow control | 2005 | /* Enable RTS/CTS flow control */ |
| 2026 | status = BoxSetHW_FlowCtrl(serial, UartNumber, 1); | 2006 | status = BoxSetHW_FlowCtrl(serial, UartNumber, 1); |
| 2027 | 2007 | ||
| 2028 | if (status < 0) { | 2008 | if (status < 0) { |
| @@ -2030,8 +2010,8 @@ static void qt_set_termios(struct usb_serial_port *port, | |||
| 2030 | return; | 2010 | return; |
| 2031 | } | 2011 | } |
| 2032 | } else { | 2012 | } else { |
| 2033 | //Disable RTS/CTS flow control | 2013 | /* Disable RTS/CTS flow control */ |
| 2034 | mydbg("%s - disabling HW flow control port %d\n", __FUNCTION__, | 2014 | mydbg("%s - disabling HW flow control port %d\n", __func__, |
| 2035 | port->number); | 2015 | port->number); |
| 2036 | 2016 | ||
| 2037 | status = BoxSetHW_FlowCtrl(serial, UartNumber, 0); | 2017 | status = BoxSetHW_FlowCtrl(serial, UartNumber, 0); |
| @@ -2042,8 +2022,8 @@ static void qt_set_termios(struct usb_serial_port *port, | |||
| 2042 | 2022 | ||
| 2043 | } | 2023 | } |
| 2044 | 2024 | ||
| 2045 | //************************************************* | 2025 | /* if we are implementing XON/XOFF, set the start and stop character in |
| 2046 | /* if we are implementing XON/XOFF, set the start and stop character in the device */ | 2026 | * the device */ |
| 2047 | if (I_IXOFF(tty) || I_IXON(tty)) { | 2027 | if (I_IXOFF(tty) || I_IXON(tty)) { |
| 2048 | unsigned char stop_char = STOP_CHAR(tty); | 2028 | unsigned char stop_char = STOP_CHAR(tty); |
| 2049 | unsigned char start_char = START_CHAR(tty); | 2029 | unsigned char start_char = START_CHAR(tty); |
| @@ -2054,7 +2034,7 @@ static void qt_set_termios(struct usb_serial_port *port, | |||
| 2054 | mydbg(__FILE__ "BoxSetSW_FlowCtrl (enabled) failed\n"); | 2034 | mydbg(__FILE__ "BoxSetSW_FlowCtrl (enabled) failed\n"); |
| 2055 | 2035 | ||
| 2056 | } else { | 2036 | } else { |
| 2057 | //disable SW flow control | 2037 | /* disable SW flow control */ |
| 2058 | status = BoxDisable_SW_FlowCtrl(serial, UartNumber); | 2038 | status = BoxDisable_SW_FlowCtrl(serial, UartNumber); |
| 2059 | if (status < 0) | 2039 | if (status < 0) |
| 2060 | mydbg(__FILE__ "BoxSetSW_FlowCtrl (diabling) failed\n"); | 2040 | mydbg(__FILE__ "BoxSetSW_FlowCtrl (diabling) failed\n"); |
| @@ -2069,7 +2049,7 @@ static void qt_set_termios(struct usb_serial_port *port, | |||
| 2069 | * If successful, fills in the pValue with the register value asked for | 2049 | * If successful, fills in the pValue with the register value asked for |
| 2070 | ****************************************************************************/ | 2050 | ****************************************************************************/ |
| 2071 | static int BoxGetRegister(struct usb_serial *serial, unsigned short Uart_Number, | 2051 | static int BoxGetRegister(struct usb_serial *serial, unsigned short Uart_Number, |
| 2072 | unsigned short Register_Num, __u8 * pValue) | 2052 | unsigned short Register_Num, __u8 *pValue) |
| 2073 | { | 2053 | { |
| 2074 | int result; | 2054 | int result; |
| 2075 | __u16 current_length; | 2055 | __u16 current_length; |
| @@ -2099,8 +2079,11 @@ static int BoxSetRegister(struct usb_serial *serial, unsigned short Uart_Number, | |||
| 2099 | RegAndByte = RegAndByte << 8; | 2079 | RegAndByte = RegAndByte << 8; |
| 2100 | RegAndByte = RegAndByte + Register_Num; | 2080 | RegAndByte = RegAndByte + Register_Num; |
| 2101 | 2081 | ||
| 2102 | // result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), QT_GET_SET_REGISTER, | 2082 | /* |
| 2103 | // 0xC0, Register_Num, Uart_Number, NULL, 0, 300); | 2083 | result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
| 2084 | QT_GET_SET_REGISTER, 0xC0, Register_Num, | ||
| 2085 | Uart_Number, NULL, 0, 300); | ||
| 2086 | */ | ||
| 2104 | 2087 | ||
| 2105 | result = | 2088 | result = |
| 2106 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 2089 | usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
| @@ -2156,7 +2139,7 @@ static int box_set_device(struct usb_serial *serial, | |||
| 2156 | PortSettings += ((__u16) (device_data->porta)); | 2139 | PortSettings += ((__u16) (device_data->porta)); |
| 2157 | 2140 | ||
| 2158 | length = sizeof(struct qt_get_device_data); | 2141 | length = sizeof(struct qt_get_device_data); |
| 2159 | mydbg("%s - PortSettings = 0x%x\n", __FUNCTION__, PortSettings); | 2142 | mydbg("%s - PortSettings = 0x%x\n", __func__, PortSettings); |
| 2160 | 2143 | ||
| 2161 | result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 2144 | result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
| 2162 | QT_SET_GET_DEVICE, 0x40, PortSettings, | 2145 | QT_SET_GET_DEVICE, 0x40, PortSettings, |
| @@ -2180,8 +2163,8 @@ static int BoxOPenCloseChannel(struct usb_serial *serial, __u16 Uart_Number, | |||
| 2180 | unsigned int pipe; | 2163 | unsigned int pipe; |
| 2181 | length = sizeof(struct qt_open_channel_data); | 2164 | length = sizeof(struct qt_open_channel_data); |
| 2182 | 2165 | ||
| 2183 | if (OpenClose == 1) //IF OPENING | 2166 | /* if opening... */ |
| 2184 | { | 2167 | if (OpenClose == 1) { |
| 2185 | Direcion = USBD_TRANSFER_DIRECTION_IN; | 2168 | Direcion = USBD_TRANSFER_DIRECTION_IN; |
| 2186 | pipe = usb_rcvctrlpipe(serial->dev, 0); | 2169 | pipe = usb_rcvctrlpipe(serial->dev, 0); |
| 2187 | result = | 2170 | result = |
| @@ -2268,18 +2251,23 @@ static int BoxSetHW_FlowCtrl(struct usb_serial *serial, unsigned int UartNumber, | |||
| 2268 | port = serial->port; | 2251 | port = serial->port; |
| 2269 | 2252 | ||
| 2270 | if (bSet == 1) { | 2253 | if (bSet == 1) { |
| 2271 | MCR_Value = SERIAL_MCR_RTS; //flow control, box will clear RTS line to prevent remote | 2254 | /* flow control, box will clear RTS line to prevent remote */ |
| 2272 | } //device from xmitting more chars | 2255 | MCR_Value = SERIAL_MCR_RTS; |
| 2273 | else { //no flow control to remote device | 2256 | } /* device from xmitting more chars */ |
| 2257 | else { | ||
| 2258 | /* no flow control to remote device */ | ||
| 2274 | MCR_Value = 0; | 2259 | MCR_Value = 0; |
| 2275 | 2260 | ||
| 2276 | } | 2261 | } |
| 2277 | MOUT_Value = MCR_Value << 8; | 2262 | MOUT_Value = MCR_Value << 8; |
| 2278 | 2263 | ||
| 2279 | if (bSet == 1) { | 2264 | if (bSet == 1) { |
| 2280 | MSR_Value = SERIAL_MSR_CTS; //flow control, box will inhibit xmit data if CTS line is asserted | 2265 | /* flow control, box will inhibit xmit data if CTS line is |
| 2266 | * asserted */ | ||
| 2267 | MSR_Value = SERIAL_MSR_CTS; | ||
| 2281 | } else { | 2268 | } else { |
| 2282 | MSR_Value = 0; //Box will not inhimbe xmit data due to CTS line | 2269 | /* Box will not inhimbe xmit data due to CTS line */ |
| 2270 | MSR_Value = 0; | ||
| 2283 | } | 2271 | } |
| 2284 | MOUT_Value |= MSR_Value; | 2272 | MOUT_Value |= MSR_Value; |
| 2285 | 2273 | ||
| @@ -2319,18 +2307,12 @@ static int BoxDisable_SW_FlowCtrl(struct usb_serial *serial, __u16 UartNumber) | |||
| 2319 | 2307 | ||
| 2320 | } | 2308 | } |
| 2321 | 2309 | ||
| 2322 | /***************************************************************************** | ||
| 2323 | * SerialThrottle | ||
| 2324 | * this function is called by the tty driver when it wants to stop the data | ||
| 2325 | * being read from the port. | ||
| 2326 | *****************************************************************************/ | ||
| 2327 | |||
| 2328 | static void serial_throttle(struct tty_struct *tty) | 2310 | static void serial_throttle(struct tty_struct *tty) |
| 2329 | { | 2311 | { |
| 2330 | struct usb_serial_port *port = | 2312 | struct usb_serial_port *port = |
| 2331 | (struct usb_serial_port *)tty->driver_data; | 2313 | (struct usb_serial_port *)tty->driver_data; |
| 2332 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 2314 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 2333 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 2315 | mydbg("%s - port %d\n", __func__, port->number); |
| 2334 | 2316 | ||
| 2335 | if (!serial) | 2317 | if (!serial) |
| 2336 | return; | 2318 | return; |
| @@ -2338,14 +2320,14 @@ static void serial_throttle(struct tty_struct *tty) | |||
| 2338 | down(&port->sem); | 2320 | down(&port->sem); |
| 2339 | 2321 | ||
| 2340 | if (!port->open_count) { | 2322 | if (!port->open_count) { |
| 2341 | mydbg("%s - port not open\n", __FUNCTION__); | 2323 | mydbg("%s - port not open\n", __func__); |
| 2342 | goto exit; | 2324 | goto exit; |
| 2343 | } | 2325 | } |
| 2344 | //shut down any bulk reads that may be going on | 2326 | /* shut down any bulk reads that may be going on */ |
| 2345 | // usb_unlink_urb (port->read_urb); | 2327 | /* usb_unlink_urb (port->read_urb); */ |
| 2346 | /* pass on to the driver specific version of this function */ | 2328 | /* pass on to the driver specific version of this function */ |
| 2347 | port->RxHolding = 1; | 2329 | port->RxHolding = 1; |
| 2348 | mydbg("%s - port->RxHolding = 1\n", __FUNCTION__); | 2330 | mydbg("%s - port->RxHolding = 1\n", __func__); |
| 2349 | 2331 | ||
| 2350 | exit: | 2332 | exit: |
| 2351 | up(&port->sem); | 2333 | up(&port->sem); |
| @@ -2356,25 +2338,25 @@ static void serial_unthrottle(struct tty_struct *tty) | |||
| 2356 | { | 2338 | { |
| 2357 | struct usb_serial_port *port = | 2339 | struct usb_serial_port *port = |
| 2358 | (struct usb_serial_port *)tty->driver_data; | 2340 | (struct usb_serial_port *)tty->driver_data; |
| 2359 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 2341 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 2360 | unsigned int result; | 2342 | unsigned int result; |
| 2361 | 2343 | ||
| 2362 | if (!serial) | 2344 | if (!serial) |
| 2363 | return; | 2345 | return; |
| 2364 | down(&port->sem); | 2346 | down(&port->sem); |
| 2365 | 2347 | ||
| 2366 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 2348 | mydbg("%s - port %d\n", __func__, port->number); |
| 2367 | 2349 | ||
| 2368 | if (!port->open_count) { | 2350 | if (!port->open_count) { |
| 2369 | mydbg("%s - port not open\n", __FUNCTION__); | 2351 | mydbg("%s - port not open\n", __func__); |
| 2370 | goto exit; | 2352 | goto exit; |
| 2371 | } | 2353 | } |
| 2372 | 2354 | ||
| 2373 | if (port->RxHolding == 1) { | 2355 | if (port->RxHolding == 1) { |
| 2374 | mydbg("%s -port->RxHolding == 1\n", __FUNCTION__); | 2356 | mydbg("%s -port->RxHolding == 1\n", __func__); |
| 2375 | 2357 | ||
| 2376 | port->RxHolding = 0; | 2358 | port->RxHolding = 0; |
| 2377 | mydbg("%s - port->RxHolding = 0\n", __FUNCTION__); | 2359 | mydbg("%s - port->RxHolding = 0\n", __func__); |
| 2378 | 2360 | ||
| 2379 | /* if we have a bulk endpoint, start it up */ | 2361 | /* if we have a bulk endpoint, start it up */ |
| 2380 | if ((serial->num_bulk_in) && (port->ReadBulkStopped == 1)) { | 2362 | if ((serial->num_bulk_in) && (port->ReadBulkStopped == 1)) { |
| @@ -2390,7 +2372,7 @@ static void serial_unthrottle(struct tty_struct *tty) | |||
| 2390 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); | 2372 | result = usb_submit_urb(port->read_urb, GFP_ATOMIC); |
| 2391 | if (result) | 2373 | if (result) |
| 2392 | err("%s - failed restarting read urb, error %d", | 2374 | err("%s - failed restarting read urb, error %d", |
| 2393 | __FUNCTION__, result); | 2375 | __func__, result); |
| 2394 | } | 2376 | } |
| 2395 | } | 2377 | } |
| 2396 | exit: | 2378 | exit: |
| @@ -2403,7 +2385,7 @@ static int serial_break(struct tty_struct *tty, int break_state) | |||
| 2403 | { | 2385 | { |
| 2404 | struct usb_serial_port *port = | 2386 | struct usb_serial_port *port = |
| 2405 | (struct usb_serial_port *)tty->driver_data; | 2387 | (struct usb_serial_port *)tty->driver_data; |
| 2406 | struct usb_serial *serial = get_usb_serial(port, __FUNCTION__); | 2388 | struct usb_serial *serial = get_usb_serial(port, __func__); |
| 2407 | __u16 UartNumber, Break_Value; | 2389 | __u16 UartNumber, Break_Value; |
| 2408 | unsigned int result; | 2390 | unsigned int result; |
| 2409 | 2391 | ||
| @@ -2418,10 +2400,10 @@ static int serial_break(struct tty_struct *tty, int break_state) | |||
| 2418 | 2400 | ||
| 2419 | down(&port->sem); | 2401 | down(&port->sem); |
| 2420 | 2402 | ||
| 2421 | mydbg("%s - port %d\n", __FUNCTION__, port->number); | 2403 | mydbg("%s - port %d\n", __func__, port->number); |
| 2422 | 2404 | ||
| 2423 | if (!port->open_count) { | 2405 | if (!port->open_count) { |
| 2424 | mydbg("%s - port not open\n", __FUNCTION__); | 2406 | mydbg("%s - port not open\n", __func__); |
| 2425 | goto exit; | 2407 | goto exit; |
| 2426 | } | 2408 | } |
| 2427 | 2409 | ||
| @@ -2443,7 +2425,7 @@ static int serial_read_proc(char *page, char **start, off_t off, int count, | |||
| 2443 | int i; | 2425 | int i; |
| 2444 | off_t begin = 0; | 2426 | off_t begin = 0; |
| 2445 | 2427 | ||
| 2446 | mydbg("%s\n", __FUNCTION__); | 2428 | mydbg("%s\n", __func__); |
| 2447 | length += sprintf(page, "usbserinfo:1.0 driver:%s\n", DRIVER_VERSION); | 2429 | length += sprintf(page, "usbserinfo:1.0 driver:%s\n", DRIVER_VERSION); |
| 2448 | for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) { | 2430 | for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) { |
| 2449 | serial = get_serial_by_minor(i); | 2431 | serial = get_serial_by_minor(i); |
| @@ -2460,8 +2442,10 @@ static int serial_read_proc(char *page, char **start, off_t off, int count, | |||
| 2460 | length += | 2442 | length += |
| 2461 | sprintf(page + length, " port:%d\n", i - serial->minor + 1); | 2443 | sprintf(page + length, " port:%d\n", i - serial->minor + 1); |
| 2462 | 2444 | ||
| 2463 | // usb_make_path(serial->dev, tmp, sizeof(tmp)); | 2445 | /* |
| 2464 | // length += sprintf (page+length, " path:%s", tmp); | 2446 | usb_make_path(serial->dev, tmp, sizeof(tmp)); |
| 2447 | length += sprintf (page+length, " path:%s", tmp); | ||
| 2448 | */ | ||
| 2465 | 2449 | ||
| 2466 | length += sprintf(page + length, "\n"); | 2450 | length += sprintf(page + length, "\n"); |
| 2467 | if ((length + begin) > (off + count)) | 2451 | if ((length + begin) > (off + count)) |
| @@ -2479,7 +2463,7 @@ done: | |||
| 2479 | return ((count < begin + length - off) ? count : begin + length - off); | 2463 | return ((count < begin + length - off) ? count : begin + length - off); |
| 2480 | } | 2464 | } |
| 2481 | 2465 | ||
| 2482 | int ioctl_serial_usb(struct inode *innod, struct file *filp, unsigned int cmd, | 2466 | static int ioctl_serial_usb(struct inode *innod, struct file *filp, unsigned int cmd, |
| 2483 | unsigned long arg) | 2467 | unsigned long arg) |
| 2484 | { | 2468 | { |
| 2485 | 2469 | ||
| @@ -2500,7 +2484,7 @@ int ioctl_serial_usb(struct inode *innod, struct file *filp, unsigned int cmd, | |||
| 2500 | switch (cmd) { | 2484 | switch (cmd) { |
| 2501 | 2485 | ||
| 2502 | case SERIALQT_WRITE_QMCR: | 2486 | case SERIALQT_WRITE_QMCR: |
| 2503 | err = -ENOTTY; //initialize as error so if we don't find this one we give//an error. | 2487 | err = -ENOTTY; |
| 2504 | index = arg >> 16; | 2488 | index = arg >> 16; |
| 2505 | counts = 0; | 2489 | counts = 0; |
| 2506 | 2490 | ||
| @@ -2510,34 +2494,33 @@ int ioctl_serial_usb(struct inode *innod, struct file *filp, unsigned int cmd, | |||
| 2510 | break; | 2494 | break; |
| 2511 | 2495 | ||
| 2512 | case SERIALQT_READ_QMCR: | 2496 | case SERIALQT_READ_QMCR: |
| 2513 | err = -ENOTTY; //initialize as error so if we don't find this one we give | 2497 | err = -ENOTTY; |
| 2514 | //an error. | ||
| 2515 | p_QMCR_Value = (int *)arg; | 2498 | p_QMCR_Value = (int *)arg; |
| 2516 | index = arg >> 16; | 2499 | index = arg >> 16; |
| 2517 | counts = 0; | 2500 | counts = 0; |
| 2518 | 2501 | ||
| 2519 | err = EmulateReadQMCR_Reg(index, &uc_Value); | 2502 | err = EmulateReadQMCR_Reg(index, &uc_Value); |
| 2520 | if (err == 0) { | 2503 | if (err == 0) |
| 2521 | err = put_user(uc_Value, p_QMCR_Value); | 2504 | err = put_user(uc_Value, p_QMCR_Value); |
| 2522 | } | ||
| 2523 | break; | 2505 | break; |
| 2524 | 2506 | ||
| 2525 | case SERIALQT_GET_NUMOF_UNITS: | 2507 | case SERIALQT_GET_NUMOF_UNITS: |
| 2526 | p_Num_of_adapters = (int *)arg; | 2508 | p_Num_of_adapters = (int *)arg; |
| 2527 | counts = 0; //Initialize counts to zero | 2509 | counts = 0; /* Initialize counts to zero */ |
| 2528 | //struct usb_serial *lastserial = serial_table[0], *serial; | 2510 | /* struct usb_serial *lastserial = serial_table[0], *serial; */ |
| 2529 | lastserial = serial_table[0]; | 2511 | lastserial = serial_table[0]; |
| 2530 | 2512 | ||
| 2531 | mydbg(KERN_DEBUG "SERIALQT_GET_NUMOF_UNITS \n"); | 2513 | mydbg(KERN_DEBUG "SERIALQT_GET_NUMOF_UNITS \n"); |
| 2532 | //if first pointer is nonull, we at least have one box | 2514 | /* if first pointer is nonull, we at least have one box */ |
| 2533 | if (lastserial) | 2515 | if (lastserial) |
| 2534 | counts = 1; //we at least have one box | 2516 | counts = 1; /* we at least have one box */ |
| 2535 | 2517 | ||
| 2536 | for (index = 1; index < SERIAL_TTY_MINORS; index++) { | 2518 | for (index = 1; index < SERIAL_TTY_MINORS; index++) { |
| 2537 | serial = serial_table[index]; | 2519 | serial = serial_table[index]; |
| 2538 | if (serial) { | 2520 | if (serial) { |
| 2539 | if (serial != lastserial) { | 2521 | if (serial != lastserial) { |
| 2540 | //we had a change in the array, hence another box is there | 2522 | /* we had a change in the array, hence |
| 2523 | * another box is there */ | ||
| 2541 | lastserial = serial; | 2524 | lastserial = serial; |
| 2542 | counts++; | 2525 | counts++; |
| 2543 | } | 2526 | } |
| @@ -2554,15 +2537,14 @@ int ioctl_serial_usb(struct inode *innod, struct file *filp, unsigned int cmd, | |||
| 2554 | case SERIALQT_GET_THIS_UNIT: | 2537 | case SERIALQT_GET_THIS_UNIT: |
| 2555 | counts = 0; | 2538 | counts = 0; |
| 2556 | p_Identity_of = (struct identity *)arg; | 2539 | p_Identity_of = (struct identity *)arg; |
| 2557 | //copy user structure to local variable | 2540 | /* copy user structure to local variable */ |
| 2558 | get_user(Identity_of.index, &p_Identity_of->index); | 2541 | get_user(Identity_of.index, &p_Identity_of->index); |
| 2559 | mydbg(KERN_DEBUG "SERIALQT_GET_THIS_UNIT Identity_of.index\n"); | 2542 | mydbg(KERN_DEBUG "SERIALQT_GET_THIS_UNIT Identity_of.index\n"); |
| 2560 | mydbg(KERN_DEBUG | 2543 | mydbg(KERN_DEBUG |
| 2561 | "SERIALQT_GET_THIS_UNIT Identity_of.index= 0x%x\n", | 2544 | "SERIALQT_GET_THIS_UNIT Identity_of.index= 0x%x\n", |
| 2562 | Identity_of.index); | 2545 | Identity_of.index); |
| 2563 | 2546 | ||
| 2564 | err = -ENOTTY; //initialize as error so if we don't find this one we give | 2547 | err = -ENOTTY; |
| 2565 | //an error. | ||
| 2566 | serial = find_the_box(Identity_of.index); | 2548 | serial = find_the_box(Identity_of.index); |
| 2567 | if (serial) { | 2549 | if (serial) { |
| 2568 | err = | 2550 | err = |
| @@ -2573,9 +2555,8 @@ int ioctl_serial_usb(struct inode *innod, struct file *filp, unsigned int cmd, | |||
| 2573 | break; | 2555 | break; |
| 2574 | 2556 | ||
| 2575 | case SERIALQT_IS422_EXTENDED: | 2557 | case SERIALQT_IS422_EXTENDED: |
| 2576 | err = -ENOTTY; //initialize as error so if we don't find this one we give | 2558 | err = -ENOTTY; |
| 2577 | mydbg(KERN_DEBUG "SERIALQT_IS422_EXTENDED \n"); | 2559 | mydbg(KERN_DEBUG "SERIALQT_IS422_EXTENDED \n"); |
| 2578 | //an error. | ||
| 2579 | index = arg >> 16; | 2560 | index = arg >> 16; |
| 2580 | 2561 | ||
| 2581 | counts = 0; | 2562 | counts = 0; |
| @@ -2585,20 +2566,20 @@ int ioctl_serial_usb(struct inode *innod, struct file *filp, unsigned int cmd, | |||
| 2585 | index); | 2566 | index); |
| 2586 | serial = find_the_box(index); | 2567 | serial = find_the_box(index); |
| 2587 | if (serial) { | 2568 | if (serial) { |
| 2588 | mydbg("%s index = 0x%x, serial = 0x%p\n", __FUNCTION__, | 2569 | mydbg("%s index = 0x%x, serial = 0x%p\n", __func__, |
| 2589 | index, serial); | 2570 | index, serial); |
| 2590 | for (counts = 0; serqt_422_table[counts] != 0; counts++) { | 2571 | for (counts = 0; serqt_422_table[counts] != 0; counts++) { |
| 2591 | 2572 | ||
| 2592 | mydbg | 2573 | mydbg |
| 2593 | ("%s serial->product = = 0x%x, serqt_422_table[counts] = 0x%x\n", | 2574 | ("%s serial->product = = 0x%x, serqt_422_table[counts] = 0x%x\n", |
| 2594 | __FUNCTION__, serial->product, | 2575 | __func__, serial->product, |
| 2595 | serqt_422_table[counts]); | 2576 | serqt_422_table[counts]); |
| 2596 | if (serial->product == serqt_422_table[counts]) { | 2577 | if (serial->product == serqt_422_table[counts]) { |
| 2597 | err = 0; | 2578 | err = 0; |
| 2598 | 2579 | ||
| 2599 | mydbg | 2580 | mydbg |
| 2600 | ("%s found match for 422extended\n", | 2581 | ("%s found match for 422extended\n", |
| 2601 | __FUNCTION__); | 2582 | __func__); |
| 2602 | break; | 2583 | break; |
| 2603 | } | 2584 | } |
| 2604 | } | 2585 | } |
| @@ -2607,10 +2588,9 @@ int ioctl_serial_usb(struct inode *innod, struct file *filp, unsigned int cmd, | |||
| 2607 | 2588 | ||
| 2608 | default: | 2589 | default: |
| 2609 | err = -ENOTTY; | 2590 | err = -ENOTTY; |
| 2591 | } | ||
| 2610 | 2592 | ||
| 2611 | } //End switch | 2593 | mydbg("%s returning err = 0x%x\n", __func__, err); |
| 2612 | |||
| 2613 | mydbg("%s returning err = 0x%x\n", __FUNCTION__, err); | ||
| 2614 | return err; | 2594 | return err; |
| 2615 | } | 2595 | } |
| 2616 | 2596 | ||
| @@ -2624,33 +2604,32 @@ static struct usb_serial *find_the_box(unsigned int index) | |||
| 2624 | serial = serial_table[index2]; | 2604 | serial = serial_table[index2]; |
| 2625 | 2605 | ||
| 2626 | mydbg("%s index = 0x%x, index2 = 0x%x, serial = 0x%p\n", | 2606 | mydbg("%s index = 0x%x, index2 = 0x%x, serial = 0x%p\n", |
| 2627 | __FUNCTION__, index, index2, serial); | 2607 | __func__, index, index2, serial); |
| 2628 | 2608 | ||
| 2629 | if (serial) { | 2609 | if (serial) { |
| 2630 | //first see if this is the unit we'er looking for | 2610 | /* first see if this is the unit we'er looking for */ |
| 2631 | mydbg | 2611 | mydbg |
| 2632 | ("%s inside if(serial) counts = 0x%x , index = 0x%x\n", | 2612 | ("%s inside if(serial) counts = 0x%x , index = 0x%x\n", |
| 2633 | __FUNCTION__, counts, index); | 2613 | __func__, counts, index); |
| 2634 | if (counts == index) { | 2614 | if (counts == index) { |
| 2635 | //we found the one we're looking for, copythe product Id to user | 2615 | /* we found the one we're looking for, copythe |
| 2636 | 2616 | * product Id to user */ | |
| 2637 | mydbg | 2617 | mydbg("%s we found the one we're looking for serial = 0x%p\n", |
| 2638 | ("%s we found the one we're looking for serial = 0x%p\n", | 2618 | __func__, serial); |
| 2639 | __FUNCTION__, serial); | ||
| 2640 | foundserial = serial; | 2619 | foundserial = serial; |
| 2641 | break; | 2620 | break; |
| 2642 | } | 2621 | } |
| 2643 | 2622 | ||
| 2644 | if (serial != lastserial) { | 2623 | if (serial != lastserial) { |
| 2645 | //when we have a change in the pointer | 2624 | /* when we have a change in the pointer */ |
| 2646 | lastserial = serial; | 2625 | lastserial = serial; |
| 2647 | counts++; | 2626 | counts++; |
| 2648 | } | 2627 | } |
| 2649 | } else | 2628 | } else |
| 2650 | break; // no matches | 2629 | break; /* no matches */ |
| 2651 | } | 2630 | } |
| 2652 | 2631 | ||
| 2653 | mydbg("%s returning foundserial = 0x%p\n", __FUNCTION__, foundserial); | 2632 | mydbg("%s returning foundserial = 0x%p\n", __func__, foundserial); |
| 2654 | return foundserial; | 2633 | return foundserial; |
| 2655 | } | 2634 | } |
| 2656 | 2635 | ||
| @@ -2662,12 +2641,12 @@ static int EmulateWriteQMCR_Reg(int index, unsigned uc_value) | |||
| 2662 | int status; | 2641 | int status; |
| 2663 | struct qt_get_device_data DeviceData; | 2642 | struct qt_get_device_data DeviceData; |
| 2664 | unsigned uc_temp = 0; | 2643 | unsigned uc_temp = 0; |
| 2665 | mydbg("Inside %s, uc_value = 0x%x\n", __FUNCTION__, uc_value); | 2644 | mydbg("Inside %s, uc_value = 0x%x\n", __func__, uc_value); |
| 2666 | 2645 | ||
| 2667 | DeviceData.porta = 0; | 2646 | DeviceData.porta = 0; |
| 2668 | DeviceData.portb = 0; | 2647 | DeviceData.portb = 0; |
| 2669 | serial = find_the_box(index); | 2648 | serial = find_the_box(index); |
| 2670 | //Determine Duplex mode | 2649 | /* Determine Duplex mode */ |
| 2671 | if (!(serial)) | 2650 | if (!(serial)) |
| 2672 | return -ENOTTY; | 2651 | return -ENOTTY; |
| 2673 | status = box_get_device(serial, &DeviceData); | 2652 | status = box_get_device(serial, &DeviceData); |
| @@ -2700,11 +2679,11 @@ static int EmulateWriteQMCR_Reg(int index, unsigned uc_value) | |||
| 2700 | uc_temp = uc_value & QMCR_CONNECTOR_MASK; | 2679 | uc_temp = uc_value & QMCR_CONNECTOR_MASK; |
| 2701 | switch (uc_temp) { | 2680 | switch (uc_temp) { |
| 2702 | case QMCR_MODEM_CONTROL: | 2681 | case QMCR_MODEM_CONTROL: |
| 2703 | DeviceData.portb &= ~LOOPMODE_BITS; //reset connection bits | 2682 | DeviceData.portb &= ~LOOPMODE_BITS; /* reset connection bits */ |
| 2704 | DeviceData.portb |= MODEM_CTRL; | 2683 | DeviceData.portb |= MODEM_CTRL; |
| 2705 | break; | 2684 | break; |
| 2706 | case QMCR_ALL_LOOPBACK: | 2685 | case QMCR_ALL_LOOPBACK: |
| 2707 | DeviceData.portb &= ~LOOPMODE_BITS; //reset connection bits | 2686 | DeviceData.portb &= ~LOOPMODE_BITS; /* reset connection bits */ |
| 2708 | DeviceData.portb |= ALL_LOOPBACK; | 2687 | DeviceData.portb |= ALL_LOOPBACK; |
| 2709 | break; | 2688 | break; |
| 2710 | } | 2689 | } |
| @@ -2716,8 +2695,9 @@ static int EmulateWriteQMCR_Reg(int index, unsigned uc_value) | |||
| 2716 | return status; | 2695 | return status; |
| 2717 | } | 2696 | } |
| 2718 | 2697 | ||
| 2719 | if (uc_value & QMCR_RX_EN_MASK) //This bit (otherwise unused) i'll used to detect whether ATC is selected | 2698 | /* This bit (otherwise unused) i'll used to detect whether ATC is |
| 2720 | { | 2699 | * selected */ |
| 2700 | if (uc_value & QMCR_RX_EN_MASK) { | ||
| 2721 | 2701 | ||
| 2722 | mydbg(__FILE__ | 2702 | mydbg(__FILE__ |
| 2723 | "calling BoxsetATC with DeviceData.porta = 0x%x and DeviceData.portb = 0x%x\n", | 2703 | "calling BoxsetATC with DeviceData.porta = 0x%x and DeviceData.portb = 0x%x\n", |
| @@ -2776,7 +2756,8 @@ static int EmulateReadQMCR_Reg(int index, unsigned *uc_value) | |||
| 2776 | break; | 2756 | break; |
| 2777 | } | 2757 | } |
| 2778 | 2758 | ||
| 2779 | uc_temp = DeviceData.portb & LOOPMODE_BITS; //I use this for ATC control se | 2759 | /* I use this for ATC control se */ |
| 2760 | uc_temp = DeviceData.portb & LOOPMODE_BITS; | ||
| 2780 | 2761 | ||
| 2781 | switch (uc_temp) { | 2762 | switch (uc_temp) { |
| 2782 | case ALL_LOOPBACK: | 2763 | case ALL_LOOPBACK: |
| @@ -2798,7 +2779,7 @@ static int __init serqt_usb_init(void) | |||
| 2798 | int i, result; | 2779 | int i, result; |
| 2799 | int status = 0; | 2780 | int status = 0; |
| 2800 | 2781 | ||
| 2801 | mydbg("%s\n", __FUNCTION__); | 2782 | mydbg("%s\n", __func__); |
| 2802 | tty_set_operations(&serial_tty_driver, &serial_ops); | 2783 | tty_set_operations(&serial_tty_driver, &serial_ops); |
| 2803 | result = tty_register_driver(&serial_tty_driver); | 2784 | result = tty_register_driver(&serial_tty_driver); |
| 2804 | if (result) { | 2785 | if (result) { |
| @@ -2817,7 +2798,7 @@ static int __init serqt_usb_init(void) | |||
| 2817 | " driver. Error number %d", result); | 2798 | " driver. Error number %d", result); |
| 2818 | return result; | 2799 | return result; |
| 2819 | } | 2800 | } |
| 2820 | status = 0; // Dynamic assignment of major number | 2801 | status = 0; /* Dynamic assignment of major number */ |
| 2821 | major_number = | 2802 | major_number = |
| 2822 | register_chrdev(status, "SerialQT_USB", &serialqt_usb_fops); | 2803 | register_chrdev(status, "SerialQT_USB", &serialqt_usb_fops); |
| 2823 | if (major_number < 0) { | 2804 | if (major_number < 0) { |
