Skip to content

Commit ba47ad9

Browse files
committed
fix bug where hw_is_claimed claims - which it should not do
1 parent c6c4eeb commit ba47ad9

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

src/rp2_common/hardware_claim/claim.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,8 @@ void hw_claim_unlock(uint32_t save) {
1414
spin_unlock(spin_lock_instance(PICO_SPINLOCK_ID_HARDWARE_CLAIM), save);
1515
}
1616

17-
bool hw_is_claimed(uint8_t *bits, uint bit_index) {
18-
bool rc;
19-
uint32_t save = hw_claim_lock();
20-
if (bits[bit_index >> 3u] & (1u << (bit_index & 7u))) {
21-
rc = false;
22-
} else {
23-
bits[bit_index >> 3u] |= (uint8_t)(1u << (bit_index & 7u));
24-
rc = true;
25-
}
26-
hw_claim_unlock(save);
27-
return rc;
17+
bool hw_is_claimed(const uint8_t *bits, uint bit_index) {
18+
return bits[bit_index >> 3u] & (1u << (bit_index & 7u));
2819
}
2920

3021
void hw_claim_or_assert(uint8_t *bits, uint bit_index, const char *message) {

src/rp2_common/hardware_claim/include/hardware/claim.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ int hw_claim_unused_from_range(uint8_t *bits, bool required, uint bit_lsb, uint
6565
* The resource ownership is indicated by the bit_index bit in an array of bits.
6666
*
6767
* \param bits pointer to an array of bits (8 bits per byte)
68-
* \param bit_index resource to unclaim (bit index into array of bits)
68+
* \param bit_index resource to check (bit index into array of bits)
6969
* \return true if the resource is claimed
7070
*/
71-
bool hw_is_claimed(uint8_t *bits, uint bit_index);
71+
bool hw_is_claimed(const uint8_t *bits, uint bit_index);
7272

7373
/*! \brief Atomically unclaim a resource
7474
* \ingroup hardware_claim

0 commit comments

Comments
 (0)