linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] can: c_can: Enable interrupts only when initialization has been completed
@ 2014-04-02 17:28 Oleksandr Tyshchenko
  2014-04-24 22:07 ` Marc Kleine-Budde
  0 siblings, 1 reply; 2+ messages in thread
From: Oleksandr Tyshchenko @ 2014-04-02 17:28 UTC (permalink / raw)
  To: linux-can; +Cc: wg, mkl

In current driver realization we enable interrupts twice from c_can_start().
First time in c_can_start()->c_can_chip_config() during set operating mode.
Second time in the end of c_can_start() after finish basic controller
configuration.

Enabling interrupts in first place (while initialization is ongoing)
may cause to interrupts when the CAN chip is not completely initialized.
Also if basic controller configuration failed with error,
we will leave initialization sequence with interrupts enabled.

We have to enable interrupts only when initialization has been completed.
So, don't enable interrupts while initialization is ongoing.

Signed-off-by: Oleksandr Tyshchenko <oleksandr.tyshchenko@globallogic.com>
---
 drivers/net/can/c_can/c_can.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 6883938..3ce776e8 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -642,24 +642,18 @@ static int c_can_chip_config(struct net_device *dev)
 	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);
+		priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_TEST);
 		priv->write_reg(priv, C_CAN_TEST_REG,
 				TEST_LBACK | TEST_SILENT);
 	} else if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) {
 		/* loopback mode : useful for self-test function */
-		priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_EIE |
-				CONTROL_SIE | CONTROL_IE | CONTROL_TEST);
+		priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_TEST);
 		priv->write_reg(priv, C_CAN_TEST_REG, TEST_LBACK);
 	} else if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) {
 		/* silent mode : bus-monitoring mode */
-		priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_EIE |
-				CONTROL_SIE | CONTROL_IE | CONTROL_TEST);
+		priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_TEST);
 		priv->write_reg(priv, C_CAN_TEST_REG, TEST_SILENT);
-	} else
-		/* normal mode*/
-		priv->write_reg(priv, C_CAN_CTRL_REG,
-				CONTROL_EIE | CONTROL_SIE | CONTROL_IE);
+	}
 
 	/* configure message objects */
 	c_can_configure_msg_objects(dev);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-24 22:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-02 17:28 [PATCH v1] can: c_can: Enable interrupts only when initialization has been completed Oleksandr Tyshchenko
2014-04-24 22:07 ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).