[PATCH] ext2: le*_add_cpu conversion

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: LKML <linux-kernel@...>
Cc: Marcin Slusarz <marcin.slusarz@...>, <linux-ext4@...>
Date: Tuesday, February 12, 2008 - 7:06 pm

From: Marcin Slusarz <marcin.slusarz@gmail.com>

replace all:
little_endian_variable = cpu_to_leX(leX_to_cpu(little_endian_variable) +
					expression_in_cpu_byteorder);
with:
	leX_add_cpu(&little_endian_variable, expression_in_cpu_byteorder);
generated with semantic patch

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: linux-ext4@vger.kernel.org
---
 fs/ext2/ialloc.c |   12 ++++--------
 fs/ext2/super.c  |    2 +-
 fs/ext2/xattr.c  |    9 +++------
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index 5deb8b7..0f3e3f3 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -75,11 +75,9 @@ static void ext2_release_inode(struct super_block *sb, int group, int dir)
 	}
 
 	spin_lock(sb_bgl_lock(EXT2_SB(sb), group));
-	desc->bg_free_inodes_count =
-		cpu_to_le16(le16_to_cpu(desc->bg_free_inodes_count) + 1);
+	le16_add_cpu(&desc->bg_free_inodes_count, 1);
 	if (dir)
-		desc->bg_used_dirs_count =
-			cpu_to_le16(le16_to_cpu(desc->bg_used_dirs_count) - 1);
+		le16_add_cpu(&desc->bg_used_dirs_count, -1);
 	spin_unlock(sb_bgl_lock(EXT2_SB(sb), group));
 	if (dir)
 		percpu_counter_dec(&EXT2_SB(sb)->s_dirs_counter);
@@ -539,13 +537,11 @@ got:
 		percpu_counter_inc(&sbi->s_dirs_counter);
 
 	spin_lock(sb_bgl_lock(sbi, group));
-	gdp->bg_free_inodes_count =
-                cpu_to_le16(le16_to_cpu(gdp->bg_free_inodes_count) - 1);
+	le16_add_cpu(&gdp->bg_free_inodes_count, -1);
 	if (S_ISDIR(mode)) {
 		if (sbi->s_debts[group] < 255)
 			sbi->s_debts[group]++;
-		gdp->bg_used_dirs_count =
-			cpu_to_le16(le16_to_cpu(gdp->bg_used_dirs_count) + 1);
+		le16_add_cpu(&gdp->bg_used_dirs_count, 1);
 	} else {
 		if (sbi->s_debts[group])
 			sbi->s_debts[group]--;
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 108f739..7e68673 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -603,7 +603,7 @@ static int ext2_setup_super (struct super_block * sb,
 			"running e2fsck is recommended\n");
 	if (!le16_to_cpu(es->s_max_mnt_count))
 		es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
-	es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1);
+	le16_add_cpu(&es->s_mnt_count, 1);
 	ext2_write_super(sb);
 	if (test_opt (sb, DEBUG))
 		printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, "
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 3e8683d..495ec0d 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -646,8 +646,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
 					unlock_buffer(new_bh);
 					goto cleanup;
 				}
-				HDR(new_bh)->h_refcount = cpu_to_le32(1 +
-					le32_to_cpu(HDR(new_bh)->h_refcount));
+				le32_add_cpu(&HDR(new_bh)->h_refcount, 1);
 				ea_bdebug(new_bh, "refcount now=%d",
 					le32_to_cpu(HDR(new_bh)->h_refcount));
 			}
@@ -731,8 +730,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
 			bforget(old_bh);
 		} else {
 			/* Decrement the refcount only. */
-			HDR(old_bh)->h_refcount = cpu_to_le32(
-				le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
+			le32_add_cpu(&HDR(old_bh)->h_refcount, -1);
 			if (ce)
 				mb_cache_entry_release(ce);
 			DQUOT_FREE_BLOCK(inode, 1);
@@ -789,8 +787,7 @@ ext2_xattr_delete_inode(struct inode *inode)
 		bforget(bh);
 		unlock_buffer(bh);
 	} else {
-		HDR(bh)->h_refcount = cpu_to_le32(
-			le32_to_cpu(HDR(bh)->h_refcount) - 1);
+		le32_add_cpu(&HDR(bh)->h_refcount, -1);
 		if (ce)
 			mb_cache_entry_release(ce);
 		ea_bdebug(bh, "refcount now=%d",
-- 
1.5.3.7

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCHSET] [bl]e*_add_cpu conversions, , (Tue Feb 12, 7:06 pm)
Re: [PATCH] ufs: [bl]e*_add_cpu conversion, Roel Kluin, (Wed Feb 13, 5:41 am)
Re: [PATCH] ufs: [bl]e*_add_cpu conversion, Andrew Morton, (Sat Feb 16, 1:28 am)
Re: [PATCH] ufs: [bl]e*_add_cpu conversion, Roel Kluin, (Mon Feb 18, 7:22 pm)
Re: [PATCH] ufs: [bl]e*_add_cpu conversion, Marcin Slusarz, (Tue Feb 19, 1:45 pm)
Re: [PATCH] ufs: [bl]e*_add_cpu conversion, Evgeniy Dushistov, (Tue Feb 19, 3:16 pm)
Re: [PATCH] ufs: [bl]e*_add_cpu conversion, Marcin Slusarz, (Sun Mar 9, 6:21 am)
Re: [PATCH] ufs: [bl]e*_add_cpu conversion, Marcin Slusarz, (Wed Feb 13, 2:21 pm)
Re: [PATCH] sysv: [bl]e*_add_cpu conversion, Christoph Hellwig, (Thu Feb 14, 3:04 am)
Re: [PATCH] sysv: [bl]e*_add_cpu conversion, Christoph Hellwig, (Sat Feb 16, 9:31 am)
[PATCH] quota: le*_add_cpu conversion, , (Tue Feb 12, 7:06 pm)
Re: [PATCH] quota: le*_add_cpu conversion, Jan Kara, (Wed Feb 13, 5:52 am)
[PATCH] ocfs2: le*_add_cpu conversion, , (Tue Feb 12, 7:06 pm)
Re: [PATCH] ocfs2: le*_add_cpu conversion, Mark Fasheh, (Mon Feb 18, 5:03 pm)
[PATCH] ntfs: le*_add_cpu conversion, , (Tue Feb 12, 7:06 pm)
[PATCH] jfs: le*_add_cpu conversion, , (Tue Feb 12, 7:06 pm)
Re: [PATCH] jfs: le*_add_cpu conversion, Dave Kleikamp, (Wed Feb 13, 5:51 pm)
[PATCH] ext4: le*_add_cpu conversion, , (Tue Feb 12, 7:06 pm)
[PATCH] ext2: le*_add_cpu conversion, , (Tue Feb 12, 7:06 pm)
[PATCH] scsi: le*_add_cpu conversion, , (Tue Feb 12, 7:06 pm)
RE: [PATCH] scsi: le*_add_cpu conversion, Salyzyn, Mark, (Wed Feb 13, 10:06 am)
RE: [PATCH] ipw2200: le*_add_cpu conversion, Chatre, Reinette, (Wed Feb 13, 12:54 pm)
[PATCH] gfs2: be*_add_cpu conversion, , (Tue Feb 12, 7:06 pm)
Re: [PATCH] gfs2: be*_add_cpu conversion, Steven Whitehouse, (Wed Feb 13, 5:55 am)
[PATCH] affs: be*_add_cpu conversion, , (Tue Feb 12, 7:06 pm)
Re: [PATCH] infiniband: be*_add_cpu conversion, Roland Dreier, (Tue Feb 12, 8:32 pm)
Re: [PATCH] ieee 1394: be*_add_cpu conversion, Stefan Richter, (Sat Feb 16, 12:54 pm)
Re: [PATCH] crypto: be*_add_cpu conversion, Roel Kluin, (Wed Feb 13, 4:25 am)
Re: [PATCH] crypto: be*_add_cpu conversion, Marcin Slusarz, (Wed Feb 13, 2:36 pm)
Re: [PATCH] crypto: be*_add_cpu conversion, Herbert Xu, (Fri Mar 14, 4:24 am)