diff options
author | Michal Sroczynski <msroczyn@gmail.com> | 2011-07-05 15:53:35 -0400 |
---|---|---|
committer | Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com> | 2011-10-17 13:33:03 -0400 |
commit | f3d5d8895400da6eb324794ab356b68eff2e6114 (patch) | |
tree | 44b806efc79c9cf9f332e93a1a0c9bdb4179955e /drivers/usb | |
parent | 2d4e57380a717fd511ce1bf9d9f501960da2414f (diff) |
USB: PL2303: correctly handle baudrates above 115200
BugLink: http://bugs.launchpad.net/bugs/868628
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.c | 26 |
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, | |||
343 | baud = 6000000; | 343 | baud = 6000000; |
344 | } | 344 | } |
345 | dbg("%s - baud set = %d", __func__, baud); | 345 | dbg("%s - baud set = %d", __func__, baud); |
346 | buf[0] = baud & 0xff; | 346 | if (baud <= 115200) { |
347 | buf[1] = (baud >> 8) & 0xff; | 347 | buf[0] = baud & 0xff; |
348 | buf[2] = (baud >> 16) & 0xff; | 348 | buf[1] = (baud >> 8) & 0xff; |
349 | buf[3] = (baud >> 24) & 0xff; | 349 | buf[2] = (baud >> 16) & 0xff; |
350 | buf[3] = (baud >> 24) & 0xff; | ||
351 | } else { | ||
352 | /* apparently the formula for higher speeds is: | ||
353 | * baudrate = 12M * 32 / (2^buf[1]) / buf[0] | ||
354 | */ | ||
355 | unsigned tmp = 12*1000*1000*32 / baud; | ||
356 | buf[3] = 0x80; | ||
357 | buf[2] = 0; | ||
358 | buf[1] = (tmp >= 256); | ||
359 | while (tmp >= 256) { | ||
360 | tmp >>= 2; | ||
361 | buf[1] <<= 1; | ||
362 | } | ||
363 | if (tmp > 256) { | ||
364 | tmp %= 256; | ||
365 | } | ||
366 | buf[0] = tmp; | ||
367 | } | ||
350 | } | 368 | } |
351 | 369 | ||
352 | /* For reference buf[4]=0 is 1 stop bits */ | 370 | /* For reference buf[4]=0 is 1 stop bits */ |