USB-serial: pl2303: fix baud rate handling in case of unsupported values
authorFrank Schaefer <schaefer.frank@gmx.net>
Tue, 18 Aug 2009 18:15:07 +0000 (20:15 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 23 Sep 2009 13:46:36 +0000 (06:46 -0700)
commit25b8286805e856c8c7fda127018e31032c918015
treee95665d787347049bc728d96c2c169f329e8a4db
parente55c6d06fead7e58b7c597fd9afc46a88ef740e6
USB-serial: pl2303: fix baud rate handling in case of unsupported values

According to the datasheets, the PL2303 supports a set of 25 baudrates.
The baudrate is set as a 4 byte value directly.

During my experiments with device 067b:2303 (PL2303X), I noticed that
 - the bridge-controller always uses 9600 baud if invalid/unsupported baud rate
   values are set
 - the baud rate value returned by usb_control_msg(..., GET_LINE_REQUEST, ...)
   does not reflect the actually used baudrate. Always the last set value is
   returned, even if it was invalid and not used by the controller.

This patch fixes the following issues with the current code:
1.) make sure that only supported baudrates are set (are there any buggy
    chip revisions out there which don't "like" other values... ?).
2.) always set the baudrate to the next nearest supported baudrate.
3.) applications can now read back the resulting baudrate properly, because
    tty_encode_baud_rate(...) is now fed with the actually used baudrate.

Signed-off-by: Frank Schaefer <schaefer.frank@gmx.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/serial/pl2303.c