@@ -708,82 +708,6 @@ void bitmap_fold(unsigned long *dst, const unsigned long *orig,
708708}
709709#endif /* CONFIG_NUMA */
710710
711- /*
712- * Common code for bitmap_*_region() routines.
713- * bitmap: array of unsigned longs corresponding to the bitmap
714- * pos: the beginning of the region
715- * order: region size (log base 2 of number of bits)
716- * reg_op: operation(s) to perform on that region of bitmap
717- *
718- * Can set, verify and/or release a region of bits in a bitmap,
719- * depending on which combination of REG_OP_* flag bits is set.
720- *
721- * A region of a bitmap is a sequence of bits in the bitmap, of
722- * some size '1 << order' (a power of two), aligned to that same
723- * '1 << order' power of two.
724- *
725- * Return: 1 if REG_OP_ISFREE succeeds (region is all zero bits).
726- * 0 in all other cases and reg_ops.
727- */
728-
729- enum {
730- REG_OP_ISFREE , /* true if region is all zero bits */
731- REG_OP_ALLOC , /* set all bits in region */
732- REG_OP_RELEASE , /* clear all bits in region */
733- };
734-
735- static int __reg_op (unsigned long * bitmap , unsigned int pos , int order , int reg_op )
736- {
737- int nbits_reg ; /* number of bits in region */
738- int index ; /* index first long of region in bitmap */
739- int offset ; /* bit offset region in bitmap[index] */
740- int nlongs_reg ; /* num longs spanned by region in bitmap */
741- int nbitsinlong ; /* num bits of region in each spanned long */
742- unsigned long mask ; /* bitmask for one long of region */
743- int i ; /* scans bitmap by longs */
744- int ret = 0 ; /* return value */
745-
746- /*
747- * Either nlongs_reg == 1 (for small orders that fit in one long)
748- * or (offset == 0 && mask == ~0UL) (for larger multiword orders.)
749- */
750- nbits_reg = 1 << order ;
751- index = pos / BITS_PER_LONG ;
752- offset = pos - (index * BITS_PER_LONG );
753- nlongs_reg = BITS_TO_LONGS (nbits_reg );
754- nbitsinlong = min (nbits_reg , BITS_PER_LONG );
755-
756- /*
757- * Can't do "mask = (1UL << nbitsinlong) - 1", as that
758- * overflows if nbitsinlong == BITS_PER_LONG.
759- */
760- mask = (1UL << (nbitsinlong - 1 ));
761- mask += mask - 1 ;
762- mask <<= offset ;
763-
764- switch (reg_op ) {
765- case REG_OP_ISFREE :
766- for (i = 0 ; i < nlongs_reg ; i ++ ) {
767- if (bitmap [index + i ] & mask )
768- goto done ;
769- }
770- ret = 1 ; /* all bits in region free (zero) */
771- break ;
772-
773- case REG_OP_ALLOC :
774- for (i = 0 ; i < nlongs_reg ; i ++ )
775- bitmap [index + i ] |= mask ;
776- break ;
777-
778- case REG_OP_RELEASE :
779- for (i = 0 ; i < nlongs_reg ; i ++ )
780- bitmap [index + i ] &= ~mask ;
781- break ;
782- }
783- done :
784- return ret ;
785- }
786-
787711/**
788712 * bitmap_find_free_region - find a contiguous aligned mem region
789713 * @bitmap: array of unsigned longs corresponding to the bitmap
0 commit comments