Skip to contentSkip to conversation

drivers/tty: Use bitwise instead of arithmetic operator for flags

PATCH Superseded Jiapeng Zhong 2 participants 2 messages Jan 15, 2021 TTY layer and serial drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/tty: Use bitwise instead of arithmetic operator for flags

Fix the following coccicheck warning:

./drivers/tty/synclink_gt.c:4384:15-16: WARNING: sum of probable bitmasks, consider | ./drivers/tty/synclink_gt.c:4342:39-40: WARNING: sum of probable bitmasks, consider | ./drivers/tty/synclink_gt.c:4280:48-49: WARNING: sum of probable bitmasks, consider | ./drivers/tty/synclink_gt.c:2221:20-21: WARNING: sum of probable bitmasks, consider |

---
 drivers/tty/synclink_gt.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/tty/synclink_gt.c +8 -4
index c0b384e..d302c08 100644
@@ -2219,7 +2219,7 @@ static void isr_tdma(struct slgt_info *info)
 	 */
 	wr_reg32(info, TDCSR, status);	/* clear pending */
 
-	if (status & (BIT5 + BIT4 + BIT3)) {
+	if (status & (BIT5 | BIT4 | BIT3)) {
 		// another transmit buffer has completed
 		// run bottom half to get more send data from user
 		info->pending_bh |= BH_TRANSMIT;
@@ -4265,7 +4265,9 @@ static void sync_mode(struct slgt_info *info)
 	case MGSL_MODE_XSYNC:
 		val |= BIT15 + BIT13;
 		break;
-	case MGSL_MODE_MONOSYNC: val |= BIT14 + BIT13; break;
+	case MGSL_MODE_MONOSYNC:
+		val |= BIT14 | BIT13;
+		break;
 	case MGSL_MODE_BISYNC:   val |= BIT15; break;
 	case MGSL_MODE_RAW:      val |= BIT13; break;
 	}
@@ -4278,7 +4280,9 @@ static void sync_mode(struct slgt_info *info)
 	case HDLC_ENCODING_NRZI_MARK:     val |= BIT11; break;
 	case HDLC_ENCODING_NRZI:          val |= BIT11 + BIT10; break;
 	case HDLC_ENCODING_BIPHASE_MARK:  val |= BIT12; break;
-	case HDLC_ENCODING_BIPHASE_SPACE: val |= BIT12 + BIT10; break;
+	case HDLC_ENCODING_BIPHASE_SPACE:
+		val |= BIT12 | BIT10;
+		break;
 	case HDLC_ENCODING_BIPHASE_LEVEL: val |= BIT12 + BIT11; break;
 	case HDLC_ENCODING_DIFF_BIPHASE_LEVEL: val |= BIT12 + BIT11 + BIT10; break;
 	}
@@ -4382,7 +4386,7 @@ static void sync_mode(struct slgt_info *info)
 		// reference clock, so take TxC from BRG/16 to get
 		// transmit clock at actual data rate
 		if (info->params.flags & HDLC_FLAG_RXC_DPLL)
-			val |= BIT6 + BIT5;	/* 011, txclk = BRG/16 */
+			val |= BIT6 | BIT5;	/* 011, txclk = BRG/16 */
 		else
 			val |= BIT6;	/* 010, txclk = BRG */
 	}
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 31 lines · Jiapeng Zhong

Fix the following coccicheck warning:

./drivers/tty/synclink_gt.c:4384:15-16: WARNING: sum of probable bitmasks, consider | ./drivers/tty/synclink_gt.c:4342:39-40: WARNING: sum of probable bitmasks, consider | ./drivers/tty/synclink_gt.c:4280:48-49: WARNING: sum of probable bitmasks, consider | ./drivers/tty/synclink_gt.c:2221:20-21: WARNING: sum of probable bitmasks, consider |

---
 drivers/tty/synclink_gt.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/tty/synclink_gt.c +1 -1
index c0b384e..d302c08 100644
@@ -2219,7 +2219,7 @@ static void isr_tdma(struct slgt_info *info)
 	 */
 	wr_reg32(info, TDCSR, status);	/* clear pending */
 
-	if (status & (BIT5 + BIT4 + BIT3)) {
+	if (status & (BIT5 | BIT4 | BIT3)) {
 		// another transmit buffer has completed
 		// run bottom half to get more send data from user
 		info->pending_bh |= BH_TRANSMIT;

drivers/tty/synclink_gt.c static void sync_mode(struct slgt_info *info) · line 4266

Quoted 2 lines
drivers/tty/synclink_gt.c +0 -0
@@ -4265,7 +4265,9 @@ static void sync_mode(struct slgt_info *info)
 	case MGSL_MODE_XSYNC:
 		val |= BIT15 + BIT13;

Why didn't you also change this line?

drivers/tty/synclink_gt.c static void sync_mode(struct slgt_info *info) · line 4281

Quoted 11 lines
drivers/tty/synclink_gt.c +3 -1
 		break;
-	case MGSL_MODE_MONOSYNC: val |= BIT14 + BIT13; break;
+	case MGSL_MODE_MONOSYNC:
+		val |= BIT14 | BIT13;
+		break;
 	case MGSL_MODE_BISYNC:   val |= BIT15; break;
 	case MGSL_MODE_RAW:      val |= BIT13; break;
 	}
@@ -4278,7 +4280,9 @@ static void sync_mode(struct slgt_info *info)
 	case HDLC_ENCODING_NRZI_MARK:     val |= BIT11; break;
 	case HDLC_ENCODING_NRZI:          val |= BIT11 + BIT10; break;

Or this line?

Seems like you only changed some of these "warnings", why?

Either fix them all or none :)

thanks,

greg k-h