158d6ea30SMatthew Wilcox /* lib/bitmap.c pulls in at least two other files. */
258d6ea30SMatthew Wilcox 
358d6ea30SMatthew Wilcox #include <linux/bitmap.h>
458d6ea30SMatthew Wilcox 
bitmap_clear(unsigned long * map,unsigned int start,int len)558d6ea30SMatthew Wilcox void bitmap_clear(unsigned long *map, unsigned int start, int len)
658d6ea30SMatthew Wilcox {
758d6ea30SMatthew Wilcox 	unsigned long *p = map + BIT_WORD(start);
858d6ea30SMatthew Wilcox 	const unsigned int size = start + len;
958d6ea30SMatthew Wilcox 	int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
1058d6ea30SMatthew Wilcox 	unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
1158d6ea30SMatthew Wilcox 
1258d6ea30SMatthew Wilcox 	while (len - bits_to_clear >= 0) {
1358d6ea30SMatthew Wilcox 		*p &= ~mask_to_clear;
1458d6ea30SMatthew Wilcox 		len -= bits_to_clear;
1558d6ea30SMatthew Wilcox 		bits_to_clear = BITS_PER_LONG;
1658d6ea30SMatthew Wilcox 		mask_to_clear = ~0UL;
1758d6ea30SMatthew Wilcox 		p++;
1858d6ea30SMatthew Wilcox 	}
1958d6ea30SMatthew Wilcox 	if (len) {
2058d6ea30SMatthew Wilcox 		mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
2158d6ea30SMatthew Wilcox 		*p &= ~mask_to_clear;
2258d6ea30SMatthew Wilcox 	}
2358d6ea30SMatthew Wilcox }
24