"Das U-Boot" Source Tree

riscv: define find_{first,next}_zero_bit in asm/bitops.h

These seem to be missing, and trying to build fastboot cmd without
them is causing errors due to these being missing.

Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Tested-by: E Shattow <lucent@gmail.com
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

authored by

Maxim Kochetkov and committed by
Leo Yu-Chi Liang
bbbb2ef4 e0495c91

+40
+40
arch/riscv/include/asm/bitops.h
··· 138 138 return k; 139 139 } 140 140 141 + static inline int find_next_zero_bit(void *addr, int size, int offset) 142 + { 143 + unsigned long *p = ((unsigned long *)addr) + (offset / BITS_PER_LONG); 144 + unsigned long result = offset & ~(BITS_PER_LONG - 1); 145 + unsigned long tmp; 146 + 147 + if (offset >= size) 148 + return size; 149 + size -= result; 150 + offset &= (BITS_PER_LONG - 1); 151 + if (offset) { 152 + tmp = *(p++); 153 + tmp |= ~0UL >> (BITS_PER_LONG - offset); 154 + if (size < BITS_PER_LONG) 155 + goto found_first; 156 + if (~tmp) 157 + goto found_middle; 158 + size -= BITS_PER_LONG; 159 + result += BITS_PER_LONG; 160 + } 161 + while (size & ~(BITS_PER_LONG - 1)) { 162 + tmp = *(p++); 163 + if (~tmp) 164 + goto found_middle; 165 + result += BITS_PER_LONG; 166 + size -= BITS_PER_LONG; 167 + } 168 + if (!size) 169 + return result; 170 + tmp = *p; 171 + 172 + found_first: 173 + tmp |= ~0UL << size; 174 + found_middle: 175 + return result + ffz(tmp); 176 + } 177 + 141 178 /* 142 179 * ffs: find first bit set. This is defined the same way as 143 180 * the libc and compiler builtin ffs routines, therefore ··· 157 194 #define hweight32(x) generic_hweight32(x) 158 195 #define hweight16(x) generic_hweight16(x) 159 196 #define hweight8(x) generic_hweight8(x) 197 + 198 + #define find_first_zero_bit(addr, size) \ 199 + find_next_zero_bit((addr), (size), 0) 160 200 161 201 #define test_and_set_bit __test_and_set_bit 162 202 #define test_and_clear_bit __test_and_clear_bit