bitmap.c 599 B

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