lib/sbitmap: kill 'depth' from sbitmap_word
[linux-2.6-microblaze.git] / include / linux / sbitmap.h
index 95df357..df3b584 100644 (file)
@@ -27,15 +27,10 @@ struct seq_file;
  * struct sbitmap_word - Word in a &struct sbitmap.
  */
 struct sbitmap_word {
-       /**
-        * @depth: Number of bits being used in @word/@cleared
-        */
-       unsigned long depth;
-
        /**
         * @word: word holding free bits
         */
-       unsigned long word ____cacheline_aligned_in_smp;
+       unsigned long word;
 
        /**
         * @cleared: word holding cleared bits
@@ -164,6 +159,14 @@ struct sbitmap_queue {
 int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift,
                      gfp_t flags, int node, bool round_robin, bool alloc_hint);
 
+/* sbitmap internal helper */
+static inline unsigned int __map_depth(const struct sbitmap *sb, int index)
+{
+       if (index == sb->map_nr - 1)
+               return sb->depth - (index << sb->shift);
+       return 1U << sb->shift;
+}
+
 /**
  * sbitmap_free() - Free memory used by a &struct sbitmap.
  * @sb: Bitmap to free.
@@ -251,7 +254,7 @@ static inline void __sbitmap_for_each_set(struct sbitmap *sb,
        while (scanned < sb->depth) {
                unsigned long word;
                unsigned int depth = min_t(unsigned int,
-                                          sb->map[index].depth - nr,
+                                          __map_depth(sb, index) - nr,
                                           sb->depth - scanned);
 
                scanned += depth;