Path: blob/master/drivers/firmware/efi/libstub/bitmap.c
26483 views
#include <linux/bitmap.h>12void __bitmap_set(unsigned long *map, unsigned int start, int len)3{4unsigned long *p = map + BIT_WORD(start);5const unsigned int size = start + len;6int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);7unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);89while (len - bits_to_set >= 0) {10*p |= mask_to_set;11len -= bits_to_set;12bits_to_set = BITS_PER_LONG;13mask_to_set = ~0UL;14p++;15}16if (len) {17mask_to_set &= BITMAP_LAST_WORD_MASK(size);18*p |= mask_to_set;19}20}2122void __bitmap_clear(unsigned long *map, unsigned int start, int len)23{24unsigned long *p = map + BIT_WORD(start);25const unsigned int size = start + len;26int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);27unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);2829while (len - bits_to_clear >= 0) {30*p &= ~mask_to_clear;31len -= bits_to_clear;32bits_to_clear = BITS_PER_LONG;33mask_to_clear = ~0UL;34p++;35}36if (len) {37mask_to_clear &= BITMAP_LAST_WORD_MASK(size);38*p &= ~mask_to_clear;39}40}414243