aboutsummaryrefslogtreecommitdiff
path: root/fs/ufs/util.h
diff options
context:
space:
mode:
authorEvgeniy <dushistov@mail.ru>2006-01-14 11:42:06 +0300
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-14 10:27:32 -0800
commit7b4ee73e28052e53aac2fef1c91029666d8b2d70 (patch)
treea82714e4b9c2e1157695872b66bf180dc12b27a2 /fs/ufs/util.h
parent59af70385fb125f819d953801b6c45629836e916 (diff)
[PATCH] ufs cleanup
Here is update of ufs cleanup patch, brought on by the recently fixed ubh_get_usb_second() bug that made some ugly code rather painfully obvious. It also includes - fix compilation warnings which appears if debug mode turn on - remove unnecessary duplication of code to support UFS2 I tested it on ufs1 and ufs2 file-systems. Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ufs/util.h')
-rw-r--r--fs/ufs/util.h28
1 files changed, 19 insertions, 9 deletions
diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index e45ad537987..48d6d9bcc15 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -249,18 +249,28 @@ extern void _ubh_memcpyubh_(struct ufs_sb_private_info *, struct ufs_buffer_head
/*
- * macros to get important structures from ufs_buffer_head
+ * macros and inline function to get important structures from ufs_sb_private_info
*/
-#define ubh_get_usb_first(ubh) \
- ((struct ufs_super_block_first *)((ubh)->bh[0]->b_data))
-#define ubh_get_usb_second(ubh) \
- ((struct ufs_super_block_second *)((ubh)->\
- bh[UFS_SECTOR_SIZE >> uspi->s_fshift]->b_data + (UFS_SECTOR_SIZE & ~uspi->s_fmask)))
+static inline void *get_usb_offset(struct ufs_sb_private_info *uspi,
+ unsigned int offset)
+{
+ unsigned int index;
+
+ index = offset >> uspi->s_fshift;
+ offset &= ~uspi->s_fmask;
+ return uspi->s_ubh.bh[index]->b_data + offset;
+}
+
+#define ubh_get_usb_first(uspi) \
+ ((struct ufs_super_block_first *)get_usb_offset((uspi), 0))
+
+#define ubh_get_usb_second(uspi) \
+ ((struct ufs_super_block_second *)get_usb_offset((uspi), UFS_SECTOR_SIZE))
+
+#define ubh_get_usb_third(uspi) \
+ ((struct ufs_super_block_third *)get_usb_offset((uspi), 2*UFS_SECTOR_SIZE))
-#define ubh_get_usb_third(ubh) \
- ((struct ufs_super_block_third *)((ubh)-> \
- bh[UFS_SECTOR_SIZE*2 >> uspi->s_fshift]->b_data + (UFS_SECTOR_SIZE*2 & ~uspi->s_fmask)))
#define ubh_get_ucg(ubh) \
((struct ufs_cylinder_group *)((ubh)->bh[0]->b_data))