]> Git Repo - linux.git/commitdiff
scsi: sbitmap: Export sbitmap_weight
authorMing Lei <[email protected]>
Fri, 22 Jan 2021 02:33:09 +0000 (10:33 +0800)
committerMartin K. Petersen <[email protected]>
Thu, 4 Mar 2021 22:36:59 +0000 (17:36 -0500)
SCSI's .device_busy will be converted to sbitmap and sbitmap_weight is
needed. Export the helper.

The only existing user of sbitmap_weight() uses it to find out how many
bits are set and not cleared. Align sbitmap_weight() meaning with this
usage model.

Link: https://lore.kernel.org/r/[email protected]
Cc: Omar Sandoval <[email protected]>
Cc: Kashyap Desai <[email protected]>
Cc: Sumanesh Samanta <[email protected]>
Cc: Ewan D. Milne <[email protected]>
Tested-by: Sumanesh Samanta <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Signed-off-by: Ming Lei <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
include/linux/sbitmap.h
lib/sbitmap.c

index 247776fcc02cc652fe1e688249def820f809202a..c65ba887dcc37eac4bb11a43cd764838b4ca9abe 100644 (file)
@@ -341,6 +341,16 @@ static inline int sbitmap_test_bit(struct sbitmap *sb, unsigned int bitnr)
  */
 void sbitmap_show(struct sbitmap *sb, struct seq_file *m);
 
+
+/**
+ * sbitmap_weight() - Return how many set and not cleared bits in a &struct
+ * sbitmap.
+ * @sb: Bitmap to check.
+ *
+ * Return: How many set and not cleared bits set
+ */
+unsigned int sbitmap_weight(const struct sbitmap *sb);
+
 /**
  * sbitmap_bitmap_show() - Write a hex dump of a &struct sbitmap to a &struct
  * seq_file.
index e395435654aa60ce6b9be39448986a3ac91bd660..73da26ad021eace844c1a333f3d527df3fa3cdbd 100644 (file)
@@ -334,20 +334,21 @@ static unsigned int __sbitmap_weight(const struct sbitmap *sb, bool set)
        return weight;
 }
 
-static unsigned int sbitmap_weight(const struct sbitmap *sb)
+static unsigned int sbitmap_cleared(const struct sbitmap *sb)
 {
-       return __sbitmap_weight(sb, true);
+       return __sbitmap_weight(sb, false);
 }
 
-static unsigned int sbitmap_cleared(const struct sbitmap *sb)
+unsigned int sbitmap_weight(const struct sbitmap *sb)
 {
-       return __sbitmap_weight(sb, false);
+       return __sbitmap_weight(sb, true) - sbitmap_cleared(sb);
 }
+EXPORT_SYMBOL_GPL(sbitmap_weight);
 
 void sbitmap_show(struct sbitmap *sb, struct seq_file *m)
 {
        seq_printf(m, "depth=%u\n", sb->depth);
-       seq_printf(m, "busy=%u\n", sbitmap_weight(sb) - sbitmap_cleared(sb));
+       seq_printf(m, "busy=%u\n", sbitmap_weight(sb));
        seq_printf(m, "cleared=%u\n", sbitmap_cleared(sb));
        seq_printf(m, "bits_per_word=%u\n", 1U << sb->shift);
        seq_printf(m, "map_nr=%u\n", sb->map_nr);
This page took 0.054634 seconds and 4 git commands to generate.