forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/usb/serial/cypress_m8.c
....@@ -7,7 +7,7 @@
77 * Copyright (C) 2003,2004
88 * Neil Whelchel (koyama@firstlight.net)
99 *
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
1111 * driver
1212 *
1313 * See http://geocities.com/i0xox0i for information on this driver and the
....@@ -100,7 +100,6 @@
100100 int write_urb_interval; /* interval to use for write urb */
101101 int read_urb_interval; /* interval to use for read urb */
102102 int comm_is_ok; /* true if communication is (still) ok */
103
- int termios_initialized;
104103 __u8 line_control; /* holds dtr / rts value */
105104 __u8 current_status; /* received from last read - info on dsr,cts,cd,ri,etc */
106105 __u8 current_config; /* stores the current configuration byte */
....@@ -109,11 +108,7 @@
109108 int get_cfg_unsafe; /* If true, the CYPRESS_GET_CONFIG is unsafe */
110109 int baud_rate; /* stores current baud rate in
111110 integer form */
112
- int isthrottled; /* if throttled, discard reads */
113111 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 */
117112 };
118113
119114 /* function prototypes for the Cypress USB to serial device */
....@@ -128,6 +123,7 @@
128123 const unsigned char *buf, int count);
129124 static void cypress_send(struct usb_serial_port *port);
130125 static int cypress_write_room(struct tty_struct *tty);
126
+static void cypress_earthmate_init_termios(struct tty_struct *tty);
131127 static void cypress_set_termios(struct tty_struct *tty,
132128 struct usb_serial_port *port, struct ktermios *old);
133129 static int cypress_tiocmget(struct tty_struct *tty);
....@@ -155,6 +151,7 @@
155151 .dtr_rts = cypress_dtr_rts,
156152 .write = cypress_write,
157153 .write_room = cypress_write_room,
154
+ .init_termios = cypress_earthmate_init_termios,
158155 .set_termios = cypress_set_termios,
159156 .tiocmget = cypress_tiocmget,
160157 .tiocmset = cypress_tiocmset,
....@@ -380,7 +377,7 @@
380377 retval = -ENOTTY;
381378 goto out;
382379 }
383
- dev_dbg(dev, "%s - retreiving serial line settings\n", __func__);
380
+ dev_dbg(dev, "%s - retrieving serial line settings\n", __func__);
384381 do {
385382 retval = usb_control_msg(port->serial->dev,
386383 usb_rcvctrlpipe(port->serial->dev, 0),
....@@ -469,7 +466,6 @@
469466
470467 priv->cmd_ctrl = 0;
471468 priv->line_control = 0;
472
- priv->termios_initialized = 0;
473469 priv->rx_flags = 0;
474470 /* Default packet format setting is determined by packet size.
475471 Anything with a size larger then 9 must have a separate
....@@ -606,7 +602,7 @@
606602 cypress_send(port);
607603
608604 if (tty)
609
- cypress_set_termios(tty, port, &priv->tmp_termios);
605
+ cypress_set_termios(tty, port, NULL);
610606
611607 /* setup the port and start reading from the device */
612608 usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
....@@ -859,56 +855,26 @@
859855 return cypress_write(tty, port, NULL, 0);
860856 }
861857
858
+static void cypress_earthmate_init_termios(struct tty_struct *tty)
859
+{
860
+ tty_encode_baud_rate(tty, 4800, 4800);
861
+}
862
+
862863 static void cypress_set_termios(struct tty_struct *tty,
863864 struct usb_serial_port *port, struct ktermios *old_termios)
864865 {
865866 struct cypress_private *priv = usb_get_serial_port_data(port);
866867 struct device *dev = &port->dev;
867868 int data_bits, stop_bits, parity_type, parity_enable;
868
- unsigned cflag, iflag;
869
+ unsigned int cflag;
869870 unsigned long flags;
870871 __u8 oldlines;
871872 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);
899873
900874 /* Unsupported features need clearing */
901875 tty->termios.c_cflag &= ~(CMSPAR|CRTSCTS);
902876
903877 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
- }
912878
913879 /* set number of data bits, parity, stop bits */
914880 /* when parity is disabled the parity type bit is ignored */
....@@ -1082,7 +1048,7 @@
10821048 return;
10831049 case -EPIPE:
10841050 /* Can't call usb_clear_halt while in_interrupt */
1085
- /* FALLS THROUGH */
1051
+ fallthrough;
10861052 default:
10871053 /* something ugly is going on... */
10881054 dev_err(dev, "%s - unexpected nonzero read status received: %d\n",
....@@ -1231,7 +1197,7 @@
12311197 return;
12321198 case -EPIPE:
12331199 /* Cannot call usb_clear_halt while in_interrupt */
1234
- /* FALLTHROUGH */
1200
+ fallthrough;
12351201 default:
12361202 dev_err(dev, "%s - unexpected nonzero write status received: %d\n",
12371203 __func__, status);