Преглед на файлове

Merge branch 'fix/fixed_polling_api_lock_logic' into 'master'

fix(spi_master): fixed polling_start break common resouce when error

See merge request espressif/esp-idf!25593
Wan Lei преди 2 години
родител
ревизия
cff1631ac7
променени са 2 файла, в които са добавени 10 реда и са изтрити 2 реда
  1. 8 2
      components/driver/spi/gpspi/spi_master.c
  2. 2 0
      examples/network/.build-test-rules.yml

+ 8 - 2
components/driver/spi/gpspi/spi_master.c

@@ -1043,7 +1043,8 @@ esp_err_t SPI_MASTER_ISR_ATTR spi_device_polling_start(spi_device_handle_t handl
     SPI_CHECK(!spi_bus_device_is_polling(handle), "Cannot send polling transaction while the previous polling transaction is not terminated.", ESP_ERR_INVALID_STATE );
 
     spi_host_t *host = handle->host;
-    ret = setup_priv_desc(trans_desc, &host->cur_trans_buf, (host->bus_attr->dma_enabled));
+    spi_trans_priv_t priv_polling_trans;
+    ret = setup_priv_desc(trans_desc, &priv_polling_trans, (host->bus_attr->dma_enabled));
     if (ret!=ESP_OK) return ret;
 
     /* If device_acquiring_lock is set to handle, it means that the user has already
@@ -1059,10 +1060,15 @@ esp_err_t SPI_MASTER_ISR_ATTR spi_device_polling_start(spi_device_handle_t handl
     } else {
         ret = spi_bus_lock_wait_bg_done(handle->dev_lock, ticks_to_wait);
     }
-    if (ret != ESP_OK) return ret;
+    if (ret != ESP_OK) {
+        uninstall_priv_desc(&priv_polling_trans);
+        ESP_LOGE(SPI_TAG, "polling can't get buslock");
+        return ret;
+    }
 
     //Polling, no interrupt is used.
     host->polling = true;
+    host->cur_trans_buf = priv_polling_trans;
 
     ESP_LOGV(SPI_TAG, "polling trans");
     spi_new_trans(handle, &host->cur_trans_buf);

+ 2 - 0
examples/network/.build-test-rules.yml

@@ -4,6 +4,8 @@ examples/network/bridge:
   disable_test:
     - if: IDF_TARGET != "esp32"
       reason: Generic functionality, no need to be run on specific targets
+  depends_filepatterns:
+    - components/driver/spi/**/*
 
 examples/network/eth2ap:
   disable: