提交 27126252 编写于 作者: T Torin Cooper-Bennun 提交者: Marc Kleine-Budde

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: 5443c226 ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
Link: https://lore.kernel.org/r/20210226163440.313628-1-torin@maxiluxsystems.comSuggested-by: NMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: NTorin Cooper-Bennun <torin@maxiluxsystems.com>
Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
上级 e940e089
...@@ -237,14 +237,14 @@ static int tcan4x5x_init(struct m_can_classdev *cdev) ...@@ -237,14 +237,14 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)
if (ret) if (ret)
return ret; return ret;
/* Zero out the MCAN buffers */
m_can_init_ram(cdev);
ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG, ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG,
TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL); TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL);
if (ret) if (ret)
return ret; return ret;
/* Zero out the MCAN buffers */
m_can_init_ram(cdev);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册