]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/usb/serial/ch341.c
Merge tag 'staging-5.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[linux.git] / drivers / usb / serial / ch341.c
index d3f420f3a083570d4d3372514c39430caa9fc8d8..c5ecdcd51ffc6742e09af4954e5c3c272233c208 100644 (file)
@@ -205,6 +205,16 @@ static int ch341_get_divisor(speed_t speed)
                        16 * speed - 16 * CH341_CLKRATE / (clk_div * (div + 1)))
                div++;
 
+       /*
+        * Prefer lower base clock (fact = 0) if even divisor.
+        *
+        * Note that this makes the receiver more tolerant to errors.
+        */
+       if (fact == 1 && div % 2 == 0) {
+               div /= 2;
+               fact = 0;
+       }
+
        return (0x100 - div) << 8 | fact << 2 | ps;
 }