[PATCH] jfs: 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@...>, <shaggy@...>, <jfs-discussion@...>
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: shaggy@austin.ibm.com
Cc: jfs-discussion@lists.sourceforge.net
---
 fs/jfs/jfs_dmap.c  |   11 +++++------
 fs/jfs/jfs_imap.c  |   15 ++++++---------
 fs/jfs/jfs_xtree.c |   26 ++++++++------------------
 3 files changed, 19 insertions(+), 33 deletions(-)

diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index e198506..2bc7d8a 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -2172,7 +2172,7 @@ static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
 	}
 
 	/* update the free count for this dmap */
-	dp->nfree = cpu_to_le32(le32_to_cpu(dp->nfree) - nblocks);
+	le32_add_cpu(&dp->nfree, -nblocks);
 
 	BMAP_LOCK(bmp);
 
@@ -2316,7 +2316,7 @@ static int dbFreeBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
 
 	/* update the free count for this dmap.
 	 */
-	dp->nfree = cpu_to_le32(le32_to_cpu(dp->nfree) + nblocks);
+	le32_add_cpu(&dp->nfree, nblocks);
 
 	BMAP_LOCK(bmp);
 
@@ -3226,7 +3226,7 @@ static int dbAllocDmapBU(struct bmap * bmp, struct dmap * dp, s64 blkno,
 	}
 
 	/* update the free count for this dmap */
-	dp->nfree = cpu_to_le32(le32_to_cpu(dp->nfree) - nblocks);
+	le32_add_cpu(&dp->nfree, -nblocks);
 
 	/* reconstruct summary tree */
 	dbInitDmapTree(dp);
@@ -3660,9 +3660,8 @@ static int dbInitDmap(struct dmap * dp, s64 Blkno, int nblocks)
 			goto initTree;
 		}
 	} else {
-		dp->nblocks =
-		    cpu_to_le32(le32_to_cpu(dp->nblocks) + nblocks);
-		dp->nfree = cpu_to_le32(le32_to_cpu(dp->nfree) + nblocks);
+		le32_add_cpu(&dp->nblocks, nblocks);
+		le32_add_cpu(&dp->nfree, nblocks);
 	}
 
 	/* word number containing start block number */
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index 9bf29f7..734ec91 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -1019,8 +1019,7 @@ int diFree(struct inode *ip)
 		/* update the free inode counts at the iag, ag and
 		 * map level.
 		 */
-		iagp->nfreeinos =
-		    cpu_to_le32(le32_to_cpu(iagp->nfreeinos) + 1);
+		le32_add_cpu(&iagp->nfreeinos, 1);
 		imap->im_agctl[agno].numfree += 1;
 		atomic_inc(&imap->im_numfree);
 
@@ -1219,9 +1218,8 @@ int diFree(struct inode *ip)
 	/* update the number of free inodes and number of free extents
 	 * for the iag.
 	 */
-	iagp->nfreeinos = cpu_to_le32(le32_to_cpu(iagp->nfreeinos) -
-				      (INOSPEREXT - 1));
-	iagp->nfreeexts = cpu_to_le32(le32_to_cpu(iagp->nfreeexts) + 1);
+	le32_add_cpu(&iagp->nfreeinos, -(INOSPEREXT - 1));
+	le32_add_cpu(&iagp->nfreeexts, 1);
 
 	/* update the number of free inodes and backed inodes
 	 * at the ag and inode map level.
@@ -2124,7 +2122,7 @@ static int diAllocBit(struct inomap * imap, struct iag * iagp, int ino)
 	/* update the free inode count at the iag, ag, inode
 	 * map levels.
 	 */
-	iagp->nfreeinos = cpu_to_le32(le32_to_cpu(iagp->nfreeinos) - 1);
+	le32_add_cpu(&iagp->nfreeinos, -1);
 	imap->im_agctl[agno].numfree -= 1;
 	atomic_dec(&imap->im_numfree);
 
@@ -2378,9 +2376,8 @@ static int diNewExt(struct inomap * imap, struct iag * iagp, int extno)
 	/* update the free inode and free extent counts for the
 	 * iag.
 	 */
-	iagp->nfreeinos = cpu_to_le32(le32_to_cpu(iagp->nfreeinos) +
-				      (INOSPEREXT - 1));
-	iagp->nfreeexts = cpu_to_le32(le32_to_cpu(iagp->nfreeexts) - 1);
+	le32_add_cpu(&iagp->nfreeinos, (INOSPEREXT - 1));
+	le32_add_cpu(&iagp->nfreeexts, -1);
 
 	/* update the free and backed inode counts for the ag.
 	 */
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
index a000aaa..5a61ebf 100644
--- a/fs/jfs/jfs_xtree.c
+++ b/fs/jfs/jfs_xtree.c
@@ -905,8 +905,7 @@ int xtInsert(tid_t tid,		/* transaction id */
 	XT_PUTENTRY(xad, xflag, xoff, xlen, xaddr);
 
 	/* advance next available entry index */
-	p->header.nextindex =
-	    cpu_to_le16(le16_to_cpu(p->header.nextindex) + 1);
+	le16_add_cpu(&p->header.nextindex, 1);
 
 	/* Don't log it if there are no links to the file */
 	if (!test_cflag(COMMIT_Nolink, ip)) {
@@ -997,8 +996,7 @@ xtSplitUp(tid_t tid,
 			    split->addr);
 
 		/* advance next available entry index */
-		sp->header.nextindex =
-		    cpu_to_le16(le16_to_cpu(sp->header.nextindex) + 1);
+		le16_add_cpu(&sp->header.nextindex, 1);
 
 		/* Don't log it if there are no links to the file */
 		if (!test_cflag(COMMIT_Nolink, ip)) {
@@ -1167,9 +1165,7 @@ xtSplitUp(tid_t tid,
 				    JFS_SBI(ip->i_sb)->nbperpage, rcbn);
 
 			/* advance next available entry index. */
-			sp->header.nextindex =
-			    cpu_to_le16(le16_to_cpu(sp->header.nextindex) +
-					1);
+			le16_add_cpu(&sp->header.nextindex, 1);
 
 			/* Don't log it if there are no links to the file */
 			if (!test_cflag(COMMIT_Nolink, ip)) {
@@ -1738,8 +1734,7 @@ int xtExtend(tid_t tid,		/* transaction id */
 		XT_PUTENTRY(xad, XAD_NEW, xoff, len, xaddr);
 
 		/* advance next available entry index */
-		p->header.nextindex =
-		    cpu_to_le16(le16_to_cpu(p->header.nextindex) + 1);
+		le16_add_cpu(&p->header.nextindex, 1);
 	}
 
 	/* get back old entry */
@@ -1905,8 +1900,7 @@ printf("xtTailgate: xoff:0x%lx xlen:0x%x xaddr:0x%lx\n",
 		XT_PUTENTRY(xad, XAD_NEW, xoff, xlen, xaddr);
 
 		/* advance next available entry index */
-		p->header.nextindex =
-		    cpu_to_le16(le16_to_cpu(p->header.nextindex) + 1);
+		le16_add_cpu(&p->header.nextindex, 1);
 	}
 
 	/* get back old XAD */
@@ -2567,8 +2561,7 @@ int xtAppend(tid_t tid,		/* transaction id */
 	XT_PUTENTRY(xad, xflag, xoff, xlen, xaddr);
 
 	/* advance next available entry index */
-	p->header.nextindex =
-	    cpu_to_le16(le16_to_cpu(p->header.nextindex) + 1);
+	le16_add_cpu(&p->header.nextindex, 1);
 
 	xtlck->lwm.offset =
 	    (xtlck->lwm.offset) ? min(index,(int) xtlck->lwm.offset) : index;
@@ -2631,8 +2624,7 @@ int xtDelete(tid_t tid, struct inode *ip, s64 xoff, s32 xlen, int flag)
 	 * delete the entry from the leaf page
 	 */
 	nextindex = le16_to_cpu(p->header.nextindex);
-	p->header.nextindex =
-	    cpu_to_le16(le16_to_cpu(p->header.nextindex) - 1);
+	le16_add_cpu(&p->header.nextindex, -1);
 
 	/*
 	 * if the leaf page bocome empty, free the page
@@ -2795,9 +2787,7 @@ xtDeleteUp(tid_t tid, struct inode *ip,
 					(nextindex - index -
 					 1) << L2XTSLOTSIZE);
 
-			p->header.nextindex =
-			    cpu_to_le16(le16_to_cpu(p->header.nextindex) -
-					1);
+			le16_add_cpu(&p->header.nextindex, -1);
 			jfs_info("xtDeleteUp(entry): 0x%lx[%d]",
 				 (ulong) parent->bn, index);
 		}
-- 
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)