aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/synclinkmp.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-01-27 21:21:00 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-30 00:09:58 -0500
commit9fe8074b82ed14358be50c62ab9d081bcb911607 (patch)
tree53dd1345c50b76426747536bb681489f59aaa93f /drivers/tty/synclinkmp.c
parentabd7bacae672298ec99ce6cfdc75ae1e1f9159b6 (diff)
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.c40
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)
882 /* Handle transition to B0 status */ 882 /* Handle transition to B0 status */
883 if (old_termios->c_cflag & CBAUD && 883 if (old_termios->c_cflag & CBAUD &&
884 !(tty->termios.c_cflag & CBAUD)) { 884 !(tty->termios.c_cflag & CBAUD)) {
885 info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); 885 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
886 spin_lock_irqsave(&info->lock,flags); 886 spin_lock_irqsave(&info->lock,flags);
887 set_signals(info); 887 set_signals(info);
888 spin_unlock_irqrestore(&info->lock,flags); 888 spin_unlock_irqrestore(&info->lock,flags);
@@ -1676,8 +1676,8 @@ static int hdlcdev_open(struct net_device *dev)
1676 return rc; 1676 return rc;
1677 } 1677 }
1678 1678
1679 /* assert DTR and RTS, apply hardware settings */ 1679 /* assert RTS and DTR, apply hardware settings */
1680 info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; 1680 info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR;
1681 program_hw(info); 1681 program_hw(info);
1682 1682
1683 /* enable network layer transmit */ 1683 /* enable network layer transmit */
@@ -2706,7 +2706,7 @@ static void shutdown(SLMP_INFO * info)
2706 reset_port(info); 2706 reset_port(info);
2707 2707
2708 if (!info->port.tty || info->port.tty->termios.c_cflag & HUPCL) { 2708 if (!info->port.tty || info->port.tty->termios.c_cflag & HUPCL) {
2709 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); 2709 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
2710 set_signals(info); 2710 set_signals(info);
2711 } 2711 }
2712 2712
@@ -2768,12 +2768,12 @@ static void change_params(SLMP_INFO *info)
2768 2768
2769 cflag = info->port.tty->termios.c_cflag; 2769 cflag = info->port.tty->termios.c_cflag;
2770 2770
2771 /* if B0 rate (hangup) specified then negate DTR and RTS */ 2771 /* if B0 rate (hangup) specified then negate RTS and DTR */
2772 /* otherwise assert DTR and RTS */ 2772 /* otherwise assert RTS and DTR */
2773 if (cflag & CBAUD) 2773 if (cflag & CBAUD)
2774 info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; 2774 info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR;
2775 else 2775 else
2776 info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); 2776 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
2777 2777
2778 /* byte size and parity */ 2778 /* byte size and parity */
2779 2779
@@ -3212,12 +3212,12 @@ static int tiocmget(struct tty_struct *tty)
3212 get_signals(info); 3212 get_signals(info);
3213 spin_unlock_irqrestore(&info->lock,flags); 3213 spin_unlock_irqrestore(&info->lock,flags);
3214 3214
3215 result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS:0) + 3215 result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS : 0) |
3216 ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR:0) + 3216 ((info->serial_signals & SerialSignal_DTR) ? TIOCM_DTR : 0) |
3217 ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR:0) + 3217 ((info->serial_signals & SerialSignal_DCD) ? TIOCM_CAR : 0) |
3218 ((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG:0) + 3218 ((info->serial_signals & SerialSignal_RI) ? TIOCM_RNG : 0) |
3219 ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR:0) + 3219 ((info->serial_signals & SerialSignal_DSR) ? TIOCM_DSR : 0) |
3220 ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS:0); 3220 ((info->serial_signals & SerialSignal_CTS) ? TIOCM_CTS : 0);
3221 3221
3222 if (debug_level >= DEBUG_LEVEL_INFO) 3222 if (debug_level >= DEBUG_LEVEL_INFO)
3223 printk("%s(%d):%s tiocmget() value=%08X\n", 3223 printk("%s(%d):%s tiocmget() value=%08X\n",
@@ -3272,9 +3272,9 @@ static void dtr_rts(struct tty_port *port, int on)
3272 3272
3273 spin_lock_irqsave(&info->lock,flags); 3273 spin_lock_irqsave(&info->lock,flags);
3274 if (on) 3274 if (on)
3275 info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; 3275 info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR;
3276 else 3276 else
3277 info->serial_signals &= ~(SerialSignal_RTS + SerialSignal_DTR); 3277 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
3278 set_signals(info); 3278 set_signals(info);
3279 spin_unlock_irqrestore(&info->lock,flags); 3279 spin_unlock_irqrestore(&info->lock,flags);
3280} 3280}
@@ -4354,7 +4354,7 @@ static void reset_port(SLMP_INFO *info)
4354 tx_stop(info); 4354 tx_stop(info);
4355 rx_stop(info); 4355 rx_stop(info);
4356 4356
4357 info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); 4357 info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
4358 set_signals(info); 4358 set_signals(info);
4359 4359
4360 /* disable all port interrupts */ 4360 /* disable all port interrupts */
@@ -4750,8 +4750,8 @@ static void get_signals(SLMP_INFO *info)
4750 u16 gpstatus = read_status_reg(info); 4750 u16 gpstatus = read_status_reg(info);
4751 u16 testbit; 4751 u16 testbit;
4752 4752
4753 /* clear all serial signals except DTR and RTS */ 4753 /* clear all serial signals except RTS and DTR */
4754 info->serial_signals &= SerialSignal_DTR + SerialSignal_RTS; 4754 info->serial_signals &= SerialSignal_RTS | SerialSignal_DTR;
4755 4755
4756 /* set serial signal bits to reflect MISR */ 4756 /* set serial signal bits to reflect MISR */
4757 4757
@@ -4770,7 +4770,7 @@ static void get_signals(SLMP_INFO *info)
4770 info->serial_signals |= SerialSignal_DSR; 4770 info->serial_signals |= SerialSignal_DSR;
4771} 4771}
4772 4772
4773/* Set the state of DTR and RTS based on contents of 4773/* Set the state of RTS and DTR based on contents of
4774 * serial_signals member of device context. 4774 * serial_signals member of device context.
4775 */ 4775 */
4776static void set_signals(SLMP_INFO *info) 4776static void set_signals(SLMP_INFO *info)