[RFC: 2.6 patch] ext2: make ext2_count_free a static inline

From: Adrian Bunk (bunk_at_stusta.de)
Date: 04/30/05

  • Next message: Adrian Bunk: "[2.6 patch] drivers/char/agp/: make code static"
    Date:	Sat, 30 Apr 2005 22:07:38 +0200
    To: Andrew Morton <akpm@osdl.org>
    
    

    ext2_count_free is a small function that is only used
    #ifdef EXT2FS_DEBUG.

    We could offer the function itself only #ifdef EXT2FS_DEBUG, but what
    about this patch to change ot to a static inline?

    Signed-off-by: Adrian Bunk <bunk@stusta.de>

    ---
    This patch was already sent on:
    - 23 Apr 2005
     fs/ext2/Makefile |    2 +-
     fs/ext2/bitmap.c |   25 -------------------------
     fs/ext2/ext2.h   |   18 +++++++++++++++++-
     3 files changed, 18 insertions(+), 27 deletions(-)
    --- linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h.old	2005-04-20 23:08:52.000000000 +0200
    +++ linux-2.6.12-rc2-mm3-full/fs/ext2/ext2.h	2005-04-20 23:14:21.000000000 +0200
    @@ -1,5 +1,6 @@
     #include <linux/fs.h>
     #include <linux/ext2_fs.h>
    +#include <linux/buffer_head.h>
     
     /*
      * second extended file system inode data in memory
    @@ -79,6 +80,22 @@
     	return container_of(inode, struct ext2_inode_info, vfs_inode);
     }
     
    +static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
    +
    +static inline unsigned long ext2_count_free (struct buffer_head * map,
    +					     unsigned int numchars)
    +{
    +	unsigned int i;
    +	unsigned long sum = 0;
    +	
    +	if (!map) 
    +		return (0);
    +	for (i = 0; i < numchars; i++)
    +		sum += nibblemap[map->b_data[i] & 0xf] +
    +			nibblemap[(map->b_data[i] >> 4) & 0xf];
    +	return (sum);
    +}
    +
     /* balloc.c */
     extern int ext2_bg_has_super(struct super_block *sb, int group);
     extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
    @@ -111,7 +128,6 @@
     extern void ext2_free_inode (struct inode *);
     extern unsigned long ext2_count_free_inodes (struct super_block *);
     extern void ext2_check_inodes_bitmap (struct super_block *);
    -extern unsigned long ext2_count_free (struct buffer_head *, unsigned);
     
     /* inode.c */
     extern void ext2_read_inode (struct inode *);
    --- linux-2.6.12-rc2-mm3-full/fs/ext2/Makefile.old	2005-04-20 23:14:35.000000000 +0200
    +++ linux-2.6.12-rc2-mm3-full/fs/ext2/Makefile	2005-04-20 23:14:45.000000000 +0200
    @@ -4,7 +4,7 @@
     
     obj-$(CONFIG_EXT2_FS) += ext2.o
     
    -ext2-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
    +ext2-y := balloc.o dir.o file.o fsync.o ialloc.o inode.o \
     	  ioctl.o namei.o super.o symlink.o
     
     ext2-$(CONFIG_EXT2_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
    --- linux-2.6.12-rc2-mm3-full/fs/ext2/bitmap.c	2005-03-02 08:38:08.000000000 +0100
    +++ /dev/null	2005-03-19 22:42:59.000000000 +0100
    @@ -1,25 +0,0 @@
    -/*
    - *  linux/fs/ext2/bitmap.c
    - *
    - * Copyright (C) 1992, 1993, 1994, 1995
    - * Remy Card (card@masi.ibp.fr)
    - * Laboratoire MASI - Institut Blaise Pascal
    - * Universite Pierre et Marie Curie (Paris VI)
    - */
    -
    -#include <linux/buffer_head.h>
    -
    -static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
    -
    -unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
    -{
    -	unsigned int i;
    -	unsigned long sum = 0;
    -	
    -	if (!map) 
    -		return (0);
    -	for (i = 0; i < numchars; i++)
    -		sum += nibblemap[map->b_data[i] & 0xf] +
    -			nibblemap[(map->b_data[i] >> 4) & 0xf];
    -	return (sum);
    -}
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Adrian Bunk: "[2.6 patch] drivers/char/agp/: make code static"
  • Quantcast