@ -803,7 +803,7 @@ unsigned int bitmap_ord_to_pos(const unsigned long *buf, unsigned int ord, unsig
* @ src : subset to be remapped
* @ src : subset to be remapped
* @ old : defines domain of map
* @ old : defines domain of map
* @ new : defines range of map
* @ new : defines range of map
* @ bits : number of bits in each of these bitmaps
* @ n bits: number of bits in each of these bitmaps
*
*
* Let @ old and @ new define a mapping of bit positions , such that
* Let @ old and @ new define a mapping of bit positions , such that
* whatever position is held by the n - th set bit in @ old is mapped
* whatever position is held by the n - th set bit in @ old is mapped
@ -831,22 +831,22 @@ unsigned int bitmap_ord_to_pos(const unsigned long *buf, unsigned int ord, unsig
*/
*/
void bitmap_remap ( unsigned long * dst , const unsigned long * src ,
void bitmap_remap ( unsigned long * dst , const unsigned long * src ,
const unsigned long * old , const unsigned long * new ,
const unsigned long * old , const unsigned long * new ,
int bits )
unsigned int n bits)
{
{
int oldbit , w ;
unsigned int oldbit , w ;
if ( dst = = src ) /* following doesn't handle inplace remaps */
if ( dst = = src ) /* following doesn't handle inplace remaps */
return ;
return ;
bitmap_zero ( dst , bits ) ;
bitmap_zero ( dst , n bits) ;
w = bitmap_weight ( new , bits ) ;
w = bitmap_weight ( new , n bits) ;
for_each_set_bit ( oldbit , src , bits ) {
for_each_set_bit ( oldbit , src , n bits) {
int n = bitmap_pos_to_ord ( old , oldbit , bits ) ;
int n = bitmap_pos_to_ord ( old , oldbit , n bits) ;
if ( n < 0 | | w = = 0 )
if ( n < 0 | | w = = 0 )
set_bit ( oldbit , dst ) ; /* identity map */
set_bit ( oldbit , dst ) ; /* identity map */
else
else
set_bit ( bitmap_ord_to_pos ( new , n % w , bits ) , dst ) ;
set_bit ( bitmap_ord_to_pos ( new , n % w , n bits) , dst ) ;
}
}
}
}
EXPORT_SYMBOL ( bitmap_remap ) ;
EXPORT_SYMBOL ( bitmap_remap ) ;