Skip to content

Commit

Permalink
drivers: can: sja1000: do not attempt to sleep in IRQ context
Browse files Browse the repository at this point in the history
The can_sja1000_handle_error_warning_irq() function should only attempt to
start bus-off recovery, but not wait for the result.

Fixes: #63712

Signed-off-by: Henrik Brix Andersen <[email protected]>
  • Loading branch information
henrikbrixandersen authored and jhedberg committed Oct 9, 2023
1 parent f09b67b commit fc078f9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/can/can_sja1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ static inline int can_sja1000_enter_reset_mode(const struct device *dev)
return 0;
}

static inline void can_sja1000_leave_reset_mode_nowait(const struct device *dev)
{
uint8_t mod;

mod = can_sja1000_read_reg(dev, CAN_SJA1000_MOD);
can_sja1000_write_reg(dev, CAN_SJA1000_MOD, mod & ~(CAN_SJA1000_MOD_RM));
}

static inline int can_sja1000_leave_reset_mode(const struct device *dev)
{
int retries = CAN_SJA1000_RESET_MODE_RETRIES;
Expand Down Expand Up @@ -590,7 +598,7 @@ static void can_sja1000_handle_error_warning_irq(const struct device *dev)
can_sja1000_tx_done(dev, -ENETUNREACH);
#ifdef CONFIG_CAN_AUTO_BUS_OFF_RECOVERY
if (data->started) {
(void)can_sja1000_leave_reset_mode(dev);
can_sja1000_leave_reset_mode_nowait(dev);
}
#endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
} else if ((sr & CAN_SJA1000_SR_ES) != 0) {
Expand Down

0 comments on commit fc078f9

Please sign in to comment.