^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* lib/bitmap.c pulls in at least two other files. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/bitmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) void bitmap_clear(unsigned long *map, unsigned int start, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) unsigned long *p = map + BIT_WORD(start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) const unsigned int size = start + len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) while (len - bits_to_clear >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *p &= ~mask_to_clear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) len -= bits_to_clear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) bits_to_clear = BITS_PER_LONG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) mask_to_clear = ~0UL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) p++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) if (len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *p &= ~mask_to_clear;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }