Skip to content

Commit

Permalink
fix(esp_driver_spi): Make spi_bus_free() exit early on issues
Browse files Browse the repository at this point in the history
If for example there are still devices configured on the bus
spi_bus_free() will report that with ESP_ERR_INVALID_STATE, but not
before it frees all other things like IO and DMA. This means that
after the function exits any other task that is still running and
using those devices will all of a sudden stop working (and probably
crash the device).

This commit prevents that situation by making the function return
early so it can be called again safely later when all devices have
been removed.
  • Loading branch information
MathyV committed May 25, 2024
1 parent 003f3bb commit 397aa28
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions components/esp_driver_spi/src/gpspi/spi_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,9 @@ esp_err_t spi_bus_free(spi_host_device_t host_id)

if (ctx->destroy_func) {
err = ctx->destroy_func(ctx->destroy_arg);
if (err != ESP_OK) {
return err;
}
}
spicommon_bus_free_io_cfg(&bus_attr->bus_cfg);

Expand Down

0 comments on commit 397aa28

Please sign in to comment.