Merge branch 'fix/spi_buslock_unregister_issue_v5.2' into 'release/v5.2'

fix(hw_support): spi buslock fix unregister dev api issue (v5.2)

See merge request espressif/esp-idf!51476
This commit is contained in:
Jiang Jiang Jian
2026-08-11 14:19:11 +08:00
6 changed files with 32 additions and 5 deletions
+1
View File
@@ -510,6 +510,7 @@ esp_err_t spi_bus_remove_device(spi_device_handle_t handle)
//catch design errors and aren't meant to be triggered during normal operation.
SPI_CHECK(uxQueueMessagesWaiting(handle->trans_queue)==0, "Have unfinished transactions", ESP_ERR_INVALID_STATE);
SPI_CHECK(handle->host->cur_cs == DEV_NUM_MAX || handle->host->device[handle->host->cur_cs] != handle, "Have unfinished transactions", ESP_ERR_INVALID_STATE);
SPI_CHECK(handle->host->device_acquiring_lock != handle, "Device has acquired the bus", ESP_ERR_INVALID_STATE);
if (handle->ret_queue) {
SPI_CHECK(uxQueueMessagesWaiting(handle->ret_queue)==0, "Have unfinished transactions", ESP_ERR_INVALID_STATE);
}
+14 -1
View File
@@ -687,8 +687,16 @@ void spi_bus_lock_unregister_dev(spi_bus_lock_dev_handle_t dev_handle)
spi_bus_lock_t* lock = dev_handle->parent;
BUS_LOCK_DEBUG_EXECUTE_CHECK(atomic_load(&lock->dev[id]) == (intptr_t)dev_handle);
BUS_LOCK_DEBUG_EXECUTE_CHECK(lock->acquiring_dev != dev_handle);
BUS_LOCK_DEBUG_EXECUTE_CHECK((lock_status_fetch(lock) & dev_handle->mask) == 0);
if (lock->last_dev == dev_handle) lock->last_dev = NULL;
if (lock->last_dev == dev_handle) {
lock->last_dev = NULL;
}
if (lock->acquiring_dev == dev_handle) {
lock->acquiring_dev = NULL;
lock->acq_dev_bg_active = false;
}
atomic_store(&lock->dev[id], (intptr_t)NULL);
if (dev_handle->semphr) {
@@ -715,6 +723,11 @@ void spi_bus_lock_set_bg_control(spi_bus_lock_handle_t lock, bg_ctrl_func_t bg_e
lock->bg_arg = arg;
}
IRAM_ATTR spi_bus_lock_handle_t spi_bus_lock_get_parent(spi_bus_lock_dev_handle_t dev_handle)
{
return (dev_handle ? dev_handle->parent : NULL);
}
IRAM_ATTR int spi_bus_lock_get_dev_id(spi_bus_lock_dev_handle_t dev_handle)
{
return (dev_handle? dev_lock_get_id(dev_handle): -1);