mmc: s3c6410: enable ADMA feature in 6410 sdhci controller
[safe/jmp/linux-2.6] / fs / affs / bitmap.c
index b0b9536..3e26271 100644 (file)
@@ -7,11 +7,12 @@
  *  block allocation, deallocation, calculation of free space.
  */
 
+#include <linux/slab.h>
 #include "affs.h"
 
 /* This is, of course, shamelessly stolen from fs/minix */
 
-static int nibblemap[] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 };
+static const int nibblemap[] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 };
 
 static u32
 affs_count_free_bits(u32 blocksize, const void *data)
@@ -45,14 +46,14 @@ affs_count_free_blocks(struct super_block *sb)
        if (sb->s_flags & MS_RDONLY)
                return 0;
 
-       down(&AFFS_SB(sb)->s_bmlock);
+       mutex_lock(&AFFS_SB(sb)->s_bmlock);
 
        bm = AFFS_SB(sb)->s_bitmap;
        free = 0;
        for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--)
                free += bm->bm_free;
 
-       up(&AFFS_SB(sb)->s_bmlock);
+       mutex_unlock(&AFFS_SB(sb)->s_bmlock);
 
        return free;
 }
@@ -76,7 +77,7 @@ affs_free_block(struct super_block *sb, u32 block)
        bit     = blk % sbi->s_bmap_bits;
        bm      = &sbi->s_bitmap[bmap];
 
-       down(&sbi->s_bmlock);
+       mutex_lock(&sbi->s_bmlock);
 
        bh = sbi->s_bmap_bh;
        if (sbi->s_last_bmap != bmap) {
@@ -105,19 +106,19 @@ affs_free_block(struct super_block *sb, u32 block)
        sb->s_dirt = 1;
        bm->bm_free++;
 
-       up(&sbi->s_bmlock);
+       mutex_unlock(&sbi->s_bmlock);
        return;
 
 err_free:
        affs_warning(sb,"affs_free_block","Trying to free block %u which is already free", block);
-       up(&sbi->s_bmlock);
+       mutex_unlock(&sbi->s_bmlock);
        return;
 
 err_bh_read:
        affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key);
        sbi->s_bmap_bh = NULL;
        sbi->s_last_bmap = ~0;
-       up(&sbi->s_bmlock);
+       mutex_unlock(&sbi->s_bmlock);
        return;
 
 err_range:
@@ -128,7 +129,7 @@ err_range:
 /*
  * Allocate a block in the given allocation zone.
  * Since we have to byte-swap the bitmap on little-endian
- * machines, this is rather expensive. Therefor we will
+ * machines, this is rather expensive. Therefore we will
  * preallocate up to 16 blocks from the same word, if
  * possible. We are not doing preallocations in the
  * header zone, though.
@@ -168,7 +169,7 @@ affs_alloc_block(struct inode *inode, u32 goal)
        bmap = blk / sbi->s_bmap_bits;
        bm = &sbi->s_bitmap[bmap];
 
-       down(&sbi->s_bmlock);
+       mutex_lock(&sbi->s_bmlock);
 
        if (bm->bm_free)
                goto find_bmap_bit;
@@ -249,7 +250,7 @@ find_bit:
        mark_buffer_dirty(bh);
        sb->s_dirt = 1;
 
-       up(&sbi->s_bmlock);
+       mutex_unlock(&sbi->s_bmlock);
 
        pr_debug("%d\n", blk);
        return blk;
@@ -259,7 +260,7 @@ err_bh_read:
        sbi->s_bmap_bh = NULL;
        sbi->s_last_bmap = ~0;
 err_full:
-       up(&sbi->s_bmlock);
+       mutex_unlock(&sbi->s_bmlock);
        pr_debug("failed\n");
        return 0;
 }
@@ -289,12 +290,11 @@ int affs_init_bitmap(struct super_block *sb, int *flags)
        sbi->s_bmap_count = (sbi->s_partition_size - sbi->s_reserved +
                                 sbi->s_bmap_bits - 1) / sbi->s_bmap_bits;
        size = sbi->s_bmap_count * sizeof(*bm);
-       bm = sbi->s_bitmap = kmalloc(size, GFP_KERNEL);
+       bm = sbi->s_bitmap = kzalloc(size, GFP_KERNEL);
        if (!sbi->s_bitmap) {
                printk(KERN_ERR "AFFS: Bitmap allocation failed\n");
                return -ENOMEM;
        }
-       memset(sbi->s_bitmap, 0, size);
 
        bmap_blk = (__be32 *)sbi->s_root_bh->b_data;
        blk = sb->s_blocksize / 4 - 49;