]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
USB: serial: pl2303: fix line-speed handling on newer chips
authorJohan Hovold <johan@kernel.org>
Fri, 22 Oct 2021 07:22:00 +0000 (09:22 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 5 Nov 2021 08:12:52 +0000 (09:12 +0100)
BugLink: https://bugs.launchpad.net/bugs/1948377
The latest chip family (HXN) apparently does not support setting the
line speed using divisors and instead needs to use the direct encoding
scheme for all rates.

This specifically enables 50, 110, 134, 200 bps and other rates not
supported by the original chip type.

Fixes: ebd09f1cd417 ("USB: serial: pl2303: add support for PL2303HXN")
Cc: stable@vger.kernel.org # 5.5
Cc: Charles Yeh <charlesyeh522@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
(cherry picked from commit 979d9cbe75b922ab1695b8ad5576115774f72e62)
Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
Acked-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/usb/serial/pl2303.c

index 25b4333e9f85864ffa05467e78c8065da6c8a87c..67d2249cae2261196c11fc23bbbea313b4a5dc82 100644 (file)
@@ -184,6 +184,7 @@ struct pl2303_type_data {
        speed_t max_baud_rate;
        unsigned long quirks;
        unsigned int no_autoxonxoff:1;
+       unsigned int no_divisors:1;
 };
 
 struct pl2303_serial_private {
@@ -210,6 +211,7 @@ static const struct pl2303_type_data pl2303_type_data[TYPE_COUNT] = {
        },
        [TYPE_HXN] = {
                .max_baud_rate          = 12000000,
+               .no_divisors            = true,
        },
 };
 
@@ -572,8 +574,12 @@ static void pl2303_encode_baud_rate(struct tty_struct *tty,
                baud = min_t(speed_t, baud, spriv->type->max_baud_rate);
        /*
         * Use direct method for supported baud rates, otherwise use divisors.
+        * Newer chip types do not support divisor encoding.
         */
-       baud_sup = pl2303_get_supported_baud_rate(baud);
+       if (spriv->type->no_divisors)
+               baud_sup = baud;
+       else
+               baud_sup = pl2303_get_supported_baud_rate(baud);
 
        if (baud == baud_sup)
                baud = pl2303_encode_baud_rate_direct(buf, baud);