Skip to contentSkip to conversation

Rename bitmap_clear to bitmap_zero, remove CLEAR_BITMAP

PATCH Rusty Russell 1 participant 1 message Apr 8, 2004

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

OK, was looking through cpumask_t usage, and this confused me. Useless churn? Maybe.

Name: Rename bitmap_clear to bitmap_zero, remove CLEAR_BITMAP
Status: Trivial

clear_bit(n, addr) clears the nth bit. test_and_clear_bit(n, addr) clears the nth bit. cpu_clear(n, cpumask) clears the nth bit (vs. cpus_clear()). bitmap_clear(bitmap, n) clears out all the bits up to n.

Moreover, there's a CLEAR_BITMAP() in linux/types.h which bitmap_clear() is a wrapper for.

Rename bitmap_clear to bitmap_zero, which is harder to confuse (yes, it bit me), and make everyone use it.

arch/ia64/sn/kernel/sn2/sn2_smp.c +1 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5891-linux-2.6.5/arch/ia64/sn/kernel/sn2/sn2_smp.c .5891-linux-2.6.5.updated/arch/ia64/sn/kernel/sn2/sn2_smp.c
@@ -91,7 +91,7 @@ sn2_global_tlb_purge (unsigned long star
 	short			nasids[NR_NODES], nix;
 	DECLARE_BITMAP(nodes_flushed, NR_NODES);
 
-	CLEAR_BITMAP(nodes_flushed, NR_NODES);
+	bitmap_zero(nodes_flushed, NR_NODES);
 
 	i = 0;
 
drivers/atm/lanai.c +3 -3
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5891-linux-2.6.5/drivers/atm/lanai.c .5891-linux-2.6.5.updated/drivers/atm/lanai.c
@@ -1743,7 +1743,7 @@ static void run_service(struct lanai_dev
 		read_lock(&vcc_sklist_lock);
 		vci_bitfield_iterate(lanai, lanai->transmit_ready,
 		    iter_transmit);
-		CLEAR_BITMAP(&lanai->transmit_ready, NUM_VCI);
+		bitmap_zero(&lanai->transmit_ready, NUM_VCI);
 		read_unlock(&vcc_sklist_lock);
 	}
 }
@@ -2158,8 +2158,8 @@ static int __init lanai_dev_open(struct 
 	/* Basic device fields */
 	lanai->number = atmdev->number;
 	lanai->num_vci = NUM_VCI;
-	CLEAR_BITMAP(&lanai->backlog_vccs, NUM_VCI);
-	CLEAR_BITMAP(&lanai->transmit_ready, NUM_VCI);
+	bitmap_zero(&lanai->backlog_vccs, NUM_VCI);
+	bitmap_zero(&lanai->transmit_ready, NUM_VCI);
 	lanai->naal0 = 0;
 #ifdef USE_POWERDOWN
 	lanai->nbound = 0;
drivers/ieee1394/ieee1394_types.h +1 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5891-linux-2.6.5/drivers/ieee1394/ieee1394_types.h .5891-linux-2.6.5.updated/drivers/ieee1394/ieee1394_types.h
@@ -24,7 +24,7 @@ struct hpsb_tlabel_pool {
 
 #define HPSB_TPOOL_INIT(_tp)			\
 do {						\
-	CLEAR_BITMAP((_tp)->pool, 64);		\
+	bitmap_zero((_tp)->pool, 64);		\
 	spin_lock_init(&(_tp)->lock);		\
 	(_tp)->next = 0;			\
 	(_tp)->allocations = 0;			\
drivers/scsi/atari_NCR5380.c +2 -2
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5891-linux-2.6.5/drivers/scsi/atari_NCR5380.c .5891-linux-2.6.5.updated/drivers/scsi/atari_NCR5380.c
@@ -329,7 +329,7 @@ static void __init init_tags( void )
     for( target = 0; target < 8; ++target ) {
 	for( lun = 0; lun < 8; ++lun ) {
 	    ta = &TagAlloc[target][lun];
-	    CLEAR_BITMAP( ta->allocated, MAX_TAGS );
+	    bitmap_zero(ta->allocated, MAX_TAGS);
 	    ta->nr_allocated = 0;
 	    /* At the beginning, assume the maximum queue size we could
 	     * support (MAX_TAGS). This value will be decreased if the target
@@ -438,7 +438,7 @@ static void free_all_tags( void )
     for( target = 0; target < 8; ++target ) {
 	for( lun = 0; lun < 8; ++lun ) {
 	    ta = &TagAlloc[target][lun];
-	    CLEAR_BITMAP( ta->allocated, MAX_TAGS );
+	    bitmap_zero(ta->allocated, MAX_TAGS);
 	    ta->nr_allocated = 0;
 	}
     }
include/asm-generic/cpumask_array.h +1 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5891-linux-2.6.5/include/asm-generic/cpumask_array.h .5891-linux-2.6.5.updated/include/asm-generic/cpumask_array.h
@@ -16,7 +16,7 @@
 
 #define cpus_and(dst,src1,src2)	bitmap_and((dst).mask,(src1).mask, (src2).mask, NR_CPUS)
 #define cpus_or(dst,src1,src2)	bitmap_or((dst).mask, (src1).mask, (src2).mask, NR_CPUS)
-#define cpus_clear(map)		bitmap_clear((map).mask, NR_CPUS)
+#define cpus_clear(map)		bitmap_zero((map).mask, NR_CPUS)
 #define cpus_complement(map)	bitmap_complement((map).mask, NR_CPUS)
 #define cpus_equal(map1, map2)	bitmap_equal((map1).mask, (map2).mask, NR_CPUS)
 #define cpus_empty(map)		bitmap_empty(map.mask, NR_CPUS)
include/asm-i386/mpspec.h +1 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5891-linux-2.6.5/include/asm-i386/mpspec.h .5891-linux-2.6.5.updated/include/asm-i386/mpspec.h
@@ -52,7 +52,7 @@ typedef struct physid_mask physid_mask_t
 
 #define physids_and(dst, src1, src2)		bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
 #define physids_or(dst, src1, src2)		bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
-#define physids_clear(map)			bitmap_clear((map).mask, MAX_APICS)
+#define physids_clear(map)			bitmap_zero((map).mask, MAX_APICS)
 #define physids_complement(map)			bitmap_complement((map).mask, MAX_APICS)
 #define physids_empty(map)			bitmap_empty((map).mask, MAX_APICS)
 #define physids_equal(map1, map2)		bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
include/asm-x86_64/mpspec.h +1 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5891-linux-2.6.5/include/asm-x86_64/mpspec.h .5891-linux-2.6.5.updated/include/asm-x86_64/mpspec.h
@@ -211,7 +211,7 @@ typedef struct physid_mask physid_mask_t
 
 #define physids_and(dst, src1, src2)		bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
 #define physids_or(dst, src1, src2)		bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
-#define physids_clear(map)			bitmap_clear((map).mask, MAX_APICS)
+#define physids_clear(map)			bitmap_zero((map).mask, MAX_APICS)
 #define physids_complement(map)			bitmap_complement((map).mask, MAX_APICS)
 #define physids_empty(map)			bitmap_empty((map).mask, MAX_APICS)
 #define physids_equal(map1, map2)		bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
include/linux/bitmap.h +2 -2
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5891-linux-2.6.5/include/linux/bitmap.h .5891-linux-2.6.5.updated/include/linux/bitmap.h
@@ -16,9 +16,9 @@ int bitmap_equal(const unsigned long *bi
 			unsigned long *bitmap2, int bits);
 void bitmap_complement(unsigned long *bitmap, int bits);
 
-static inline void bitmap_clear(unsigned long *bitmap, int bits)
+static inline void bitmap_zero(unsigned long *bitmap, int bits)
 {
-	CLEAR_BITMAP((unsigned long *)bitmap, bits);
+	memset(bitmap, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long))
 }
 
 static inline void bitmap_fill(unsigned long *bitmap, int bits)
include/linux/types.h +0 -2
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5891-linux-2.6.5/include/linux/types.h .5891-linux-2.6.5.updated/include/linux/types.h
@@ -8,8 +8,6 @@
 	(((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
 #define DECLARE_BITMAP(name,bits) \
 	unsigned long name[BITS_TO_LONGS(bits)]
-#define CLEAR_BITMAP(name,bits) \
-	memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long))
 #endif
 
 #include <linux/posix_types.h>
lib/bitmap.c +3 -3
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5891-linux-2.6.5/lib/bitmap.c .5891-linux-2.6.5.updated/lib/bitmap.c
@@ -78,7 +78,7 @@ void bitmap_shift_right(unsigned long *d
 	DECLARE_BITMAP(__shr_tmp, MAX_BITMAP_BITS);
 
 	BUG_ON(bits > MAX_BITMAP_BITS);
-	bitmap_clear(__shr_tmp, bits);
+	bitmap_zero(__shr_tmp, bits);
 	for (k = 0; k < bits - shift; ++k)
 		if (test_bit(k + shift, src))
 			set_bit(k, __shr_tmp);
@@ -93,7 +93,7 @@ void bitmap_shift_left(unsigned long *ds
 	DECLARE_BITMAP(__shl_tmp, MAX_BITMAP_BITS);
 
 	BUG_ON(bits > MAX_BITMAP_BITS);
-	bitmap_clear(__shl_tmp, bits);
+	bitmap_zero(__shl_tmp, bits);
 	for (k = bits; k >= shift; --k)
 		if (test_bit(k - shift, src))
 			set_bit(k, __shl_tmp);
@@ -223,7 +223,7 @@ int bitmap_parse(const char __user *ubuf
 	int c, old_c, totaldigits, ndigits, nchunks, nbits;
 	u32 chunk;
 
-	bitmap_clear(maskp, nmaskbits);
+	bitmap_zero(maskp, nmaskbits);
 
 	nchunks = nbits = totaldigits = c = 0;
 	do {
mm/page_alloc.c +1 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5891-linux-2.6.5/mm/page_alloc.c .5891-linux-2.6.5.updated/mm/page_alloc.c
@@ -1209,7 +1209,7 @@ static void __init build_zonelists(pg_da
 	local_node = pgdat->node_id;
 	load = numnodes;
 	prev_node = local_node;
-	CLEAR_BITMAP(used_mask, MAX_NUMNODES);
+	bitmap_zero(used_mask, MAX_NUMNODES);
 	while ((node = find_next_best_node(local_node, used_mask)) >= 0) {
 		/*
 		 * We don't want to pressure a particular node.
Signature · 1 line
Anyone who quotes me in their signature is an idiot -- Rusty Russell