Commit 8d48fdf6 authored by Michał Sroczyński's avatar Michał Sroczyński Committed by Greg Kroah-Hartman

USB: PL2303: correctly handle baudrates above 115200

PL2303: correctly handle baudrates above 115200
Signed-off-by: default avatarMichal Sroczynski <msroczyn@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 35da4137
...@@ -342,10 +342,28 @@ static void pl2303_set_termios(struct tty_struct *tty, ...@@ -342,10 +342,28 @@ static void pl2303_set_termios(struct tty_struct *tty,
baud = 6000000; baud = 6000000;
} }
dbg("%s - baud set = %d", __func__, baud); dbg("%s - baud set = %d", __func__, baud);
if (baud <= 115200) {
buf[0] = baud & 0xff; buf[0] = baud & 0xff;
buf[1] = (baud >> 8) & 0xff; buf[1] = (baud >> 8) & 0xff;
buf[2] = (baud >> 16) & 0xff; buf[2] = (baud >> 16) & 0xff;
buf[3] = (baud >> 24) & 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 */ /* For reference buf[4]=0 is 1 stop bits */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment