aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/ftdi_sio.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-06-06 06:54:35 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-06-13 05:49:58 -0400
commit83c9a2d1a6ec906649facb009f1ee191c1c03f48 (patch)
tree0e29bf8ddaf30023c3f1649a41cdcdf162f409cb /drivers/usb/serial/ftdi_sio.c
parentf3e8ae657e40354cfb1372555f0d700f50f72ba2 (diff)
USB: serial: ftdi_sio: remove broken alt-speed handling
Remove the broken alt_speed code, and warn when trying to set the line speed using TIOCSSERIAL and SPD flags. The use of SPD flags to set the line speed has been deprecated since v2.1.69 and support for alt_speed (e.g. "warp") has even been removed from TTY core in v3.10 by commit 6865ff222cca ("TTY: do not warn about setting speed via SPD_*"), effectively breaking all driver implementations of this except for serial core. Also remove the verbose and outdated comment on how to set baud rates. Note that setting a custom divisor will continue to work with the caveat that 38400 must again be selected every time the divisor is changed since v2.6.24 and commit 669a6db1037e ("USB: ftd_sio: cleanups and updates for new termios work") which started reporting back the actual baud rate used. Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/ftdi_sio.c')
-rw-r--r--drivers/usb/serial/ftdi_sio.c56
1 files changed, 9 insertions, 47 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index df5c45a4b1d7..1cec03799cdf 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1244,42 +1244,13 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1244 int div_okay = 1; 1244 int div_okay = 1;
1245 int baud; 1245 int baud;
1246 1246
1247 /*
1248 * The logic involved in setting the baudrate can be cleanly split into
1249 * 3 steps.
1250 * 1. Standard baud rates are set in tty->termios->c_cflag
1251 * 2. If these are not enough, you can set any speed using alt_speed as
1252 * follows:
1253 * - set tty->termios->c_cflag speed to B38400
1254 * - set your real speed in tty->alt_speed; it gets ignored when
1255 * alt_speed==0, (or)
1256 * - call TIOCSSERIAL ioctl with (struct serial_struct) set as
1257 * follows:
1258 * flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP],
1259 * this just sets alt_speed to (HI: 57600, VHI: 115200,
1260 * SHI: 230400, WARP: 460800)
1261 * ** Steps 1, 2 are done courtesy of tty_get_baud_rate
1262 * 3. You can also set baud rate by setting custom divisor as follows
1263 * - set tty->termios->c_cflag speed to B38400
1264 * - call TIOCSSERIAL ioctl with (struct serial_struct) set as
1265 * follows:
1266 * o flags & ASYNC_SPD_MASK == ASYNC_SPD_CUST
1267 * o custom_divisor set to baud_base / your_new_baudrate
1268 * ** Step 3 is done courtesy of code borrowed from serial.c
1269 * I should really spend some time and separate + move this common
1270 * code to serial.c, it is replicated in nearly every serial driver
1271 * you see.
1272 */
1273
1274 /* 1. Get the baud rate from the tty settings, this observes
1275 alt_speed hack */
1276
1277 baud = tty_get_baud_rate(tty); 1247 baud = tty_get_baud_rate(tty);
1278 dev_dbg(dev, "%s - tty_get_baud_rate reports speed %d\n", __func__, baud); 1248 dev_dbg(dev, "%s - tty_get_baud_rate reports speed %d\n", __func__, baud);
1279 1249
1280 /* 2. Observe async-compatible custom_divisor hack, update baudrate 1250 /*
1281 if needed */ 1251 * Observe deprecated async-compatible custom_divisor hack, update
1282 1252 * baudrate if needed.
1253 */
1283 if (baud == 38400 && 1254 if (baud == 38400 &&
1284 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 1255 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
1285 (priv->custom_divisor)) { 1256 (priv->custom_divisor)) {
@@ -1288,8 +1259,6 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1288 __func__, priv->custom_divisor, baud); 1259 __func__, priv->custom_divisor, baud);
1289 } 1260 }
1290 1261
1291 /* 3. Convert baudrate to device-specific divisor */
1292
1293 if (!baud) 1262 if (!baud)
1294 baud = 9600; 1263 baud = 9600;
1295 switch (priv->chip_type) { 1264 switch (priv->chip_type) {
@@ -1529,21 +1498,14 @@ static int set_serial_info(struct tty_struct *tty,
1529check_and_exit: 1498check_and_exit:
1530 write_latency_timer(port); 1499 write_latency_timer(port);
1531 1500
1532 if ((priv->flags ^ old_priv.flags) & ASYNC_SPD_MASK) {
1533 if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
1534 tty->alt_speed = 57600;
1535 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
1536 tty->alt_speed = 115200;
1537 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
1538 tty->alt_speed = 230400;
1539 else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
1540 tty->alt_speed = 460800;
1541 else
1542 tty->alt_speed = 0;
1543 }
1544 if ((priv->flags ^ old_priv.flags) & ASYNC_SPD_MASK || 1501 if ((priv->flags ^ old_priv.flags) & ASYNC_SPD_MASK ||
1545 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST && 1502 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
1546 priv->custom_divisor != old_priv.custom_divisor)) { 1503 priv->custom_divisor != old_priv.custom_divisor)) {
1504
1505 /* warn about deprecation unless clearing */
1506 if (priv->flags & ASYNC_SPD_MASK)
1507 dev_warn_ratelimited(&port->dev, "use of SPD flags is deprecated\n");
1508
1547 change_speed(tty, port); 1509 change_speed(tty, port);
1548 mutex_unlock(&priv->cfg_lock); 1510 mutex_unlock(&priv->cfg_lock);
1549 } 1511 }