Skip to contentSkip to conversation

ext2: make ext2_count_free a static inline

RFC PATCH New Adrian Bunk 1 participant 1 message Apr 30, 2005 ext2 file system

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ext2: make ext2_count_free a static inline

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?

---

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(-)
fs/ext2/ext2.h renamed from fs/ext2/ext2.h.old +17 -1
@@ -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 *);
fs/ext2/Makefile renamed from fs/ext2/Makefile.old +1 -1
@@ -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
fs/ext2/bitmap.c deleted +0 -25
@@ -1,25 +0,0 @@
-/*
- *  linux/fs/ext2/bitmap.c
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card ([email protected])
- * 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);
-}