summaryrefslogtreecommitdiff
path: root/drivers/usb/serial/pl2303.c
diff options
context:
space:
mode:
authorLauri Hintsala <lauri.hintsala@bluegiga.com>2014-08-13 15:02:53 +0300
committerJohan Hovold <johan@kernel.org>2014-09-01 12:04:17 +0200
commit399aa9a75ad372b301e5050f3653a297a767fdc4 (patch)
tree9738bb249a31ba13cba86866cf641bdc915d7f7a /drivers/usb/serial/pl2303.c
parent69e273c0b0a3c337a521d083374c918dc52c666f (diff)
downloadlwn-399aa9a75ad372b301e5050f3653a297a767fdc4.tar.gz
lwn-399aa9a75ad372b301e5050f3653a297a767fdc4.zip
USB: pl2303: use divisors for unsupported baud rates
Use direct method for supported baud rates, otherwise use divisors. Limit baud rate to 12 Mbaud with HX type. This change has been tested to work with PL-2303HX at 115200, 500000, 1000000, 2000000, 2500000, 3000000 and 4000000 baud rates. Signed-off-by: Lauri Hintsala <lauri.hintsala@bluegiga.com> Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial/pl2303.c')
-rw-r--r--drivers/usb/serial/pl2303.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index e9bad928039f..0f872e6b2c87 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -162,6 +162,9 @@ static const struct pl2303_type_data pl2303_type_data[TYPE_COUNT] = {
.max_baud_rate = 1228800,
.quirks = PL2303_QUIRK_LEGACY,
},
+ [TYPE_HX] = {
+ .max_baud_rate = 12000000,
+ },
};
static int pl2303_vendor_read(struct usb_serial *serial, u16 value,
@@ -395,16 +398,14 @@ static void pl2303_encode_baud_rate(struct tty_struct *tty,
if (spriv->type->max_baud_rate)
baud = min_t(speed_t, baud, spriv->type->max_baud_rate);
/*
- * Set baud rate to nearest supported value.
- *
- * NOTE: Baud rate 500k can only be set using divisors.
+ * Use direct method for supported baud rates, otherwise use divisors.
*/
baud_sup = pl2303_get_supported_baud_rate(baud);
- if (baud == 500000)
- baud = pl2303_encode_baud_rate_divisor(buf, baud);
+ if (baud == baud_sup)
+ baud = pl2303_encode_baud_rate_direct(buf, baud);
else
- baud = pl2303_encode_baud_rate_direct(buf, baud_sup);
+ baud = pl2303_encode_baud_rate_divisor(buf, baud);
/* Save resulting baud rate */
tty_encode_baud_rate(tty, baud, baud);