yaffs Added more tests to direct/timothy_tests/mirror_tests
[yaffs2.git] / yaffs_bitmap.c
index 5d1cfb2965197ba853011551571e2301ec5e9a6d..7df42cd0066ed84aa29836948516dd130ac23b7b 100644 (file)
  * Chunk bitmap manipulations
  */
 
-static Y_INLINE u8 *yaffs_block_bits(struct yaffs_dev *dev, int blk)
+static inline u8 *yaffs_block_bits(struct yaffs_dev *dev, int blk)
 {
        if (blk < dev->internal_start_block || blk > dev->internal_end_block) {
-               T(YAFFS_TRACE_ERROR,
-                 (TSTR("**>> yaffs: BlockBits block %d is not valid" TENDSTR),
-                  blk));
+               yaffs_trace(YAFFS_TRACE_ERROR,
+                       "BlockBits block %d is not valid",
+                       blk);
                YBUG();
        }
        return dev->chunk_bits +
@@ -33,9 +33,9 @@ void yaffs_verify_chunk_bit_id(struct yaffs_dev *dev, int blk, int chunk)
 {
        if (blk < dev->internal_start_block || blk > dev->internal_end_block ||
            chunk < 0 || chunk >= dev->param.chunks_per_block) {
-               T(YAFFS_TRACE_ERROR,
-                 (TSTR("**>> yaffs: Chunk Id (%d:%d) invalid" TENDSTR),
-                  blk, chunk));
+               yaffs_trace(YAFFS_TRACE_ERROR,
+                       "Chunk Id (%d:%d) invalid",
+                       blk, chunk);
                YBUG();
        }
 }
@@ -90,15 +90,9 @@ int yaffs_count_chunk_bits(struct yaffs_dev *dev, int blk)
        u8 *blk_bits = yaffs_block_bits(dev, blk);
        int i;
        int n = 0;
-       for (i = 0; i < dev->chunk_bit_stride; i++) {
-               u8 x = *blk_bits;
-               while (x) {
-                       if (x & 1)
-                               n++;
-                       x >>= 1;
-               }
 
-               blk_bits++;
-       }
+       for (i = 0; i < dev->chunk_bit_stride; i++, blk_bits++)
+               n += hweight8(*blk_bits);
+
        return n;
 }