Skip to contentSkip to conversation

sctp: use bitmap_weight

PATCH Applied Akinobu Mita 5 participants 5 messages Nov 17, 2012 – Nov 18, 2012

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

PATCH 1/1 sctp: use bitmap_weight

Use bitmap_weight to count the total number of bits set in bitmap.

---
 net/sctp/tsnmap.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
net/sctp/tsnmap.c +2 -6
index b5fb7c4..5f25e0c 100644
@@ -272,7 +272,7 @@ __u16 sctp_tsnmap_pending(struct sctp_tsnmap *map)
 	__u32 max_tsn = map->max_tsn_seen;
 	__u32 base_tsn = map->base_tsn;
 	__u16 pending_data;
-	u32 gap, i;
+	u32 gap;
 
 	pending_data = max_tsn - cum_tsn;
 	gap = max_tsn - base_tsn;
@@ -280,11 +280,7 @@ __u16 sctp_tsnmap_pending(struct sctp_tsnmap *map)
 	if (gap = 0 || gap >= map->len)
 		goto out;
 
-	for (i = 0; i < gap+1; i++) {
-		if (test_bit(i, map->tsn_map))
-			pending_data--;
-	}
-
+	pending_data -= bitmap_weight(map->tsn_map, gap + 1);
 out:
 	return pending_data;
 }
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH 1/1 sound: use bitmap_weight

Use bitmap_weight to count the total number of bits set in bitmap.

---
 sound/usb/endpoint.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)
sound/usb/endpoint.c +1 -6
index 34de6f2..51a9aa3 100644
@@ -485,15 +485,10 @@ __exit_unlock:
 static int wait_clear_urbs(struct snd_usb_endpoint *ep)
 {
 	unsigned long end_time = jiffies + msecs_to_jiffies(1000);
-	unsigned int i;
 	int alive;
 
 	do {
-		alive = 0;
-		for (i = 0; i < ep->nurbs; i++)
-			if (test_bit(i, &ep->active_mask))
-				alive++;
-
+		alive = bitmap_weight(&ep->active_mask, ep->nurbs);
 		if (!alive)
 			break;
 
Applied
#2 lore raw

Re: [PATCH] sound: use bitmap_weight

At Fri, 16 Nov 2012 23:35:16 -0800,

Quoted 4 lines · Joe Perches

Use bitmap_weight to count the total number of bits set in bitmap.

Thanks, applied.

Takashi

Quoted 27 lines
---
 sound/usb/endpoint.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)
sound/usb/endpoint.c +1 -6
index 34de6f2..51a9aa3 100644
@@ -485,15 +485,10 @@ __exit_unlock:
 static int wait_clear_urbs(struct snd_usb_endpoint *ep)
 {
 	unsigned long end_time = jiffies + msecs_to_jiffies(1000);
-	unsigned int i;
 	int alive;
 
 	do {
-		alive = 0;
-		for (i = 0; i < ep->nurbs; i++)
-			if (test_bit(i, &ep->active_mask))
-				alive++;
-
+		alive = bitmap_weight(&ep->active_mask, ep->nurbs);
 		if (!alive)
 			break;
 
Acked-by on v1 1/1
#3 lore raw
In reply to Akinobu Mita
Quoted 7 lines · Akinobu Mita

Use bitmap_weight to count the total number of bits set in bitmap.

-vlad

Quoted 31 lines
---
  net/sctp/tsnmap.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)
net/sctp/tsnmap.c +2 -6
index b5fb7c4..5f25e0c 100644
@@ -272,7 +272,7 @@ __u16 sctp_tsnmap_pending(struct sctp_tsnmap *map)
  	__u32 max_tsn = map->max_tsn_seen;
  	__u32 base_tsn = map->base_tsn;
  	__u16 pending_data;
-	u32 gap, i;
+	u32 gap;
 
  	pending_data = max_tsn - cum_tsn;
  	gap = max_tsn - base_tsn;
@@ -280,11 +280,7 @@ __u16 sctp_tsnmap_pending(struct sctp_tsnmap *map)
  	if (gap = 0 || gap >= map->len)
  		goto out;
 
-	for (i = 0; i < gap+1; i++) {
-		if (test_bit(i, map->tsn_map))
-			pending_data--;
-	}
-
+	pending_data -= bitmap_weight(map->tsn_map, gap + 1);
  out:
  	return pending_data;
  }