tftSetup: don't claim the SPI bus after a timed-out take (#12025)

ReentrantSpiLock::lock(uint32_t) recorded the calling thread as owner
with depth 1 whether or not spiLock->lock(timeout) succeeded. After a
timeout the thread's next lock() then took the reentrant path and skipped
the real acquire, and the matching unlock() released a semaphore the
thread never held, so device-ui and the radio could both reach the bus.

Record ownership only when the take succeeds, and return false without
touching owner or depth when it times out.

Found while reviewing CodeRabbit's note on #12024.



Claude-Session: https://claude.ai/code/session_01REkPVFh6kvG4AZJ5A8AtM9

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jonathan BennettandClaude Opus 5.5 authored and GitHub committed 2026-09-30 20:53:42 +00:00
1 parent 7fe3176a40
commit 790944a75e
1 file changed
+5 -2
+5 -2
View File
@@ -280,10 +280,13 @@ class ReentrantSpiLock : public ISpiLock
depth++;
return true;
}
bool result = spiLock->lock(timeout);
// A timed-out take holds nothing: claiming ownership anyway would let this thread's next
// lock() skip the real acquire, and its unlock() release a bus it never held.
if (!spiLock->lock(timeout))
return false;
owner = self;
depth = 1;
return result;
return true;
}
void unlock(void) override