[patch] can: c_can: precedence error in c_can_chip_config()

Subsystems: can network drivers, the rest

STALE5205d

6 messages, 3 authors, 2012-06-12 · open the first message on its own page

[patch] can: c_can: precedence error in c_can_chip_config()

From: Dan Carpenter <hidden>
Date: 2012-06-09 15:57:17

(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.

Signed-off-by: Dan Carpenter <redacted>
---
This is a static checker fix.  I'm not super familiar with the c_can
code.
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index e2ce508..eea6608 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -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);

Re: [patch] can: c_can: precedence error in c_can_chip_config()

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: 2012-06-10 17:53:08

On 06/09/2012 05:56 PM, Dan Carpenter wrote:
(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.

Signed-off-by: Dan Carpenter <redacted>
---
This is a static checker fix.  I'm not super familiar with the c_can
code.
Good catch. Applied to can-next.

Marc

-- 
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   |

Re: [patch] can: c_can: precedence error in c_can_chip_config()

From: Oliver Hartkopp <socketcan@hartkopp.net>
Date: 2012-06-11 17:42:57

On 10.06.2012 19:52, Marc Kleine-Budde wrote:
On 06/09/2012 05:56 PM, Dan Carpenter wrote:
quoted
(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.

Signed-off-by: Dan Carpenter <redacted>
---
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

Re: [patch] can: c_can: precedence error in c_can_chip_config()

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: 2012-06-11 17:51:53

On 06/11/2012 07:42 PM, Oliver Hartkopp wrote:
On 10.06.2012 19:52, Marc Kleine-Budde wrote:
quoted
On 06/09/2012 05:56 PM, Dan Carpenter wrote:
quoted
(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.

Signed-off-by: Dan Carpenter <redacted>
---
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?
Indeed.

Marc
-- 
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   |

Re: [patch] can: c_can: precedence error in c_can_chip_config()

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: 2012-06-12 09:37:29

On 06/11/2012 07:42 PM, Oliver Hartkopp wrote:
On 10.06.2012 19:52, Marc Kleine-Budde wrote:
quoted
On 06/09/2012 05:56 PM, Dan Carpenter wrote:
quoted
(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.

Signed-off-by: Dan Carpenter <redacted>
---
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?
Can I add your Acked-by ... when adding to net?

Marc

-- 
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   |

Re: [patch] can: c_can: precedence error in c_can_chip_config()

From: Oliver Hartkopp <socketcan@hartkopp.net>
Date: 2012-06-12 11:01:19

On 12.06.2012 11:37, Marc Kleine-Budde wrote:
On 06/11/2012 07:42 PM, Oliver Hartkopp wrote:
quoted
On 10.06.2012 19:52, Marc Kleine-Budde wrote:
quoted
On 06/09/2012 05:56 PM, Dan Carpenter wrote:
quoted
(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.

Signed-off-by: Dan Carpenter <redacted>
---
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?
Can I add your Acked-by ... when adding to net?

Yes you can :-)

Oliver
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help