From 6f61f098037b9b8b88a80d33814ecec26f112d51 Mon Sep 17 00:00:00 2001 From: Sritej Kanakadandi Venkata Rama Date: Mon, 18 Jun 2018 13:47:06 -0700 Subject: [PATCH] drivers: can: Set a initial state to the can device before HAL_CAN_Init As part of HAL_CAN_Init we check the initial state of the can handle. Setting it to HAL_CAN_STATE_RESET as an initial state to start the Init properly. Resolves: #8416 Coverity-CID: 186580 Signed-off-by: Sritej Kanakadandi Venkata Rama --- drivers/can/stm32_can.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/can/stm32_can.c b/drivers/can/stm32_can.c index 6fd79b1ef7c..3524f228668 100644 --- a/drivers/can/stm32_can.c +++ b/drivers/can/stm32_can.c @@ -254,6 +254,8 @@ int can_stm32_runtime_configure(struct device *dev, enum can_mode mode, hcan.Init.BS2 = bs2; hcan.Init.Prescaler = prescaler; + hcan.State = HAL_CAN_STATE_RESET; + hal_ret = HAL_CAN_Init(&hcan); if (hal_ret != HAL_OK) { SYS_LOG_ERR("HAL_CAN_Init failed: %d", hal_ret);