提交 75e8b71d 编写于 作者: M Maciej W. Rozycki 提交者: Linus Torvalds

tty_ioctl: fix the baud_table check in encode_baud_rate

The tty_termios_encode_baud_rate() function as defined by tty_ioctl.c has a
problem with the baud_table within.  The comparison operators are reversed
and as a result this table's entries never match and BOTHER is always used.
Signed-off-by: NMaciej W. Rozycki <macro@linux-mips.org>
Acked-by: NAlan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 77bf2bab
......@@ -228,7 +228,8 @@ EXPORT_SYMBOL(tty_termios_input_baud_rate);
* and will all go away once this is done.
*/
void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed_t obaud)
void tty_termios_encode_baud_rate(struct ktermios *termios,
speed_t ibaud, speed_t obaud)
{
int i = 0;
int ifound = -1, ofound = -1;
......@@ -263,11 +264,15 @@ void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed
*/
do {
if (obaud - oclose >= baud_table[i] && obaud + oclose <= baud_table[i]) {
if (obaud - oclose <= baud_table[i] &&
obaud + oclose >= baud_table[i]) {
termios->c_cflag |= baud_bits[i];
ofound = i;
}
if (ibaud - iclose >= baud_table[i] && ibaud + iclose <= baud_table[i]) {
if (ibaud - iclose <= baud_table[i] &&
ibaud + iclose >= baud_table[i]) {
/* For the case input == output don't set IBAUD bits
if the user didn't do so */
if (ofound == i && !ibinput)
ifound = i;
#ifdef IBSHIFT
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册