Skip to content

Commit

Permalink
can: tcan4x5x: tcan4x5x_init(): fix initialization - clear MRAM befor…
Browse files Browse the repository at this point in the history
…e entering Normal Mode

This patch prevents a potentially destructive race condition. The
device is fully operational on the bus after entering Normal Mode, so
zeroing the MRAM after entering this mode may lead to loss of
information, e.g. new received messages.

This patch fixes the problem by first initializing the MRAM, then
bringing the device into Normale Mode.

Fixes: 5443c22 ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
Link: https://lore.kernel.org/r/20210226163440.313628-1-torin@maxiluxsystems.com
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Torin Cooper-Bennun <torin@maxiluxsystems.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Torin Cooper-Bennun authored and marckleinebudde committed Mar 1, 2021
1 parent e940e08 commit 2712625
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/can/m_can/tcan4x5x-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,14 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)
if (ret)
return ret;

/* Zero out the MCAN buffers */
m_can_init_ram(cdev);

ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG,
TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL);
if (ret)
return ret;

/* Zero out the MCAN buffers */
m_can_init_ram(cdev);

return ret;
}

Expand Down

0 comments on commit 2712625

Please sign in to comment.