mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-20 06:07:59 +00:00
usb: fix 'find_next_bit'
Return correct offset for sizes over machine word size. Fixes #2013
This commit is contained in:
parent
4e9aeb45ea
commit
b6bc7e0486
@ -426,14 +426,16 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
|
|||||||
|
|
||||||
for (; offset < size; offset++)
|
for (; offset < size; offset++)
|
||||||
if (addr[i] & (1UL << offset))
|
if (addr[i] & (1UL << offset))
|
||||||
return offset;
|
return offset + (i * BITS_PER_LONG);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long find_next_zero_bit_le(const void *addr,
|
long find_next_zero_bit_le(const void *addr,
|
||||||
unsigned long size, unsigned long offset)
|
unsigned long size, unsigned long offset)
|
||||||
{
|
{
|
||||||
|
static unsigned cnt = 0;
|
||||||
unsigned long max_size = sizeof(long) * 8;
|
unsigned long max_size = sizeof(long) * 8;
|
||||||
if (offset >= max_size) {
|
if (offset >= max_size) {
|
||||||
PWRN("Offset greater max size");
|
PWRN("Offset greater max size");
|
||||||
@ -444,7 +446,8 @@ long find_next_zero_bit_le(const void *addr,
|
|||||||
if (!(*(unsigned long*)addr & (1L << offset)))
|
if (!(*(unsigned long*)addr & (1L << offset)))
|
||||||
return offset;
|
return offset;
|
||||||
|
|
||||||
PERR("No zero bit findable");
|
lx_log(DEBUG_TRACE, "No zero bit findable %u", cnt++);
|
||||||
|
|
||||||
return offset + size;
|
return offset + size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user