summaryrefslogtreecommitdiff
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-12-29 22:23:14 +0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-04 00:31:48 +0400
commit20b4c787199f4fcf0fae5ed78a4ff0104e2afaa3 (patch)
treecdad57048ead95f9afc8aa8fb69ed78121765a6c /drivers/usb/serial
parentc82c6d45a2fc882fedfde517ba86690b2d5ed555 (diff)
downloadlinux-20b4c787199f4fcf0fae5ed78a4ff0104e2afaa3.tar.xz
USB: pl2303: add helper function for direct baud-rate encoding
Add helper function for direct baud-rate encoding. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/pl2303.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 44f4b546adeb..b4e72979def7 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -339,6 +339,18 @@ static speed_t pl2303_get_supported_baud_rate(speed_t baud)
return baud;
}
+/*
+ * NOTE: If unsupported baud rates are set directly, the PL2303 seems to
+ * use 9600 baud.
+ */
+static speed_t pl2303_encode_baud_rate_direct(unsigned char buf[4],
+ speed_t baud)
+{
+ put_unaligned_le32(baud, buf);
+
+ return baud;
+}
+
static speed_t pl2303_encode_baud_rate_divisor(unsigned char buf[4],
speed_t baud)
{
@@ -376,16 +388,12 @@ 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: If unsupported values are set directly, the PL2303 seems to
- * use 9600 baud.
- */
+
+ /* Set baud rate to nearest supported value. */
baud = pl2303_get_supported_baud_rate(baud);
if (baud <= 115200)
- put_unaligned_le32(baud, buf);
+ baud = pl2303_encode_baud_rate_direct(buf, baud);
else
baud = pl2303_encode_baud_rate_divisor(buf, baud);