Skip to content

Commit 399aa9a

Browse files
Lauri Hintsalajhovold
Lauri Hintsala
authored andcommitted
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 <[email protected]> Signed-off-by: Johan Hovold <[email protected]>
1 parent 69e273c commit 399aa9a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/usb/serial/pl2303.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ static const struct pl2303_type_data pl2303_type_data[TYPE_COUNT] = {
162162
.max_baud_rate = 1228800,
163163
.quirks = PL2303_QUIRK_LEGACY,
164164
},
165+
[TYPE_HX] = {
166+
.max_baud_rate = 12000000,
167+
},
165168
};
166169

167170
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,
395398
if (spriv->type->max_baud_rate)
396399
baud = min_t(speed_t, baud, spriv->type->max_baud_rate);
397400
/*
398-
* Set baud rate to nearest supported value.
399-
*
400-
* NOTE: Baud rate 500k can only be set using divisors.
401+
* Use direct method for supported baud rates, otherwise use divisors.
401402
*/
402403
baud_sup = pl2303_get_supported_baud_rate(baud);
403404

404-
if (baud == 500000)
405-
baud = pl2303_encode_baud_rate_divisor(buf, baud);
405+
if (baud == baud_sup)
406+
baud = pl2303_encode_baud_rate_direct(buf, baud);
406407
else
407-
baud = pl2303_encode_baud_rate_direct(buf, baud_sup);
408+
baud = pl2303_encode_baud_rate_divisor(buf, baud);
408409

409410
/* Save resulting baud rate */
410411
tty_encode_baud_rate(tty, baud, baud);

0 commit comments

Comments
 (0)