summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorTorin Cooper-Bennun <torin@maxiluxsystems.com>2021-02-26 16:34:41 +0000
committerMarc Kleine-Budde <mkl@pengutronix.de>2021-03-01 11:45:15 +0100
commit2712625200ed69c642b9abc3a403830c4643364c (patch)
tree6ea04b92858aec265cfc486c670023f6f6617997 /drivers/net
parente940e0895a82c6fbaa259f2615eb52b57ee91a7e (diff)
downloadlinux-stable-2712625200ed69c642b9abc3a403830c4643364c.tar.gz
linux-stable-2712625200ed69c642b9abc3a403830c4643364c.tar.bz2
linux-stable-2712625200ed69c642b9abc3a403830c4643364c.zip
can: tcan4x5x: tcan4x5x_init(): fix initialization - clear MRAM before 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: 5443c226ba91 ("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>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/can/m_can/tcan4x5x-core.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
index b7caec769ddb..4147cecfbbd6 100644
--- a/drivers/net/can/m_can/tcan4x5x-core.c
+++ b/drivers/net/can/m_can/tcan4x5x-core.c
@@ -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;
}