diff options
author | Michał Sroczyński <msroczyn@gmail.com> | 2011-07-05 15:53:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-07-08 17:58:27 -0400 |
commit | 8d48fdf689fed2c73c493e5146d1463689246442 (patch) | |
tree | 617f026fd8f52438f8da1ed874e2f86d0cdc6d04 /drivers/usb | |
parent | 35da41375caabe5433e6d20ab1ec087bd31d12b1 (diff) |
USB: PL2303: correctly handle baudrates above 115200
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.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 30461fcc220..ee28115aa9b 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -342,10 +342,28 @@ static void pl2303_set_termios(struct tty_struct *tty, | |||
342 | baud = 6000000; | 342 | baud = 6000000; |
343 | } | 343 | } |
344 | dbg("%s - baud set = %d", __func__, baud); | 344 | dbg("%s - baud set = %d", __func__, baud); |
345 | buf[0] = baud & 0xff; | 345 | if (baud <= 115200) { |
346 | buf[1] = (baud >> 8) & 0xff; | 346 | buf[0] = baud & 0xff; |
347 | buf[2] = (baud >> 16) & 0xff; | 347 | buf[1] = (baud >> 8) & 0xff; |
348 | buf[3] = (baud >> 24) & 0xff; | 348 | buf[2] = (baud >> 16) & 0xff; |
349 | buf[3] = (baud >> 24) & 0xff; | ||
350 | } else { | ||
351 | /* apparently the formula for higher speeds is: | ||
352 | * baudrate = 12M * 32 / (2^buf[1]) / buf[0] | ||
353 | */ | ||
354 | unsigned tmp = 12*1000*1000*32 / baud; | ||
355 | buf[3] = 0x80; | ||
356 | buf[2] = 0; | ||
357 | buf[1] = (tmp >= 256); | ||
358 | while (tmp >= 256) { | ||
359 | tmp >>= 2; | ||
360 | buf[1] <<= 1; | ||
361 | } | ||
362 | if (tmp > 256) { | ||
363 | tmp %= 256; | ||
364 | } | ||
365 | buf[0] = tmp; | ||
366 | } | ||
349 | } | 367 | } |
350 | 368 | ||
351 | /* For reference buf[4]=0 is 1 stop bits */ | 369 | /* For reference buf[4]=0 is 1 stop bits */ |