[PATCH] USB: serial: pl2303: PL2303HXN can support baud rate are set directly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



PL2303HXN (TYPE_HXN) can program form 1 bps to 12000000 bps and
support standard & non-standard baud rates (Note 1) are set directly
It doesn't need complicated baud rate division calculation.

Note 1:
Standard baud rate:
75, 150, 300, 600, 1200, 1800, 2400, 3600, 4800, 7200, 9600,14400,
19200, 28800, 38400, 57600, 115200, 230400, 460800,614400, 921600,
1228800, 2457600, 3000000, 6000000

Non-standard baud rate (1 ~ 12000000):
1, 2, 5, 22, 55, 60, 75, 80, 123, 130, 150, 180, 187, 200, 300, 340,
400,..... 115200, 230400, 460800, 474747, 515151, 614400, 921600,
.. 1000000,.. 7000000,.. 12000000

Signed-off-by: Charles Yeh <charlesyeh522@xxxxxxxxx>
---
---
 drivers/usb/serial/pl2303.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index aab737e1e7b6..63d354a92db9 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -565,17 +565,21 @@ static void pl2303_encode_baud_rate(struct tty_struct *tty,
 	if (!baud)
 		return;
 
-	if (spriv->type->max_baud_rate)
-		baud = min_t(speed_t, baud, spriv->type->max_baud_rate);
-	/*
-	 * Use direct method for supported baud rates, otherwise use divisors.
-	 */
-	baud_sup = pl2303_get_supported_baud_rate(baud);
-
-	if (baud == baud_sup)
+	if (spriv->type == &pl2303_type_data[TYPE_HXN]) {
 		baud = pl2303_encode_baud_rate_direct(buf, baud);
-	else
-		baud = pl2303_encode_baud_rate_divisor(buf, baud);
+	} else {
+		if (spriv->type->max_baud_rate)
+			baud = min_t(speed_t, baud, spriv->type->max_baud_rate);
+		/*
+		 * Use direct method for supported baud rates, otherwise use divisors.
+		 */
+		baud_sup = pl2303_get_supported_baud_rate(baud);
+
+		if (baud == baud_sup)
+			baud = pl2303_encode_baud_rate_direct(buf, baud);
+		else
+			baud = pl2303_encode_baud_rate_divisor(buf, baud);
+	}
 
 	/* Save resulting baud rate */
 	tty_encode_baud_rate(tty, baud, baud);
-- 
2.20.1




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux