| .. | .. |
|---|
| 7 | 7 | * Copyright (C) 2003,2004 |
|---|
| 8 | 8 | * Neil Whelchel (koyama@firstlight.net) |
|---|
| 9 | 9 | * |
|---|
| 10 | | - * See Documentation/usb/usb-serial.txt for more information on using this |
|---|
| 10 | + * See Documentation/usb/usb-serial.rst for more information on using this |
|---|
| 11 | 11 | * driver |
|---|
| 12 | 12 | * |
|---|
| 13 | 13 | * See http://geocities.com/i0xox0i for information on this driver and the |
|---|
| .. | .. |
|---|
| 100 | 100 | int write_urb_interval; /* interval to use for write urb */ |
|---|
| 101 | 101 | int read_urb_interval; /* interval to use for read urb */ |
|---|
| 102 | 102 | int comm_is_ok; /* true if communication is (still) ok */ |
|---|
| 103 | | - int termios_initialized; |
|---|
| 104 | 103 | __u8 line_control; /* holds dtr / rts value */ |
|---|
| 105 | 104 | __u8 current_status; /* received from last read - info on dsr,cts,cd,ri,etc */ |
|---|
| 106 | 105 | __u8 current_config; /* stores the current configuration byte */ |
|---|
| .. | .. |
|---|
| 109 | 108 | int get_cfg_unsafe; /* If true, the CYPRESS_GET_CONFIG is unsafe */ |
|---|
| 110 | 109 | int baud_rate; /* stores current baud rate in |
|---|
| 111 | 110 | integer form */ |
|---|
| 112 | | - int isthrottled; /* if throttled, discard reads */ |
|---|
| 113 | 111 | char prev_status; /* used for TIOCMIWAIT */ |
|---|
| 114 | | - /* we pass a pointer to this as the argument sent to |
|---|
| 115 | | - cypress_set_termios old_termios */ |
|---|
| 116 | | - struct ktermios tmp_termios; /* stores the old termios settings */ |
|---|
| 117 | 112 | }; |
|---|
| 118 | 113 | |
|---|
| 119 | 114 | /* function prototypes for the Cypress USB to serial device */ |
|---|
| .. | .. |
|---|
| 128 | 123 | const unsigned char *buf, int count); |
|---|
| 129 | 124 | static void cypress_send(struct usb_serial_port *port); |
|---|
| 130 | 125 | static int cypress_write_room(struct tty_struct *tty); |
|---|
| 126 | +static void cypress_earthmate_init_termios(struct tty_struct *tty); |
|---|
| 131 | 127 | static void cypress_set_termios(struct tty_struct *tty, |
|---|
| 132 | 128 | struct usb_serial_port *port, struct ktermios *old); |
|---|
| 133 | 129 | static int cypress_tiocmget(struct tty_struct *tty); |
|---|
| .. | .. |
|---|
| 155 | 151 | .dtr_rts = cypress_dtr_rts, |
|---|
| 156 | 152 | .write = cypress_write, |
|---|
| 157 | 153 | .write_room = cypress_write_room, |
|---|
| 154 | + .init_termios = cypress_earthmate_init_termios, |
|---|
| 158 | 155 | .set_termios = cypress_set_termios, |
|---|
| 159 | 156 | .tiocmget = cypress_tiocmget, |
|---|
| 160 | 157 | .tiocmset = cypress_tiocmset, |
|---|
| .. | .. |
|---|
| 380 | 377 | retval = -ENOTTY; |
|---|
| 381 | 378 | goto out; |
|---|
| 382 | 379 | } |
|---|
| 383 | | - dev_dbg(dev, "%s - retreiving serial line settings\n", __func__); |
|---|
| 380 | + dev_dbg(dev, "%s - retrieving serial line settings\n", __func__); |
|---|
| 384 | 381 | do { |
|---|
| 385 | 382 | retval = usb_control_msg(port->serial->dev, |
|---|
| 386 | 383 | usb_rcvctrlpipe(port->serial->dev, 0), |
|---|
| .. | .. |
|---|
| 469 | 466 | |
|---|
| 470 | 467 | priv->cmd_ctrl = 0; |
|---|
| 471 | 468 | priv->line_control = 0; |
|---|
| 472 | | - priv->termios_initialized = 0; |
|---|
| 473 | 469 | priv->rx_flags = 0; |
|---|
| 474 | 470 | /* Default packet format setting is determined by packet size. |
|---|
| 475 | 471 | Anything with a size larger then 9 must have a separate |
|---|
| .. | .. |
|---|
| 606 | 602 | cypress_send(port); |
|---|
| 607 | 603 | |
|---|
| 608 | 604 | if (tty) |
|---|
| 609 | | - cypress_set_termios(tty, port, &priv->tmp_termios); |
|---|
| 605 | + cypress_set_termios(tty, port, NULL); |
|---|
| 610 | 606 | |
|---|
| 611 | 607 | /* setup the port and start reading from the device */ |
|---|
| 612 | 608 | usb_fill_int_urb(port->interrupt_in_urb, serial->dev, |
|---|
| .. | .. |
|---|
| 859 | 855 | return cypress_write(tty, port, NULL, 0); |
|---|
| 860 | 856 | } |
|---|
| 861 | 857 | |
|---|
| 858 | +static void cypress_earthmate_init_termios(struct tty_struct *tty) |
|---|
| 859 | +{ |
|---|
| 860 | + tty_encode_baud_rate(tty, 4800, 4800); |
|---|
| 861 | +} |
|---|
| 862 | + |
|---|
| 862 | 863 | static void cypress_set_termios(struct tty_struct *tty, |
|---|
| 863 | 864 | struct usb_serial_port *port, struct ktermios *old_termios) |
|---|
| 864 | 865 | { |
|---|
| 865 | 866 | struct cypress_private *priv = usb_get_serial_port_data(port); |
|---|
| 866 | 867 | struct device *dev = &port->dev; |
|---|
| 867 | 868 | int data_bits, stop_bits, parity_type, parity_enable; |
|---|
| 868 | | - unsigned cflag, iflag; |
|---|
| 869 | + unsigned int cflag; |
|---|
| 869 | 870 | unsigned long flags; |
|---|
| 870 | 871 | __u8 oldlines; |
|---|
| 871 | 872 | int linechange = 0; |
|---|
| 872 | | - |
|---|
| 873 | | - spin_lock_irqsave(&priv->lock, flags); |
|---|
| 874 | | - /* We can't clean this one up as we don't know the device type |
|---|
| 875 | | - early enough */ |
|---|
| 876 | | - if (!priv->termios_initialized) { |
|---|
| 877 | | - if (priv->chiptype == CT_EARTHMATE) { |
|---|
| 878 | | - tty->termios = tty_std_termios; |
|---|
| 879 | | - tty->termios.c_cflag = B4800 | CS8 | CREAD | HUPCL | |
|---|
| 880 | | - CLOCAL; |
|---|
| 881 | | - tty->termios.c_ispeed = 4800; |
|---|
| 882 | | - tty->termios.c_ospeed = 4800; |
|---|
| 883 | | - } else if (priv->chiptype == CT_CYPHIDCOM) { |
|---|
| 884 | | - tty->termios = tty_std_termios; |
|---|
| 885 | | - tty->termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | |
|---|
| 886 | | - CLOCAL; |
|---|
| 887 | | - tty->termios.c_ispeed = 9600; |
|---|
| 888 | | - tty->termios.c_ospeed = 9600; |
|---|
| 889 | | - } else if (priv->chiptype == CT_CA42V2) { |
|---|
| 890 | | - tty->termios = tty_std_termios; |
|---|
| 891 | | - tty->termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | |
|---|
| 892 | | - CLOCAL; |
|---|
| 893 | | - tty->termios.c_ispeed = 9600; |
|---|
| 894 | | - tty->termios.c_ospeed = 9600; |
|---|
| 895 | | - } |
|---|
| 896 | | - priv->termios_initialized = 1; |
|---|
| 897 | | - } |
|---|
| 898 | | - spin_unlock_irqrestore(&priv->lock, flags); |
|---|
| 899 | 873 | |
|---|
| 900 | 874 | /* Unsupported features need clearing */ |
|---|
| 901 | 875 | tty->termios.c_cflag &= ~(CMSPAR|CRTSCTS); |
|---|
| 902 | 876 | |
|---|
| 903 | 877 | cflag = tty->termios.c_cflag; |
|---|
| 904 | | - iflag = tty->termios.c_iflag; |
|---|
| 905 | | - |
|---|
| 906 | | - /* check if there are new settings */ |
|---|
| 907 | | - if (old_termios) { |
|---|
| 908 | | - spin_lock_irqsave(&priv->lock, flags); |
|---|
| 909 | | - priv->tmp_termios = tty->termios; |
|---|
| 910 | | - spin_unlock_irqrestore(&priv->lock, flags); |
|---|
| 911 | | - } |
|---|
| 912 | 878 | |
|---|
| 913 | 879 | /* set number of data bits, parity, stop bits */ |
|---|
| 914 | 880 | /* when parity is disabled the parity type bit is ignored */ |
|---|
| .. | .. |
|---|
| 1082 | 1048 | return; |
|---|
| 1083 | 1049 | case -EPIPE: |
|---|
| 1084 | 1050 | /* Can't call usb_clear_halt while in_interrupt */ |
|---|
| 1085 | | - /* FALLS THROUGH */ |
|---|
| 1051 | + fallthrough; |
|---|
| 1086 | 1052 | default: |
|---|
| 1087 | 1053 | /* something ugly is going on... */ |
|---|
| 1088 | 1054 | dev_err(dev, "%s - unexpected nonzero read status received: %d\n", |
|---|
| .. | .. |
|---|
| 1231 | 1197 | return; |
|---|
| 1232 | 1198 | case -EPIPE: |
|---|
| 1233 | 1199 | /* Cannot call usb_clear_halt while in_interrupt */ |
|---|
| 1234 | | - /* FALLTHROUGH */ |
|---|
| 1200 | + fallthrough; |
|---|
| 1235 | 1201 | default: |
|---|
| 1236 | 1202 | dev_err(dev, "%s - unexpected nonzero write status received: %d\n", |
|---|
| 1237 | 1203 | __func__, status); |
|---|