1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-20 10:43:48 +01:00

Merge branch 'integration' into memory_api

This commit is contained in:
J. Nick Koston
2025-09-28 18:54:40 -05:00

View File

@@ -382,9 +382,10 @@ TransferRequest *USBClient::get_trq_() {
trq->transfer->device_handle = this->device_handle_; trq->transfer->device_handle = this->device_handle_;
return trq; return trq;
} }
// Another thread claimed this slot, retry with updated mask // CAS failed - another thread modified the bitmask
// Don't increment i - retry the same slot with the updated mask // Restart search from the beginning with the updated mask
mask = expected; mask = this->trq_in_use_.load(std::memory_order_relaxed);
i = 0;
} }
ESP_LOGE(TAG, "All %d transfer slots in use", MAX_REQUESTS); ESP_LOGE(TAG, "All %d transfer slots in use", MAX_REQUESTS);
@@ -542,7 +543,7 @@ void USBClient::release_trq(TransferRequest *trq) {
// Atomically clear bit i to mark slot as available // Atomically clear bit i to mark slot as available
// fetch_and with inverted bitmask clears the bit atomically // fetch_and with inverted bitmask clears the bit atomically
uint16_t bit = 1U << index; uint16_t bit = 1U << index;
this->trq_in_use_.fetch_and(~bit, std::memory_order_release); this->trq_in_use_.fetch_and(static_cast<uint16_t>(~bit), std::memory_order_release);
} }
} // namespace usb_host } // namespace usb_host