Skip to contentSkip to conversation

can: c_can: precedence error in c_can_chip_config()

PATCH In review Dan Carpenter 3 participants 6 messages Jun 9, 2012 – Jun 12, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 can: c_can: precedence error in c_can_chip_config()

(CAN_CTRLMODE_LISTENONLY & CAN_CTRLMODE_LOOPBACK) is (0x02 & 0x01) which is zero so the condition is never true. The intent here was to test that both flags were set.

---
This is a static checker fix. I'm not super familiar with the c_can code.

drivers/net/can/c_can/c_can.c +2 -2
index e2ce508..eea6608 100644
@@ -594,8 +594,8 @@ static void c_can_chip_config(struct net_device *dev)
 	priv->write_reg(priv, C_CAN_CTRL_REG,
 			CONTROL_ENABLE_AR);
 
-	if (priv->can.ctrlmode & (CAN_CTRLMODE_LISTENONLY &
-					CAN_CTRLMODE_LOOPBACK)) {
+	if ((priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) &&
+	    (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)) {
 		/* loopback + silent mode : useful for hot self-test */
 		priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_EIE |
 				CONTROL_SIE | CONTROL_IE | CONTROL_TEST);
#1 lore raw
Quoted 8 lines · Dan Carpenter

(CAN_CTRLMODE_LISTENONLY & CAN_CTRLMODE_LOOPBACK) is (0x02 & 0x01) which is zero so the condition is never true. The intent here was to test that both flags were set.

---
This is a static checker fix. I'm not super familiar with the c_can code.

Good catch. Applied to can-next.

Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
#2 lore raw
Quoted 5 lines · Marc Kleine-Budde
Quoted 4 lines · Dan Carpenter

(CAN_CTRLMODE_LISTENONLY & CAN_CTRLMODE_LOOPBACK) is (0x02 & 0x01) which is zero so the condition is never true. The intent here was to test that both flags were set.

Quoted 9 lines
Quoted 4 lines

---
This is a static checker fix. I'm not super familiar with the c_can code.

Good catch. Applied to can-next.

Marc

Shouldn't this fix go through the net-tree and stable instead of net-next?

Regards,
Oliver

#3 lore raw
Quoted 12 lines · Oliver Hartkopp
Quoted 10 lines · Marc Kleine-Budde
Quoted 8 lines · Dan Carpenter

(CAN_CTRLMODE_LISTENONLY & CAN_CTRLMODE_LOOPBACK) is (0x02 & 0x01) which is zero so the condition is never true. The intent here was to test that both flags were set.

---
This is a static checker fix. I'm not super familiar with the c_can code.

Quoted 7 lines
Quoted 4 lines

Good catch. Applied to can-next.

Marc

Shouldn't this fix go through the net-tree and stable instead of net-next?

Indeed.

Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
#4 lore raw
In reply to Oliver Hartkopp
Quoted 12 lines · Oliver Hartkopp
Quoted 10 lines · Marc Kleine-Budde
Quoted 8 lines · Dan Carpenter

(CAN_CTRLMODE_LISTENONLY & CAN_CTRLMODE_LOOPBACK) is (0x02 & 0x01) which is zero so the condition is never true. The intent here was to test that both flags were set.

---
This is a static checker fix. I'm not super familiar with the c_can code.

Quoted 7 lines
Quoted 4 lines

Good catch. Applied to can-next.

Marc

Shouldn't this fix go through the net-tree and stable instead of net-next?

Can I add your Acked-by ... when adding to net?

Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |
#5 lore raw
Quoted 15 lines · Marc Kleine-Budde
Quoted 14 lines · Oliver Hartkopp
Quoted 12 lines · Marc Kleine-Budde
Quoted 8 lines · Dan Carpenter

(CAN_CTRLMODE_LISTENONLY & CAN_CTRLMODE_LOOPBACK) is (0x02 & 0x01) which is zero so the condition is never true. The intent here was to test that both flags were set.

---
This is a static checker fix. I'm not super familiar with the c_can code.

Good catch. Applied to can-next.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Marc

Shouldn't this fix go through the net-tree and stable instead of net-next?

Can I add your Acked-by ... when adding to net?

Yes you can :-)

Oliver