aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorMichal Sroczynski <msroczyn@gmail.com>2011-07-05 21:53:35 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2011-10-03 11:40:47 -0700
commit9ef0bbf3e5fa4ec3086495e4c48e3b4ccf12d47d (patch)
treeeadd95b189968693d19b10f307622fe21328d3ed /drivers/usb
parent5b48fc2d4e9ce38fe045429a3ef0c76dae899ed7 (diff)
downloadkernel_samsung_smdk4412-9ef0bbf3e5fa4ec3086495e4c48e3b4ccf12d47d.tar.gz
kernel_samsung_smdk4412-9ef0bbf3e5fa4ec3086495e4c48e3b4ccf12d47d.tar.bz2
kernel_samsung_smdk4412-9ef0bbf3e5fa4ec3086495e4c48e3b4ccf12d47d.zip
USB: PL2303: correctly handle baudrates above 115200
commit 8d48fdf689fed2c73c493e5146d1463689246442 upstream. PL2303: correctly handle baudrates above 115200 Signed-off-by: Michal Sroczynski <msroczyn@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/pl2303.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 0c208314d6e..1d33260de01 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -343,10 +343,28 @@ static void pl2303_set_termios(struct tty_struct *tty,
baud = 6000000;
}
dbg("%s - baud set = %d", __func__, baud);
- buf[0] = baud & 0xff;
- buf[1] = (baud >> 8) & 0xff;
- buf[2] = (baud >> 16) & 0xff;
- buf[3] = (baud >> 24) & 0xff;
+ if (baud <= 115200) {
+ buf[0] = baud & 0xff;
+ buf[1] = (baud >> 8) & 0xff;
+ buf[2] = (baud >> 16) & 0xff;
+ buf[3] = (baud >> 24) & 0xff;
+ } else {
+ /* apparently the formula for higher speeds is:
+ * baudrate = 12M * 32 / (2^buf[1]) / buf[0]
+ */
+ unsigned tmp = 12*1000*1000*32 / baud;
+ buf[3] = 0x80;
+ buf[2] = 0;
+ buf[1] = (tmp >= 256);
+ while (tmp >= 256) {
+ tmp >>= 2;
+ buf[1] <<= 1;
+ }
+ if (tmp > 256) {
+ tmp %= 256;
+ }
+ buf[0] = tmp;
+ }
}
/* For reference buf[4]=0 is 1 stop bits */