diff options
Diffstat (limited to 'drivers/usb/serial/option.c')
-rw-r--r-- | drivers/usb/serial/option.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 7817b82889ca..a16d69fadba1 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -45,8 +45,9 @@ | |||
45 | /* Function prototypes */ | 45 | /* Function prototypes */ |
46 | static int option_open(struct tty_struct *tty, struct usb_serial_port *port, | 46 | static int option_open(struct tty_struct *tty, struct usb_serial_port *port, |
47 | struct file *filp); | 47 | struct file *filp); |
48 | static void option_close(struct tty_struct *tty, struct usb_serial_port *port, | 48 | static void option_close(struct usb_serial_port *port); |
49 | struct file *filp); | 49 | static void option_dtr_rts(struct usb_serial_port *port, int on); |
50 | |||
50 | static int option_startup(struct usb_serial *serial); | 51 | static int option_startup(struct usb_serial *serial); |
51 | static void option_shutdown(struct usb_serial *serial); | 52 | static void option_shutdown(struct usb_serial *serial); |
52 | static int option_write_room(struct tty_struct *tty); | 53 | static int option_write_room(struct tty_struct *tty); |
@@ -61,7 +62,7 @@ static void option_set_termios(struct tty_struct *tty, | |||
61 | static int option_tiocmget(struct tty_struct *tty, struct file *file); | 62 | static int option_tiocmget(struct tty_struct *tty, struct file *file); |
62 | static int option_tiocmset(struct tty_struct *tty, struct file *file, | 63 | static int option_tiocmset(struct tty_struct *tty, struct file *file, |
63 | unsigned int set, unsigned int clear); | 64 | unsigned int set, unsigned int clear); |
64 | static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *port); | 65 | static int option_send_setup(struct usb_serial_port *port); |
65 | static int option_suspend(struct usb_serial *serial, pm_message_t message); | 66 | static int option_suspend(struct usb_serial *serial, pm_message_t message); |
66 | static int option_resume(struct usb_serial *serial); | 67 | static int option_resume(struct usb_serial *serial); |
67 | 68 | ||
@@ -551,6 +552,7 @@ static struct usb_serial_driver option_1port_device = { | |||
551 | .num_ports = 1, | 552 | .num_ports = 1, |
552 | .open = option_open, | 553 | .open = option_open, |
553 | .close = option_close, | 554 | .close = option_close, |
555 | .dtr_rts = option_dtr_rts, | ||
554 | .write = option_write, | 556 | .write = option_write, |
555 | .write_room = option_write_room, | 557 | .write_room = option_write_room, |
556 | .chars_in_buffer = option_chars_in_buffer, | 558 | .chars_in_buffer = option_chars_in_buffer, |
@@ -630,7 +632,7 @@ static void option_set_termios(struct tty_struct *tty, | |||
630 | dbg("%s", __func__); | 632 | dbg("%s", __func__); |
631 | /* Doesn't support option setting */ | 633 | /* Doesn't support option setting */ |
632 | tty_termios_copy_hw(tty->termios, old_termios); | 634 | tty_termios_copy_hw(tty->termios, old_termios); |
633 | option_send_setup(tty, port); | 635 | option_send_setup(port); |
634 | } | 636 | } |
635 | 637 | ||
636 | static int option_tiocmget(struct tty_struct *tty, struct file *file) | 638 | static int option_tiocmget(struct tty_struct *tty, struct file *file) |
@@ -669,7 +671,7 @@ static int option_tiocmset(struct tty_struct *tty, struct file *file, | |||
669 | portdata->rts_state = 0; | 671 | portdata->rts_state = 0; |
670 | if (clear & TIOCM_DTR) | 672 | if (clear & TIOCM_DTR) |
671 | portdata->dtr_state = 0; | 673 | portdata->dtr_state = 0; |
672 | return option_send_setup(tty, port); | 674 | return option_send_setup(port); |
673 | } | 675 | } |
674 | 676 | ||
675 | /* Write */ | 677 | /* Write */ |
@@ -897,10 +899,6 @@ static int option_open(struct tty_struct *tty, | |||
897 | 899 | ||
898 | dbg("%s", __func__); | 900 | dbg("%s", __func__); |
899 | 901 | ||
900 | /* Set some sane defaults */ | ||
901 | portdata->rts_state = 1; | ||
902 | portdata->dtr_state = 1; | ||
903 | |||
904 | /* Reset low level data toggle and start reading from endpoints */ | 902 | /* Reset low level data toggle and start reading from endpoints */ |
905 | for (i = 0; i < N_IN_URB; i++) { | 903 | for (i = 0; i < N_IN_URB; i++) { |
906 | urb = portdata->in_urbs[i]; | 904 | urb = portdata->in_urbs[i]; |
@@ -936,37 +934,43 @@ static int option_open(struct tty_struct *tty, | |||
936 | usb_pipeout(urb->pipe), 0); */ | 934 | usb_pipeout(urb->pipe), 0); */ |
937 | } | 935 | } |
938 | 936 | ||
939 | option_send_setup(tty, port); | 937 | option_send_setup(port); |
940 | 938 | ||
941 | return 0; | 939 | return 0; |
942 | } | 940 | } |
943 | 941 | ||
944 | static void option_close(struct tty_struct *tty, | 942 | static void option_dtr_rts(struct usb_serial_port *port, int on) |
945 | struct usb_serial_port *port, struct file *filp) | ||
946 | { | 943 | { |
947 | int i; | ||
948 | struct usb_serial *serial = port->serial; | 944 | struct usb_serial *serial = port->serial; |
949 | struct option_port_private *portdata; | 945 | struct option_port_private *portdata; |
950 | 946 | ||
951 | dbg("%s", __func__); | 947 | dbg("%s", __func__); |
952 | portdata = usb_get_serial_port_data(port); | 948 | portdata = usb_get_serial_port_data(port); |
949 | mutex_lock(&serial->disc_mutex); | ||
950 | portdata->rts_state = on; | ||
951 | portdata->dtr_state = on; | ||
952 | if (serial->dev) | ||
953 | option_send_setup(port); | ||
954 | mutex_unlock(&serial->disc_mutex); | ||
955 | } | ||
953 | 956 | ||
954 | portdata->rts_state = 0; | ||
955 | portdata->dtr_state = 0; | ||
956 | 957 | ||
957 | if (serial->dev) { | 958 | static void option_close(struct usb_serial_port *port) |
958 | mutex_lock(&serial->disc_mutex); | 959 | { |
959 | if (!serial->disconnected) | 960 | int i; |
960 | option_send_setup(tty, port); | 961 | struct usb_serial *serial = port->serial; |
961 | mutex_unlock(&serial->disc_mutex); | 962 | struct option_port_private *portdata; |
963 | |||
964 | dbg("%s", __func__); | ||
965 | portdata = usb_get_serial_port_data(port); | ||
962 | 966 | ||
967 | if (serial->dev) { | ||
963 | /* Stop reading/writing urbs */ | 968 | /* Stop reading/writing urbs */ |
964 | for (i = 0; i < N_IN_URB; i++) | 969 | for (i = 0; i < N_IN_URB; i++) |
965 | usb_kill_urb(portdata->in_urbs[i]); | 970 | usb_kill_urb(portdata->in_urbs[i]); |
966 | for (i = 0; i < N_OUT_URB; i++) | 971 | for (i = 0; i < N_OUT_URB; i++) |
967 | usb_kill_urb(portdata->out_urbs[i]); | 972 | usb_kill_urb(portdata->out_urbs[i]); |
968 | } | 973 | } |
969 | tty_port_tty_set(&port->port, NULL); | ||
970 | } | 974 | } |
971 | 975 | ||
972 | /* Helper functions used by option_setup_urbs */ | 976 | /* Helper functions used by option_setup_urbs */ |
@@ -1032,28 +1036,24 @@ static void option_setup_urbs(struct usb_serial *serial) | |||
1032 | * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN | 1036 | * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN |
1033 | * CDC. | 1037 | * CDC. |
1034 | */ | 1038 | */ |
1035 | static int option_send_setup(struct tty_struct *tty, | 1039 | static int option_send_setup(struct usb_serial_port *port) |
1036 | struct usb_serial_port *port) | ||
1037 | { | 1040 | { |
1038 | struct usb_serial *serial = port->serial; | 1041 | struct usb_serial *serial = port->serial; |
1039 | struct option_port_private *portdata; | 1042 | struct option_port_private *portdata; |
1040 | int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber; | 1043 | int ifNum = serial->interface->cur_altsetting->desc.bInterfaceNumber; |
1044 | int val = 0; | ||
1041 | dbg("%s", __func__); | 1045 | dbg("%s", __func__); |
1042 | 1046 | ||
1043 | portdata = usb_get_serial_port_data(port); | 1047 | portdata = usb_get_serial_port_data(port); |
1044 | 1048 | ||
1045 | if (tty) { | 1049 | if (portdata->dtr_state) |
1046 | int val = 0; | 1050 | val |= 0x01; |
1047 | if (portdata->dtr_state) | 1051 | if (portdata->rts_state) |
1048 | val |= 0x01; | 1052 | val |= 0x02; |
1049 | if (portdata->rts_state) | ||
1050 | val |= 0x02; | ||
1051 | 1053 | ||
1052 | return usb_control_msg(serial->dev, | 1054 | return usb_control_msg(serial->dev, |
1053 | usb_rcvctrlpipe(serial->dev, 0), | 1055 | usb_rcvctrlpipe(serial->dev, 0), |
1054 | 0x22, 0x21, val, ifNum, NULL, 0, USB_CTRL_SET_TIMEOUT); | 1056 | 0x22, 0x21, val, ifNum, NULL, 0, USB_CTRL_SET_TIMEOUT); |
1055 | } | ||
1056 | return 0; | ||
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | static int option_startup(struct usb_serial *serial) | 1059 | static int option_startup(struct usb_serial *serial) |