static bool axmap_handler_topdown(struct axmap *axmap, uint64_t bit_nr,
bool (*func)(struct axmap_level *, unsigned long, unsigned int, void *))
{
- struct axmap_level *al;
int i;
for (i = axmap->nr_levels - 1; i >= 0; i--) {
unsigned long offset = index >> UNIT_SHIFT;
unsigned int bit = index & BLOCKS_PER_UNIT_MASK;
- al = &axmap->levels[i];
-
- if (func(al, offset, bit, NULL))
+ if (func(&axmap->levels[i], offset, bit, NULL))
return true;
}
for (i = level; i >= 0; i--) {
struct axmap_level *al = &axmap->levels[i];
- /*
- * Clear 'ret', this is a bug condition.
- */
- if (index >= al->map_size) {
- ret = -1ULL;
- break;
- }
+ if (index >= al->map_size)
+ goto err;
for (j = index; j < al->map_size; j++) {
if (al->map[j] == -1UL)
if (ret < axmap->nr_bits)
return ret;
+err:
return (uint64_t) -1ULL;
}