diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 06:09:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:22 -0400 |
commit | 95da310e66ee8090119596c70ca8432e57f9a97f (patch) | |
tree | 7f18c30e9c9ad4d7d53df6453fa338be06f09a85 /drivers/usb/serial/ftdi_sio.c | |
parent | 1aa3692da57c773e5c76de55c5c4a953962d360e (diff) |
usb_serial: API all change
USB serial likes to use port->tty back pointers for the real work it does and
to do so without any actual locking. Unfortunately when you consider hangup
events, hangup/parallel reopen or even worse hangup followed by parallel close
events the tty->port and port->tty pointers are not guaranteed to be the same
as port->tty is the active tty while tty->port is the port the tty may or
may not still be attached to.
So rework the entire API to pass the tty struct. For console cases we need
to pass both for now. This shows up multiple drivers that immediately crash
with USB console some of which have been fixed in the process.
Longer term we need a proper tty as console abstraction
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial/ftdi_sio.c')
-rw-r--r-- | drivers/usb/serial/ftdi_sio.c | 211 |
1 files changed, 105 insertions, 106 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 0ff4a3971e45..abbb447e5375 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -682,21 +682,21 @@ static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_i | |||
682 | static void ftdi_shutdown (struct usb_serial *serial); | 682 | static void ftdi_shutdown (struct usb_serial *serial); |
683 | static int ftdi_sio_port_probe (struct usb_serial_port *port); | 683 | static int ftdi_sio_port_probe (struct usb_serial_port *port); |
684 | static int ftdi_sio_port_remove (struct usb_serial_port *port); | 684 | static int ftdi_sio_port_remove (struct usb_serial_port *port); |
685 | static int ftdi_open (struct usb_serial_port *port, struct file *filp); | 685 | static int ftdi_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); |
686 | static void ftdi_close (struct usb_serial_port *port, struct file *filp); | 686 | static void ftdi_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); |
687 | static int ftdi_write (struct usb_serial_port *port, const unsigned char *buf, int count); | 687 | static int ftdi_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); |
688 | static int ftdi_write_room (struct usb_serial_port *port); | 688 | static int ftdi_write_room (struct tty_struct *tty); |
689 | static int ftdi_chars_in_buffer (struct usb_serial_port *port); | 689 | static int ftdi_chars_in_buffer (struct tty_struct *tty); |
690 | static void ftdi_write_bulk_callback (struct urb *urb); | 690 | static void ftdi_write_bulk_callback (struct urb *urb); |
691 | static void ftdi_read_bulk_callback (struct urb *urb); | 691 | static void ftdi_read_bulk_callback (struct urb *urb); |
692 | static void ftdi_process_read (struct work_struct *work); | 692 | static void ftdi_process_read (struct work_struct *work); |
693 | static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios * old); | 693 | static void ftdi_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); |
694 | static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file); | 694 | static int ftdi_tiocmget (struct tty_struct *tty, struct file *file); |
695 | static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear); | 695 | static int ftdi_tiocmset (struct tty_struct *tty, struct file * file, unsigned int set, unsigned int clear); |
696 | static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); | 696 | static int ftdi_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); |
697 | static void ftdi_break_ctl (struct usb_serial_port *port, int break_state ); | 697 | static void ftdi_break_ctl (struct tty_struct *tty, int break_state ); |
698 | static void ftdi_throttle (struct usb_serial_port *port); | 698 | static void ftdi_throttle (struct tty_struct *tty); |
699 | static void ftdi_unthrottle (struct usb_serial_port *port); | 699 | static void ftdi_unthrottle (struct tty_struct *tty); |
700 | 700 | ||
701 | static unsigned short int ftdi_232am_baud_base_to_divisor (int baud, int base); | 701 | static unsigned short int ftdi_232am_baud_base_to_divisor (int baud, int base); |
702 | static unsigned short int ftdi_232am_baud_to_divisor (int baud); | 702 | static unsigned short int ftdi_232am_baud_to_divisor (int baud); |
@@ -843,42 +843,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned | |||
843 | } | 843 | } |
844 | 844 | ||
845 | 845 | ||
846 | static __u32 get_ftdi_divisor(struct usb_serial_port * port); | 846 | static __u32 get_ftdi_divisor(struct tty_struct *tty, struct usb_serial_port *port) |
847 | |||
848 | |||
849 | static int change_speed(struct usb_serial_port *port) | ||
850 | { | ||
851 | struct ftdi_private *priv = usb_get_serial_port_data(port); | ||
852 | char *buf; | ||
853 | __u16 urb_value; | ||
854 | __u16 urb_index; | ||
855 | __u32 urb_index_value; | ||
856 | int rv; | ||
857 | |||
858 | buf = kmalloc(1, GFP_NOIO); | ||
859 | if (!buf) | ||
860 | return -ENOMEM; | ||
861 | |||
862 | urb_index_value = get_ftdi_divisor(port); | ||
863 | urb_value = (__u16)urb_index_value; | ||
864 | urb_index = (__u16)(urb_index_value >> 16); | ||
865 | if (priv->interface) { /* FT2232C */ | ||
866 | urb_index = (__u16)((urb_index << 8) | priv->interface); | ||
867 | } | ||
868 | |||
869 | rv = usb_control_msg(port->serial->dev, | ||
870 | usb_sndctrlpipe(port->serial->dev, 0), | ||
871 | FTDI_SIO_SET_BAUDRATE_REQUEST, | ||
872 | FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, | ||
873 | urb_value, urb_index, | ||
874 | buf, 0, WDR_SHORT_TIMEOUT); | ||
875 | |||
876 | kfree(buf); | ||
877 | return rv; | ||
878 | } | ||
879 | |||
880 | |||
881 | static __u32 get_ftdi_divisor(struct usb_serial_port * port) | ||
882 | { /* get_ftdi_divisor */ | 847 | { /* get_ftdi_divisor */ |
883 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 848 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
884 | __u32 div_value = 0; | 849 | __u32 div_value = 0; |
@@ -910,7 +875,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
910 | 875 | ||
911 | /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */ | 876 | /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */ |
912 | 877 | ||
913 | baud = tty_get_baud_rate(port->tty); | 878 | baud = tty_get_baud_rate(tty); |
914 | dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud); | 879 | dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud); |
915 | 880 | ||
916 | /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */ | 881 | /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */ |
@@ -976,10 +941,42 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
976 | ftdi_chip_name[priv->chip_type]); | 941 | ftdi_chip_name[priv->chip_type]); |
977 | } | 942 | } |
978 | 943 | ||
979 | tty_encode_baud_rate(port->tty, baud, baud); | 944 | tty_encode_baud_rate(tty, baud, baud); |
980 | return(div_value); | 945 | return(div_value); |
981 | } | 946 | } |
982 | 947 | ||
948 | static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) | ||
949 | { | ||
950 | struct ftdi_private *priv = usb_get_serial_port_data(port); | ||
951 | char *buf; | ||
952 | __u16 urb_value; | ||
953 | __u16 urb_index; | ||
954 | __u32 urb_index_value; | ||
955 | int rv; | ||
956 | |||
957 | buf = kmalloc(1, GFP_NOIO); | ||
958 | if (!buf) | ||
959 | return -ENOMEM; | ||
960 | |||
961 | urb_index_value = get_ftdi_divisor(tty, port); | ||
962 | urb_value = (__u16)urb_index_value; | ||
963 | urb_index = (__u16)(urb_index_value >> 16); | ||
964 | if (priv->interface) { /* FT2232C */ | ||
965 | urb_index = (__u16)((urb_index << 8) | priv->interface); | ||
966 | } | ||
967 | |||
968 | rv = usb_control_msg(port->serial->dev, | ||
969 | usb_sndctrlpipe(port->serial->dev, 0), | ||
970 | FTDI_SIO_SET_BAUDRATE_REQUEST, | ||
971 | FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, | ||
972 | urb_value, urb_index, | ||
973 | buf, 0, WDR_SHORT_TIMEOUT); | ||
974 | |||
975 | kfree(buf); | ||
976 | return rv; | ||
977 | } | ||
978 | |||
979 | |||
983 | 980 | ||
984 | static int get_serial_info(struct usb_serial_port * port, struct serial_struct __user * retinfo) | 981 | static int get_serial_info(struct usb_serial_port * port, struct serial_struct __user * retinfo) |
985 | { | 982 | { |
@@ -998,7 +995,8 @@ static int get_serial_info(struct usb_serial_port * port, struct serial_struct _ | |||
998 | } /* get_serial_info */ | 995 | } /* get_serial_info */ |
999 | 996 | ||
1000 | 997 | ||
1001 | static int set_serial_info(struct usb_serial_port * port, struct serial_struct __user * newinfo) | 998 | static int set_serial_info(struct tty_struct *tty, |
999 | struct usb_serial_port * port, struct serial_struct __user * newinfo) | ||
1002 | { /* set_serial_info */ | 1000 | { /* set_serial_info */ |
1003 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1001 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
1004 | struct serial_struct new_serial; | 1002 | struct serial_struct new_serial; |
@@ -1030,30 +1028,29 @@ static int set_serial_info(struct usb_serial_port * port, struct serial_struct _ | |||
1030 | (new_serial.flags & ASYNC_FLAGS)); | 1028 | (new_serial.flags & ASYNC_FLAGS)); |
1031 | priv->custom_divisor = new_serial.custom_divisor; | 1029 | priv->custom_divisor = new_serial.custom_divisor; |
1032 | 1030 | ||
1033 | port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; | 1031 | tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; |
1034 | 1032 | ||
1035 | check_and_exit: | 1033 | check_and_exit: |
1036 | if ((old_priv.flags & ASYNC_SPD_MASK) != | 1034 | if ((old_priv.flags & ASYNC_SPD_MASK) != |
1037 | (priv->flags & ASYNC_SPD_MASK)) { | 1035 | (priv->flags & ASYNC_SPD_MASK)) { |
1038 | if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) | 1036 | if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) |
1039 | port->tty->alt_speed = 57600; | 1037 | tty->alt_speed = 57600; |
1040 | else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) | 1038 | else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) |
1041 | port->tty->alt_speed = 115200; | 1039 | tty->alt_speed = 115200; |
1042 | else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) | 1040 | else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) |
1043 | port->tty->alt_speed = 230400; | 1041 | tty->alt_speed = 230400; |
1044 | else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) | 1042 | else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) |
1045 | port->tty->alt_speed = 460800; | 1043 | tty->alt_speed = 460800; |
1046 | else | 1044 | else |
1047 | port->tty->alt_speed = 0; | 1045 | tty->alt_speed = 0; |
1048 | } | 1046 | } |
1049 | if (((old_priv.flags & ASYNC_SPD_MASK) != | 1047 | if (((old_priv.flags & ASYNC_SPD_MASK) != |
1050 | (priv->flags & ASYNC_SPD_MASK)) || | 1048 | (priv->flags & ASYNC_SPD_MASK)) || |
1051 | (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && | 1049 | (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && |
1052 | (old_priv.custom_divisor != priv->custom_divisor))) { | 1050 | (old_priv.custom_divisor != priv->custom_divisor))) { |
1053 | change_speed(port); | 1051 | change_speed(tty, port); |
1054 | } | 1052 | } |
1055 | 1053 | return 0; | |
1056 | return (0); | ||
1057 | 1054 | ||
1058 | } /* set_serial_info */ | 1055 | } /* set_serial_info */ |
1059 | 1056 | ||
@@ -1415,7 +1412,8 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port) | |||
1415 | return 0; | 1412 | return 0; |
1416 | } | 1413 | } |
1417 | 1414 | ||
1418 | static int ftdi_open (struct usb_serial_port *port, struct file *filp) | 1415 | static int ftdi_open(struct tty_struct *tty, |
1416 | struct usb_serial_port *port, struct file *filp) | ||
1419 | { /* ftdi_open */ | 1417 | { /* ftdi_open */ |
1420 | struct usb_device *dev = port->serial->dev; | 1418 | struct usb_device *dev = port->serial->dev; |
1421 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1419 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
@@ -1433,8 +1431,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) | |||
1433 | priv->rx_bytes = 0; | 1431 | priv->rx_bytes = 0; |
1434 | spin_unlock_irqrestore(&priv->rx_lock, flags); | 1432 | spin_unlock_irqrestore(&priv->rx_lock, flags); |
1435 | 1433 | ||
1436 | if (port->tty) | 1434 | if (tty) |
1437 | port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; | 1435 | tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; |
1438 | 1436 | ||
1439 | /* No error checking for this (will get errors later anyway) */ | 1437 | /* No error checking for this (will get errors later anyway) */ |
1440 | /* See ftdi_sio.h for description of what is reset */ | 1438 | /* See ftdi_sio.h for description of what is reset */ |
@@ -1448,8 +1446,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) | |||
1448 | This is same behaviour as serial.c/rs_open() - Kuba */ | 1446 | This is same behaviour as serial.c/rs_open() - Kuba */ |
1449 | 1447 | ||
1450 | /* ftdi_set_termios will send usb control messages */ | 1448 | /* ftdi_set_termios will send usb control messages */ |
1451 | if (port->tty) | 1449 | if (tty) |
1452 | ftdi_set_termios(port, port->tty->termios); | 1450 | ftdi_set_termios(tty, port, tty->termios); |
1453 | 1451 | ||
1454 | /* FIXME: Flow control might be enabled, so it should be checked - | 1452 | /* FIXME: Flow control might be enabled, so it should be checked - |
1455 | we have no control of defaults! */ | 1453 | we have no control of defaults! */ |
@@ -1485,9 +1483,10 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) | |||
1485 | * | 1483 | * |
1486 | */ | 1484 | */ |
1487 | 1485 | ||
1488 | static void ftdi_close (struct usb_serial_port *port, struct file *filp) | 1486 | static void ftdi_close(struct tty_struct *tty, |
1487 | struct usb_serial_port *port, struct file *filp) | ||
1489 | { /* ftdi_close */ | 1488 | { /* ftdi_close */ |
1490 | unsigned int c_cflag = port->tty->termios->c_cflag; | 1489 | unsigned int c_cflag = tty->termios->c_cflag; |
1491 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1490 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
1492 | char buf[1]; | 1491 | char buf[1]; |
1493 | 1492 | ||
@@ -1527,7 +1526,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp) | |||
1527 | * | 1526 | * |
1528 | * The new devices do not require this byte | 1527 | * The new devices do not require this byte |
1529 | */ | 1528 | */ |
1530 | static int ftdi_write (struct usb_serial_port *port, | 1529 | static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port, |
1531 | const unsigned char *buf, int count) | 1530 | const unsigned char *buf, int count) |
1532 | { /* ftdi_write */ | 1531 | { /* ftdi_write */ |
1533 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1532 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
@@ -1686,8 +1685,9 @@ static void ftdi_write_bulk_callback (struct urb *urb) | |||
1686 | } /* ftdi_write_bulk_callback */ | 1685 | } /* ftdi_write_bulk_callback */ |
1687 | 1686 | ||
1688 | 1687 | ||
1689 | static int ftdi_write_room( struct usb_serial_port *port ) | 1688 | static int ftdi_write_room(struct tty_struct *tty) |
1690 | { | 1689 | { |
1690 | struct usb_serial_port *port = tty->driver_data; | ||
1691 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1691 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
1692 | int room; | 1692 | int room; |
1693 | unsigned long flags; | 1693 | unsigned long flags; |
@@ -1707,11 +1707,11 @@ static int ftdi_write_room( struct usb_serial_port *port ) | |||
1707 | } | 1707 | } |
1708 | spin_unlock_irqrestore(&priv->tx_lock, flags); | 1708 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
1709 | return room; | 1709 | return room; |
1710 | } /* ftdi_write_room */ | 1710 | } |
1711 | |||
1712 | 1711 | ||
1713 | static int ftdi_chars_in_buffer (struct usb_serial_port *port) | 1712 | static int ftdi_chars_in_buffer(struct tty_struct *tty) |
1714 | { /* ftdi_chars_in_buffer */ | 1713 | { |
1714 | struct usb_serial_port *port = tty->driver_data; | ||
1715 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1715 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
1716 | int buffered; | 1716 | int buffered; |
1717 | unsigned long flags; | 1717 | unsigned long flags; |
@@ -1726,12 +1726,10 @@ static int ftdi_chars_in_buffer (struct usb_serial_port *port) | |||
1726 | buffered = 0; | 1726 | buffered = 0; |
1727 | } | 1727 | } |
1728 | return buffered; | 1728 | return buffered; |
1729 | } /* ftdi_chars_in_buffer */ | 1729 | } |
1730 | |||
1731 | |||
1732 | 1730 | ||
1733 | static void ftdi_read_bulk_callback (struct urb *urb) | 1731 | static void ftdi_read_bulk_callback(struct urb *urb) |
1734 | { /* ftdi_read_bulk_callback */ | 1732 | { |
1735 | struct usb_serial_port *port = urb->context; | 1733 | struct usb_serial_port *port = urb->context; |
1736 | struct tty_struct *tty; | 1734 | struct tty_struct *tty; |
1737 | struct ftdi_private *priv; | 1735 | struct ftdi_private *priv; |
@@ -1747,10 +1745,10 @@ static void ftdi_read_bulk_callback (struct urb *urb) | |||
1747 | 1745 | ||
1748 | dbg("%s - port %d", __func__, port->number); | 1746 | dbg("%s - port %d", __func__, port->number); |
1749 | 1747 | ||
1750 | if (port->open_count <= 0) | 1748 | if (port->port.count <= 0) |
1751 | return; | 1749 | return; |
1752 | 1750 | ||
1753 | tty = port->tty; | 1751 | tty = port->port.tty; |
1754 | if (!tty) { | 1752 | if (!tty) { |
1755 | dbg("%s - bad tty pointer - exiting",__func__); | 1753 | dbg("%s - bad tty pointer - exiting",__func__); |
1756 | return; | 1754 | return; |
@@ -1803,10 +1801,10 @@ static void ftdi_process_read (struct work_struct *work) | |||
1803 | 1801 | ||
1804 | dbg("%s - port %d", __func__, port->number); | 1802 | dbg("%s - port %d", __func__, port->number); |
1805 | 1803 | ||
1806 | if (port->open_count <= 0) | 1804 | if (port->port.count <= 0) |
1807 | return; | 1805 | return; |
1808 | 1806 | ||
1809 | tty = port->tty; | 1807 | tty = port->port.tty; |
1810 | if (!tty) { | 1808 | if (!tty) { |
1811 | dbg("%s - bad tty pointer - exiting",__func__); | 1809 | dbg("%s - bad tty pointer - exiting",__func__); |
1812 | return; | 1810 | return; |
@@ -1954,7 +1952,7 @@ static void ftdi_process_read (struct work_struct *work) | |||
1954 | } | 1952 | } |
1955 | spin_unlock_irqrestore(&priv->rx_lock, flags); | 1953 | spin_unlock_irqrestore(&priv->rx_lock, flags); |
1956 | /* if the port is closed stop trying to read */ | 1954 | /* if the port is closed stop trying to read */ |
1957 | if (port->open_count > 0){ | 1955 | if (port->port.count > 0){ |
1958 | /* delay processing of remainder */ | 1956 | /* delay processing of remainder */ |
1959 | schedule_delayed_work(&priv->rx_work, 1); | 1957 | schedule_delayed_work(&priv->rx_work, 1); |
1960 | } else { | 1958 | } else { |
@@ -1967,7 +1965,7 @@ static void ftdi_process_read (struct work_struct *work) | |||
1967 | priv->rx_processed = 0; | 1965 | priv->rx_processed = 0; |
1968 | 1966 | ||
1969 | /* if the port is closed stop trying to read */ | 1967 | /* if the port is closed stop trying to read */ |
1970 | if (port->open_count > 0){ | 1968 | if (port->port.count > 0){ |
1971 | /* Continue trying to always read */ | 1969 | /* Continue trying to always read */ |
1972 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, | 1970 | usb_fill_bulk_urb(port->read_urb, port->serial->dev, |
1973 | usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), | 1971 | usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), |
@@ -1983,8 +1981,9 @@ static void ftdi_process_read (struct work_struct *work) | |||
1983 | } /* ftdi_process_read */ | 1981 | } /* ftdi_process_read */ |
1984 | 1982 | ||
1985 | 1983 | ||
1986 | static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) | 1984 | static void ftdi_break_ctl(struct tty_struct *tty, int break_state) |
1987 | { | 1985 | { |
1986 | struct usb_serial_port *port = tty->driver_data; | ||
1988 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1987 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
1989 | __u16 urb_value = 0; | 1988 | __u16 urb_value = 0; |
1990 | char buf[1]; | 1989 | char buf[1]; |
@@ -2018,11 +2017,12 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) | |||
2018 | * WARNING: set_termios calls this with old_termios in kernel space | 2017 | * WARNING: set_termios calls this with old_termios in kernel space |
2019 | */ | 2018 | */ |
2020 | 2019 | ||
2021 | static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) | 2020 | static void ftdi_set_termios(struct tty_struct *tty, |
2021 | struct usb_serial_port *port, struct ktermios *old_termios) | ||
2022 | { /* ftdi_termios */ | 2022 | { /* ftdi_termios */ |
2023 | struct usb_device *dev = port->serial->dev; | 2023 | struct usb_device *dev = port->serial->dev; |
2024 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 2024 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
2025 | struct ktermios *termios = port->tty->termios; | 2025 | struct ktermios *termios = tty->termios; |
2026 | unsigned int cflag = termios->c_cflag; | 2026 | unsigned int cflag = termios->c_cflag; |
2027 | __u16 urb_value; /* will hold the new flags */ | 2027 | __u16 urb_value; /* will hold the new flags */ |
2028 | char buf[1]; /* Perhaps I should dynamically alloc this? */ | 2028 | char buf[1]; /* Perhaps I should dynamically alloc this? */ |
@@ -2037,7 +2037,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old | |||
2037 | /* Force baud rate if this device requires it, unless it is set to B0. */ | 2037 | /* Force baud rate if this device requires it, unless it is set to B0. */ |
2038 | if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { | 2038 | if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { |
2039 | dbg("%s: forcing baud rate for this device", __func__); | 2039 | dbg("%s: forcing baud rate for this device", __func__); |
2040 | tty_encode_baud_rate(port->tty, priv->force_baud, | 2040 | tty_encode_baud_rate(tty, priv->force_baud, |
2041 | priv->force_baud); | 2041 | priv->force_baud); |
2042 | } | 2042 | } |
2043 | 2043 | ||
@@ -2104,7 +2104,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old | |||
2104 | clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); | 2104 | clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); |
2105 | } else { | 2105 | } else { |
2106 | /* set the baudrate determined before */ | 2106 | /* set the baudrate determined before */ |
2107 | if (change_speed(port)) { | 2107 | if (change_speed(tty, port)) { |
2108 | err("%s urb failed to set baudrate", __func__); | 2108 | err("%s urb failed to set baudrate", __func__); |
2109 | } | 2109 | } |
2110 | /* Ensure RTS and DTR are raised when baudrate changed from 0 */ | 2110 | /* Ensure RTS and DTR are raised when baudrate changed from 0 */ |
@@ -2168,11 +2168,11 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old | |||
2168 | 2168 | ||
2169 | } | 2169 | } |
2170 | return; | 2170 | return; |
2171 | } /* ftdi_termios */ | 2171 | } |
2172 | |||
2173 | 2172 | ||
2174 | static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) | 2173 | static int ftdi_tiocmget(struct tty_struct *tty, struct file *file) |
2175 | { | 2174 | { |
2175 | struct usb_serial_port *port = tty->driver_data; | ||
2176 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 2176 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
2177 | unsigned char buf[2]; | 2177 | unsigned char buf[2]; |
2178 | int ret; | 2178 | int ret; |
@@ -2221,15 +2221,18 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) | |||
2221 | priv->last_dtr_rts; | 2221 | priv->last_dtr_rts; |
2222 | } | 2222 | } |
2223 | 2223 | ||
2224 | static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear) | 2224 | static int ftdi_tiocmset(struct tty_struct *tty, struct file * file, |
2225 | unsigned int set, unsigned int clear) | ||
2225 | { | 2226 | { |
2227 | struct usb_serial_port *port = tty->driver_data; | ||
2226 | dbg("%s TIOCMSET", __func__); | 2228 | dbg("%s TIOCMSET", __func__); |
2227 | return update_mctrl(port, set, clear); | 2229 | return update_mctrl(port, set, clear); |
2228 | } | 2230 | } |
2229 | 2231 | ||
2230 | 2232 | ||
2231 | static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) | 2233 | static int ftdi_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) |
2232 | { | 2234 | { |
2235 | struct usb_serial_port *port = tty->driver_data; | ||
2233 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 2236 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
2234 | 2237 | ||
2235 | dbg("%s cmd 0x%04x", __func__, cmd); | 2238 | dbg("%s cmd 0x%04x", __func__, cmd); |
@@ -2241,7 +2244,7 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne | |||
2241 | return get_serial_info(port, (struct serial_struct __user *) arg); | 2244 | return get_serial_info(port, (struct serial_struct __user *) arg); |
2242 | 2245 | ||
2243 | case TIOCSSERIAL: /* sets serial port data */ | 2246 | case TIOCSSERIAL: /* sets serial port data */ |
2244 | return set_serial_info(port, (struct serial_struct __user *) arg); | 2247 | return set_serial_info(tty, port, (struct serial_struct __user *) arg); |
2245 | 2248 | ||
2246 | /* | 2249 | /* |
2247 | * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change | 2250 | * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change |
@@ -2280,25 +2283,20 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne | |||
2280 | */ | 2283 | */ |
2281 | } | 2284 | } |
2282 | } | 2285 | } |
2283 | return(0); | 2286 | return 0; |
2284 | break; | ||
2285 | default: | 2287 | default: |
2286 | break; | 2288 | break; |
2287 | |||
2288 | } | 2289 | } |
2289 | |||
2290 | |||
2291 | /* This is not necessarily an error - turns out the higher layers will do | 2290 | /* This is not necessarily an error - turns out the higher layers will do |
2292 | * some ioctls itself (see comment above) | 2291 | * some ioctls itself (see comment above) |
2293 | */ | 2292 | */ |
2294 | dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd); | 2293 | dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd); |
2294 | return -ENOIOCTLCMD; | ||
2295 | } | ||
2295 | 2296 | ||
2296 | return(-ENOIOCTLCMD); | 2297 | static void ftdi_throttle(struct tty_struct *tty) |
2297 | } /* ftdi_ioctl */ | ||
2298 | |||
2299 | |||
2300 | static void ftdi_throttle (struct usb_serial_port *port) | ||
2301 | { | 2298 | { |
2299 | struct usb_serial_port *port = tty->driver_data; | ||
2302 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 2300 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
2303 | unsigned long flags; | 2301 | unsigned long flags; |
2304 | 2302 | ||
@@ -2310,8 +2308,9 @@ static void ftdi_throttle (struct usb_serial_port *port) | |||
2310 | } | 2308 | } |
2311 | 2309 | ||
2312 | 2310 | ||
2313 | static void ftdi_unthrottle (struct usb_serial_port *port) | 2311 | static void ftdi_unthrottle(struct tty_struct *tty) |
2314 | { | 2312 | { |
2313 | struct usb_serial_port *port = tty->driver_data; | ||
2315 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 2314 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
2316 | int actually_throttled; | 2315 | int actually_throttled; |
2317 | unsigned long flags; | 2316 | unsigned long flags; |