diff options
author | Joe Perches <joe@perches.com> | 2013-01-28 03:21:00 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-30 06:09:58 +0100 |
commit | 9fe8074b82ed14358be50c62ab9d081bcb911607 (patch) | |
tree | 53dd1345c50b76426747536bb681489f59aaa93f /drivers/tty/synclinkmp.c | |
parent | serial/8250: Add suport for later SUNIX (TIMEDIA) boards. (diff) | |
download | linux-9fe8074b82ed14358be50c62ab9d081bcb911607.tar.xz linux-9fe8074b82ed14358be50c62ab9d081bcb911607.zip |
TTY: synclink: Convert + to | for bit operations
Dan Carpenter noticed a missing set of parentheses
around a multiple field addition.
https://lkml.org/lkml/2013/1/27/166
His original commit message:
There is a kind of precedence problem here, but it doesn't affect how
the code works because ->serial_signals is unsigned char. We want to
clear two flags here.
#define SerialSignal_RTS 0x20 /* Request to Send */
#define SerialSignal_DTR 0x80 /* Data Terminal Ready */
Without the parenthesis then it does:
info->serial_signals &= 0x5f;
With the parenthesis it does:
info->serial_signals &= 0xffffff5f;
info->serial_signals is an unsigned char so the two statements are
equivalent, but it's cleaner to add the parenthesis. In other dtr_rts()
functions the parenthesis are there so this makes it more consistent.
Other changes:
Convert all + uses to | for these bit operations.
Reorder the multiple fields for consistency.
Update the comments too.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/synclinkmp.c')
-rw-r--r-- | drivers/tty/synclinkmp.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index 545402509cab..6d5780cf1d57 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c @@ -882,7 +882,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios) /* Handle transition to B0 status */ if (old_termios->c_cflag & CBAUD && !(tty->termios.c_cflag & CBAUD)) { - info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); spin_lock_irqsave(&info->lock,flags); set_signals(info); spin_unlock_irqrestore(&info->lock,flags); @@ -1676,8 +1676,8 @@ static int hdlcdev_open(struct net_device *dev) return rc; } - /* assert DTR and RTS, apply hardware settings */ - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + /* assert RTS and DTR, apply hardware settings */ + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; program_hw(info); /* enable network layer transmit */ @@ -2706,7 +2706,7 @@ static void shutdown(SLMP_INFO * info) reset_port(info); if (!info->port.tty || info->port.tty->termios.c_cflag & HUPCL) { - info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); set_signals(info); } @@ -2768,12 +2768,12 @@ static void change_params(SLMP_INFO *info) cflag = info->port.tty->termios.c_cflag; - /* if B0 rate (hangup) specified then negate DTR and RTS */ - /* otherwise assert DTR and RTS */ + /* if B0 rate (hangup) specified then negate RTS and DTR */ + /* otherwise assert RTS and DTR */ if (cflag & CBAUD) - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; else - info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); /* byte size and parity */ @@ -3212,12 +3212,12 @@ static int tiocmget(struct tty_struct *tty) get_signals(info); spin_unlock_irqrestore(&info->lock,flags); - result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) + - ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) + - ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) + - ((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG:0) + - ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) + - ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0); + result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS : 0) | + ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR : 0) | + ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR : 0) | + ((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG : 0) | + ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR : 0) | + ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS : 0); if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):%s tiocmget() value=%08X\n", @@ -3272,9 +3272,9 @@ static void dtr_rts(struct tty_port *port, int on) spin_lock_irqsave(&info->lock,flags); if (on) - info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; + info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; else - info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); set_signals(info); spin_unlock_irqrestore(&info->lock,flags); } @@ -4354,7 +4354,7 @@ static void reset_port(SLMP_INFO *info) tx_stop(info); rx_stop(info); - info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); + info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); set_signals(info); /* disable all port interrupts */ @@ -4750,8 +4750,8 @@ static void get_signals(SLMP_INFO *info) u16 gpstatus = read_status_reg(info); u16 testbit; - /* clear all serial signals except DTR and RTS */ - info->serial_signals &= SerialSignal_DTR + SerialSignal_RTS; + /* clear all serial signals except RTS and DTR */ + info->serial_signals &= SerialSignal_RTS | SerialSignal_DTR; /* set serial signal bits to reflect MISR */ @@ -4770,7 +4770,7 @@ static void get_signals(SLMP_INFO *info) info->serial_signals |= SerialSignal_DSR; } -/* Set the state of DTR and RTS based on contents of +/* Set the state of RTS and DTR based on contents of * serial_signals member of device context. */ static void set_signals(SLMP_INFO *info) |