Skip to contentSkip to conversation

e*_add_cpu conversions

PATCH New [email protected] 14 participants 38 messages Feb 12, 2008 – Mar 14, 2008

Subsystems (17)
VFS SCSI InfiniBand Crypto API +13 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 e*_add_cpu conversions

From: Marcin Slusarz <[email protected]>

Hi

This patchset converts

big/little_endian_variable = cpu_to_[bl]eX([bl]eX_to_cpu(big/little_endian_variable) +

					expression_in_cpu_byteorder);
to:
	[bl]eX_add_cpu(&big/little_endian_variable, expression_in_cpu_byteorder);

All patches were generated by spatch, then reviewed and fixed to follow coding style.

Semantic patch:
@@
expression *X;
expression Y;
@@
(
- *X = cpu_to_le64(le64_to_cpu(*X) + Y);
+ le64_add_cpu(X, Y);
|
- *X = cpu_to_le32(le32_to_cpu(*X) + Y);
+ le32_add_cpu(X, Y);
|
- *X = cpu_to_le16(le16_to_cpu(*X) + Y);
+ le16_add_cpu(X, Y);
|
- *X = cpu_to_be64(be64_to_cpu(*X) + Y);
+ be64_add_cpu(X, Y);
|
- *X = cpu_to_be32(be32_to_cpu(*X) + Y);
+ be32_add_cpu(X, Y);
|
- *X = cpu_to_be16(be16_to_cpu(*X) + Y);
+ be16_add_cpu(X, Y);
|
- *X = cpu_to_le64(le64_to_cpu(*X) - Y);
+ le64_add_cpu(X, -Y);
|
- *X = cpu_to_le32(le32_to_cpu(*X) - Y);
+ le32_add_cpu(X, -Y);
|
- *X = cpu_to_le16(le16_to_cpu(*X) - Y);
+ le16_add_cpu(X, -Y);
|
- *X = cpu_to_be64(be64_to_cpu(*X) - Y);
+ be64_add_cpu(X, -Y);
|
- *X = cpu_to_be32(be32_to_cpu(*X) - Y);
+ be32_add_cpu(X, -Y);
|
- *X = cpu_to_be16(be16_to_cpu(*X) - Y);
+ be16_add_cpu(X, -Y);
)
@@ expression X, Y; @@
(
- X = cpu_to_le64(le64_to_cpu(X) + Y);
+ le64_add_cpu(&X, Y);
|
- X = cpu_to_le32(le32_to_cpu(X) + Y);
+ le32_add_cpu(&X, Y);
|
- X = cpu_to_le16(le16_to_cpu(X) + Y);
+ le16_add_cpu(&X, Y);
|
- X = cpu_to_be64(be64_to_cpu(X) + Y);
+ be64_add_cpu(&X, Y);
|
- X = cpu_to_be32(be32_to_cpu(X) + Y);
+ be32_add_cpu(&X, Y);
|
- X = cpu_to_be16(be16_to_cpu(X) + Y);
+ be16_add_cpu(&X, Y);
|
- X = cpu_to_le64(le64_to_cpu(X) - Y);
+ le64_add_cpu(&X, -Y);
|
- X = cpu_to_le32(le32_to_cpu(X) - Y);
+ le32_add_cpu(&X, -Y);
|
- X = cpu_to_le16(le16_to_cpu(X) - Y);
+ le16_add_cpu(&X, -Y);
|
- X = cpu_to_be64(be64_to_cpu(X) - Y);
+ be64_add_cpu(&X, -Y);
|
- X = cpu_to_be32(be32_to_cpu(X) - Y);
+ be32_add_cpu(&X, -Y);
|
- X = cpu_to_be16(be16_to_cpu(X) - Y);
+ be16_add_cpu(&X, -Y);
)

diffstat:

 crypto/lrw.c                           |    2 +-
 drivers/ieee1394/csr.c                 |    6 ++----
 drivers/infiniband/hw/mthca/mthca_cq.c |    2 +-
 drivers/net/wireless/ipw2200.c         |    4 +---
 drivers/scsi/aacraid/commsup.c         |    2 +-
 drivers/scsi/ips.c                     |    8 ++------
 fs/affs/file.c                         |    4 ++--
 fs/ext2/ialloc.c                       |   12 ++++--------
 fs/ext2/super.c                        |    2 +-
 fs/ext2/xattr.c                        |    9 +++------
 fs/ext4/balloc.c                       |    7 ++-----
 fs/ext4/extents.c                      |   20 +++++++++-----------
 fs/ext4/ialloc.c                       |   12 ++++--------
 fs/ext4/mballoc.c                      |    7 ++-----
 fs/ext4/resize.c                       |    6 ++----
 fs/ext4/super.c                        |    2 +-
 fs/ext4/xattr.c                        |    6 ++----
 fs/gfs2/dir.c                          |    6 +++---
 fs/hfs/mdb.c                           |    2 +-
 fs/hfsplus/super.c                     |    2 +-
 fs/jfs/jfs_dmap.c                      |   11 +++++------
 fs/jfs/jfs_imap.c                      |   15 ++++++---------
 fs/jfs/jfs_xtree.c                     |   26 ++++++++------------------
 fs/ntfs/upcase.c                       |    5 ++---
 fs/ocfs2/dir.c                         |    5 ++---
 fs/ocfs2/localalloc.c                  |    3 +--
 fs/quota_v2.c                          |    4 ++--
 fs/reiserfs/objectid.c                 |    5 ++---
 fs/reiserfs/stree.c                    |    3 +--
 fs/sysv/sysv.h                         |    8 ++++----
 fs/ufs/swab.h                          |   16 ++++++++--------
 31 files changed, 86 insertions(+), 136 deletions(-)

Marcin

#1 lore raw

PATCH 1/1 ext4: le*_add_cpu conversion

From: Marcin Slusarz <[email protected]>

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

---
 fs/ext4/balloc.c  |    7 ++-----
 fs/ext4/extents.c |   20 +++++++++-----------
 fs/ext4/ialloc.c  |   12 ++++--------
 fs/ext4/mballoc.c |    7 ++-----
 fs/ext4/resize.c  |    6 ++----
 fs/ext4/super.c   |    2 +-
 fs/ext4/xattr.c   |    6 ++----
 7 files changed, 22 insertions(+), 38 deletions(-)
fs/ext4/balloc.c +2 -5
index 0737e05..5d34899 100644
@@ -752,9 +752,7 @@ do_more:
 	jbd_unlock_bh_state(bitmap_bh);
 
 	spin_lock(sb_bgl_lock(sbi, block_group));
-	desc->bg_free_blocks_count =
-		cpu_to_le16(le16_to_cpu(desc->bg_free_blocks_count) +
-			group_freed);
+	le16_add_cpu(&desc->bg_free_blocks_count, group_freed);
 	desc->bg_checksum = ext4_group_desc_csum(sbi, block_group, desc);
 	spin_unlock(sb_bgl_lock(sbi, block_group));
 	percpu_counter_add(&sbi->s_freeblocks_counter, count);
@@ -1823,8 +1821,7 @@ allocated:
 	spin_lock(sb_bgl_lock(sbi, group_no));
 	if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT))
 		gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
-	gdp->bg_free_blocks_count =
-			cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)-num);
+	le16_add_cpu(&gdp->bg_free_blocks_count, -num);
 	gdp->bg_checksum = ext4_group_desc_csum(sbi, group_no, gdp);
 	spin_unlock(sb_bgl_lock(sbi, group_no));
 	percpu_counter_sub(&sbi->s_freeblocks_counter, num);
fs/ext4/extents.c +9 -11
index bc7081f..ad628ff 100644
@@ -608,7 +608,7 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
 
 	ix->ei_block = cpu_to_le32(logical);
 	ext4_idx_store_pblock(ix, ptr);
-	curp->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(curp->p_hdr->eh_entries)+1);
+	le16_add_cpu(&curp->p_hdr->eh_entries, 1);
 
 	BUG_ON(le16_to_cpu(curp->p_hdr->eh_entries)
 			     > le16_to_cpu(curp->p_hdr->eh_max));
@@ -730,7 +730,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
 	}
 	if (m) {
 		memmove(ex, path[depth].p_ext-m, sizeof(struct ext4_extent)*m);
-		neh->eh_entries = cpu_to_le16(le16_to_cpu(neh->eh_entries)+m);
+		le16_add_cpu(&neh->eh_entries, m);
 	}
 
 	set_buffer_uptodate(bh);
@@ -747,8 +747,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
 		err = ext4_ext_get_access(handle, inode, path + depth);
 		if (err)
 			goto cleanup;
-		path[depth].p_hdr->eh_entries =
-		     cpu_to_le16(le16_to_cpu(path[depth].p_hdr->eh_entries)-m);
+		le16_add_cpu(&path[depth].p_hdr->eh_entries, -m);
 		err = ext4_ext_dirty(handle, inode, path + depth);
 		if (err)
 			goto cleanup;
@@ -811,8 +810,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
 		if (m) {
 			memmove(++fidx, path[i].p_idx - m,
 				sizeof(struct ext4_extent_idx) * m);
-			neh->eh_entries =
-				cpu_to_le16(le16_to_cpu(neh->eh_entries) + m);
+			le16_add_cpu(&neh->eh_entries, m);
 		}
 		set_buffer_uptodate(bh);
 		unlock_buffer(bh);
@@ -828,7 +826,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
 			err = ext4_ext_get_access(handle, inode, path + i);
 			if (err)
 				goto cleanup;
-			path[i].p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(path[i].p_hdr->eh_entries)-m);
+			le16_add_cpu(&path[i].p_hdr->eh_entries, -m);
 			err = ext4_ext_dirty(handle, inode, path + i);
 			if (err)
 				goto cleanup;
@@ -1363,7 +1361,7 @@ int ext4_ext_try_to_merge(struct inode *inode,
 				* sizeof(struct ext4_extent);
 			memmove(ex + 1, ex + 2, len);
 		}
-		eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries) - 1);
+		le16_add_cpu(&eh->eh_entries, -1);
 		merge_done = 1;
 		WARN_ON(eh->eh_entries == 0);
 		if (!eh->eh_entries)
@@ -1554,7 +1552,7 @@ has_space:
 		path[depth].p_ext = nearex;
 	}
 
-	eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries)+1);
+	le16_add_cpu(&eh->eh_entries, 1);
 	nearex = path[depth].p_ext;
 	nearex->ee_block = newext->ee_block;
 	ext4_ext_store_pblock(nearex, ext_pblock(newext));
@@ -1693,7 +1691,7 @@ static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
 	err = ext4_ext_get_access(handle, inode, path);
 	if (err)
 		return err;
-	path->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(path->p_hdr->eh_entries)-1);
+	le16_add_cpu(&path->p_hdr->eh_entries, -1);
 	err = ext4_ext_dirty(handle, inode, path);
 	if (err)
 		return err;
@@ -1896,7 +1894,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
 		if (num == 0) {
 			/* this extent is removed; mark slot entirely unused */
 			ext4_ext_store_pblock(ex, 0);
-			eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries)-1);
+			le16_add_cpu(&eh->eh_entries, -1);
 		}
 
 		ex->ee_block = cpu_to_le32(block);
fs/ext4/ialloc.c +4 -8
index da18a74..843664c 100644
@@ -223,11 +223,9 @@ void ext4_free_inode (handle_t *handle, struct inode * inode)
 
 		if (gdp) {
 			spin_lock(sb_bgl_lock(sbi, block_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 (is_directory)
-				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);
 			gdp->bg_checksum = ext4_group_desc_csum(sbi,
 							block_group, gdp);
 			spin_unlock(sb_bgl_lock(sbi, block_group));
@@ -664,11 +662,9 @@ got:
 				cpu_to_le16(EXT4_INODES_PER_GROUP(sb) - ino);
 	}
 
-	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)) {
-		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);
 	}
 	gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp);
 	spin_unlock(sb_bgl_lock(sbi, group));
fs/ext4/mballoc.c +2 -5
index dd0fcfc..586a320 100644
@@ -3074,9 +3074,7 @@ static int ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
 						ac->ac_b_ex.fe_group,
 						gdp));
 	}
-	gdp->bg_free_blocks_count =
-		cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)
-				- ac->ac_b_ex.fe_len);
+	le16_add_cpu(&gdp->bg_free_blocks_count, -ac->ac_b_ex.fe_len);
 	gdp->bg_checksum = ext4_group_desc_csum(sbi, ac->ac_b_ex.fe_group, gdp);
 	spin_unlock(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group));
 	percpu_counter_sub(&sbi->s_freeblocks_counter, ac->ac_b_ex.fe_len);
@@ -4564,8 +4562,7 @@ do_more:
 	}
 
 	spin_lock(sb_bgl_lock(sbi, block_group));
-	gdp->bg_free_blocks_count =
-		cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count) + count);
+	le16_add_cpu(&gdp->bg_free_blocks_count, count);
 	gdp->bg_checksum = ext4_group_desc_csum(sbi, block_group, gdp);
 	spin_unlock(sb_bgl_lock(sbi, block_group));
 	percpu_counter_add(&sbi->s_freeblocks_counter, count);
fs/ext4/resize.c +2 -4
index 9477a2b..f9e716a 100644
@@ -502,8 +502,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
 	EXT4_SB(sb)->s_gdb_count++;
 	kfree(o_group_desc);
 
-	es->s_reserved_gdt_blocks =
-		cpu_to_le16(le16_to_cpu(es->s_reserved_gdt_blocks) - 1);
+	le16_add_cpu(&es->s_reserved_gdt_blocks, -1);
 	ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh);
 
 	return 0;
@@ -877,8 +876,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
 	 */
 	ext4_blocks_count_set(es, ext4_blocks_count(es) +
 		input->blocks_count);
-	es->s_inodes_count = cpu_to_le32(le32_to_cpu(es->s_inodes_count) +
-		EXT4_INODES_PER_GROUP(sb));
+	le32_add_cpu(&es->s_inodes_count, EXT4_INODES_PER_GROUP(sb));
 
 	/*
 	 * We need to protect s_groups_count against other CPUs seeing
fs/ext4/super.c +1 -1
index 6627ee0..5aa0a50 100644
@@ -1391,7 +1391,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
 #endif
 	if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
 		es->s_max_mnt_count = cpu_to_le16(EXT4_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);
 	es->s_mtime = cpu_to_le32(get_seconds());
 	ext4_update_dynamic_rev(sb);
 	EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
fs/ext4/xattr.c +2 -4
index d796213..fedaa4f 100644
@@ -484,8 +484,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
 		get_bh(bh);
 		ext4_forget(handle, 1, inode, bh, bh->b_blocknr);
 	} else {
-		BHDR(bh)->h_refcount = cpu_to_le32(
-				le32_to_cpu(BHDR(bh)->h_refcount) - 1);
+		le32_add_cpu(&BHDR(bh)->h_refcount, -1);
 		error = ext4_journal_dirty_metadata(handle, bh);
 		if (IS_SYNC(inode))
 			handle->h_sync = 1;
@@ -789,8 +788,7 @@ inserted:
 				if (error)
 					goto cleanup_dquot;
 				lock_buffer(new_bh);
-				BHDR(new_bh)->h_refcount = cpu_to_le32(1 +
-					le32_to_cpu(BHDR(new_bh)->h_refcount));
+				le32_add_cpu(&BHDR(new_bh)->h_refcount, 1);
 				ea_bdebug(new_bh, "reusing; refcount now=%d",
 					le32_to_cpu(BHDR(new_bh)->h_refcount));
 				unlock_buffer(new_bh);
Signature · 1 line
1.5.3.7
#2 lore raw

PATCH 1/1 reiserfs: le*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

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

---
 fs/reiserfs/objectid.c |    5 ++---
 fs/reiserfs/stree.c    |    3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)
fs/reiserfs/objectid.c +2 -3
index 65feba4..f0c1543 100644
@@ -114,7 +114,7 @@ void reiserfs_release_objectid(struct reiserfs_transaction_handle *th,
 		if (objectid_to_release == le32_to_cpu(map[i])) {
 			/* This incrementation unallocates the objectid. */
 			//map[i]++;
-			map[i] = cpu_to_le32(le32_to_cpu(map[i]) + 1);
+			le32_add_cpu(&map[i], 1);
 
 			/* Did we unallocate the last member of an odd sequence, and can shrink oids? */
 			if (map[i] == map[i + 1]) {
@@ -138,8 +138,7 @@ void reiserfs_release_objectid(struct reiserfs_transaction_handle *th,
 			/* size of objectid map is not changed */
 			if (objectid_to_release + 1 == le32_to_cpu(map[i + 1])) {
 				//objectid_map[i+1]--;
-				map[i + 1] =
-				    cpu_to_le32(le32_to_cpu(map[i + 1]) - 1);
+				le32_add_cpu(&map[i + 1], -1);
 				return;
 			}
 
fs/reiserfs/stree.c +1 -2
index d2db241..abbc64d 100644
@@ -1419,8 +1419,7 @@ int reiserfs_delete_object(struct reiserfs_transaction_handle *th,
 
 		inode_generation =
 		    &REISERFS_SB(th->t_super)->s_rs->s_inode_generation;
-		*inode_generation =
-		    cpu_to_le32(le32_to_cpu(*inode_generation) + 1);
+		le32_add_cpu(inode_generation, 1);
 	}
 /* USE_INODE_GENERATION_COUNTER */
 #endif
Signature · 1 line
1.5.3.7
#3 lore raw

PATCH 1/1 crypto: be*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

Cc Herbert Xu <[email protected]>
Cc David S. Miller <[email protected]>
---
 crypto/lrw.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
crypto/lrw.c +1 -1
index 9d52e58..4d93928 100644
@@ -92,7 +92,7 @@ struct sinfo {
 static inline void inc(be128 *iv)
 {
 	if (!(iv->b = cpu_to_be64(be64_to_cpu(iv->b) + 1)))
-		iv->a = cpu_to_be64(be64_to_cpu(iv->a) + 1);
+		be64_add_cpu(&iv->a, 1);
 }
 
 static inline void lrw_round(struct sinfo *s, void *dst, const void *src)
Signature · 1 line
1.5.3.7
#4 lore raw

Re: [PATCH] crypto: be*_add_cpu conversion

Quoted 21 lines · [email protected] wrote:

From: Marcin Slusarz <[email protected]>

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

Cc Herbert Xu <[email protected]>
Cc David S. Miller <[email protected]>
---
 crypto/lrw.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
crypto/lrw.c +0 -0
index 9d52e58..4d93928 100644

crypto/lrw.c struct sinfo { · line 94

Quoted 3 lines
crypto/lrw.c +0 -0
@@ -92,7 +92,7 @@ struct sinfo {
 static inline void inc(be128 *iv)
 {
 	if (!(iv->b = cpu_to_be64(be64_to_cpu(iv->b) + 1)))

maybe you also want instead of the line above:

	be64_add_cpu(&iv->b, 1);
	if (!iv->b)
Quoted 5 lines
crypto/lrw.c +1 -1
-		iv->a = cpu_to_be64(be64_to_cpu(iv->a) + 1);
+		be64_add_cpu(&iv->a, 1);
 }
 
 static inline void lrw_round(struct sinfo *s, void *dst, const void *src)
#5 lore raw

Re: [PATCH] crypto: be*_add_cpu conversion

Quoted 28 lines · Roel Kluin
Quoted 21 lines · [email protected] wrote:

From: Marcin Slusarz <[email protected]>

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

Cc Herbert Xu <[email protected]>
Cc David S. Miller <[email protected]>
---
 crypto/lrw.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
crypto/lrw.c +0 -0
index 9d52e58..4d93928 100644

crypto/lrw.c struct sinfo { · line 94

Quoted 3 lines
crypto/lrw.c +0 -0
@@ -92,7 +92,7 @@ struct sinfo {
 static inline void inc(be128 *iv)
 {
 	if (!(iv->b = cpu_to_be64(be64_to_cpu(iv->b) + 1)))

maybe you also want instead of the line above:

Quoted 9 lines
	be64_add_cpu(&iv->b, 1);
	if (!iv->b)

crypto/lrw.c struct sinfo { · line 98

Quoted 5 lines
crypto/lrw.c +1 -1
-		iv->a = cpu_to_be64(be64_to_cpu(iv->a) + 1);
+		be64_add_cpu(&iv->a, 1);
 }
 
 static inline void lrw_round(struct sinfo *s, void *dst, const void *src)

I'm a bit ashamed... but here is updated patch:
---
crypto: replace all adds to big endians variables with be*_add_cpu

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);
Cc Herbert Xu <[email protected]>
Cc David S. Miller <[email protected]>
Cc Roel Kluin <[email protected]>
---
 crypto/lrw.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
crypto/lrw.c +3 -2
index 9d52e58..8ef664e 100644
@@ -91,8 +91,9 @@ struct sinfo {
 
 static inline void inc(be128 *iv)
 {
-	if (!(iv->b = cpu_to_be64(be64_to_cpu(iv->b) + 1)))
-		iv->a = cpu_to_be64(be64_to_cpu(iv->a) + 1);
+	be64_add_cpu(&iv->b, 1);
+	if (!iv->b)
+		be64_add_cpu(&iv->a, 1);
 }
 
 static inline void lrw_round(struct sinfo *s, void *dst, const void *src)
Signature · 1 line
1.5.3.7
maintainer
#6 lore raw

Re: [PATCH] crypto: be*_add_cpu conversion

Quoted 5 lines · Marcin Slusarz

crypto: replace all adds to big endians variables with be*_add_cpu

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

Quoted 8 lines
					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);
Cc Herbert Xu <[email protected]>
Cc David S. Miller <[email protected]>
Cc Roel Kluin <[email protected]>

Patch applied. Thanks a lot!

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#7 lore raw

PATCH 1/1 ieee 1394: be*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

Cc Ben Collins <[email protected]>
Cc Stefan Richter <[email protected]>
---
 drivers/ieee1394/csr.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/ieee1394/csr.c +2 -4
index 52ac83e..c90be40 100644
@@ -133,8 +133,7 @@ static void host_reset(struct hpsb_host *host)
                 host->csr.state &= ~0x100;
         }
 
-        host->csr.topology_map[1] =
-                cpu_to_be32(be32_to_cpu(host->csr.topology_map[1]) + 1);
+	be32_add_cpu(&host->csr.topology_map[1], 1);
         host->csr.topology_map[2] = cpu_to_be32(host->node_count << 16
                                                 | host->selfid_count);
         host->csr.topology_map[0] =
@@ -142,8 +141,7 @@ static void host_reset(struct hpsb_host *host)
                             | csr_crc16(host->csr.topology_map + 1,
                                         host->selfid_count + 2));
 
-        host->csr.speed_map[1] =
-                cpu_to_be32(be32_to_cpu(host->csr.speed_map[1]) + 1);
+	be32_add_cpu(&host->csr.speed_map[1], 1);
         host->csr.speed_map[0] = cpu_to_be32(0x3f1 << 16
                                              | csr_crc16(host->csr.speed_map+1,
                                                          0x3f1));
Signature · 1 line
1.5.3.7
#8 lore raw

Re: [PATCH] ieee 1394: be*_add_cpu conversion

Quoted 5 lines · [email protected] wrote:

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);

Committed to linux1394-2.6.git. Thanks,

Signature · 3 lines
Stefan Richter
-=====-==--- --=- =----
http://arcgraph.de/sr/
#9 lore raw

PATCH 1/1 infiniband: be*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

Cc Roland Dreier <[email protected]>
Cc Sean Hefty <[email protected]>
Cc Hal Rosenstock <[email protected]>
---
 drivers/infiniband/hw/mthca/mthca_cq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/infiniband/hw/mthca/mthca_cq.c +1 -1
index 6bd9f13..1e1e336 100644
@@ -473,7 +473,7 @@ static void handle_error_cqe(struct mthca_dev *dev, struct mthca_cq *cq,
 	if (!(new_wqe & cpu_to_be32(0x3f)) || (!cqe->db_cnt && dbd))
 		return;
 
-	cqe->db_cnt   = cpu_to_be16(be16_to_cpu(cqe->db_cnt) - dbd);
+	be16_add_cpu(&cqe->db_cnt, -dbd);
 	cqe->wqe      = new_wqe;
 	cqe->syndrome = SYNDROME_WR_FLUSH_ERR;
 
Signature · 1 line
1.5.3.7
#11 lore raw

PATCH 1/1 affs: be*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

---
 fs/affs/file.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/affs/file.c +2 -2
index 6e0c939..95b48af 100644
@@ -543,7 +543,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize)
 		if (boff + tmp > bsize || tmp > bsize)
 			BUG();
 		memset(AFFS_DATA(bh) + boff, 0, tmp);
-		AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp);
+		be32_add_cpu(&AFFS_DATA_HEAD(bh)->size, tmp);
 		affs_fix_checksum(sb, bh);
 		mark_buffer_dirty_inode(bh, inode);
 		size += tmp;
@@ -686,7 +686,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
 		if (boff + tmp > bsize || tmp > bsize)
 			BUG();
 		memcpy(AFFS_DATA(bh) + boff, data + from, tmp);
-		AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp);
+		be32_add_cpu(&AFFS_DATA_HEAD(bh)->size, tmp);
 		affs_fix_checksum(sb, bh);
 		mark_buffer_dirty_inode(bh, inode);
 		written += tmp;
Signature · 1 line
1.5.3.7
#12 lore raw

PATCH 1/1 gfs2: be*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

---
 fs/gfs2/dir.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
fs/gfs2/dir.c +3 -3
index c347095..6f2e382 100644
@@ -1021,13 +1021,13 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
 
 			new->de_inum = dent->de_inum; /* No endian worries */
 			new->de_type = dent->de_type; /* No endian worries */
-			nleaf->lf_entries = cpu_to_be16(be16_to_cpu(nleaf->lf_entries)+1);
+			be16_add_cpu(&nleaf->lf_entries, 1);
 
 			dirent_del(dip, obh, prev, dent);
 
 			if (!oleaf->lf_entries)
 				gfs2_consist_inode(dip);
-			oleaf->lf_entries = cpu_to_be16(be16_to_cpu(oleaf->lf_entries)-1);
+			be16_add_cpu(&oleaf->lf_entries, -1);
 
 			if (!prev)
 				prev = dent;
@@ -1616,7 +1616,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
 			dent->de_type = cpu_to_be16(type);
 			if (ip->i_di.di_flags & GFS2_DIF_EXHASH) {
 				leaf = (struct gfs2_leaf *)bh->b_data;
-				leaf->lf_entries = cpu_to_be16(be16_to_cpu(leaf->lf_entries) + 1);
+				be16_add_cpu(&leaf->lf_entries, 1);
 			}
 			brelse(bh);
 			error = gfs2_meta_inode_buffer(ip, &bh);
Signature · 1 line
1.5.3.7
#13 lore raw

Re: [PATCH] gfs2: be*_add_cpu conversion

Hi,

Now in the GFS2 -nmw git tree. Thanks,

Steve.

Quoted 45 lines · marcin.slusarz at gmail.com

From: Marcin Slusarz <[email protected]>

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

Cc Steven Whitehouse <[email protected]>
Cc cluster-devel at redhat.com
---
 fs/gfs2/dir.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
fs/gfs2/dir.c +3 -3
index c347095..6f2e382 100644
@@ -1021,13 +1021,13 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
 
 			new->de_inum = dent->de_inum; /* No endian worries */
 			new->de_type = dent->de_type; /* No endian worries */
-			nleaf->lf_entries = cpu_to_be16(be16_to_cpu(nleaf->lf_entries)+1);
+			be16_add_cpu(&nleaf->lf_entries, 1);
 
 			dirent_del(dip, obh, prev, dent);
 
 			if (!oleaf->lf_entries)
 				gfs2_consist_inode(dip);
-			oleaf->lf_entries = cpu_to_be16(be16_to_cpu(oleaf->lf_entries)-1);
+			be16_add_cpu(&oleaf->lf_entries, -1);
 
 			if (!prev)
 				prev = dent;
@@ -1616,7 +1616,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
 			dent->de_type = cpu_to_be16(type);
 			if (ip->i_di.di_flags & GFS2_DIF_EXHASH) {
 				leaf = (struct gfs2_leaf *)bh->b_data;
-				leaf->lf_entries = cpu_to_be16(be16_to_cpu(leaf->lf_entries) + 1);
+				be16_add_cpu(&leaf->lf_entries, 1);
 			}
 			brelse(bh);
 			error = gfs2_meta_inode_buffer(ip, &bh);
#14 lore raw

PATCH 1/1 ipw2200: le*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

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

---
 drivers/net/wireless/ipw2200.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/net/wireless/ipw2200.c +1 -3
index 3e6ad7b..5d9854e 100644
@@ -10326,9 +10326,7 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
 					 remaining_bytes,
 					 PCI_DMA_TODEVICE));
 
-			tfd->u.data.num_chunks =
-			    cpu_to_le32(le32_to_cpu(tfd->u.data.num_chunks) +
-					1);
+			le32_add_cpu(&tfd->u.data.num_chunks, 1);
 		}
 	}
 
Signature · 1 line
1.5.3.7
#15 lore raw

RE: [PATCH] ipw2200: le*_add_cpu conversion

Quoted 37 lines · On Tuesday, February 12, 2008 3:06 PM, [email protected]…

From: Marcin Slusarz <[email protected]>

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

---
drivers/net/wireless/ipw2200.c | 4 +---

1 files changed, 1 insertions(+), 3 deletions(-)
drivers/net/wireless/ipw2200.c +0 -2
index 3e6ad7b..5d9854e 100644
@@ -10326,9 +10326,7 @@ static int ipw_tx_skb(struct ipw_priv
 *priv, struct ieee80211_txb *txb,
 					 remaining_bytes,
 					 PCI_DMA_TODEVICE));
 
-			tfd->u.data.num_chunks =
-

cpu_to_le32(le32_to_cpu(tfd->u.data.num_chunks) +

drivers/net/wireless/ipw2200.c +1 -1
-					1);
+			le32_add_cpu(&tfd->u.data.num_chunks, 1);
		}
	}
Quoted 2 lines

--
1.5.3.7

Thanks!

Reinette

#16 lore raw

PATCH 1/1 hfs/hfsplus: be*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

replace all:
big_endian_variable = cpu_to_beX(beX_to_cpu(big_endian_variable) +

					expression_in_cpu_byteorder);
with:
	beX_add_cpu(&big_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

---
 fs/hfs/mdb.c       |    2 +-
 fs/hfsplus/super.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/hfs/mdb.c +1 -1
index b4651e1..36ca2e1 100644
@@ -215,7 +215,7 @@ int hfs_mdb_get(struct super_block *sb)
 		attrib &= cpu_to_be16(~HFS_SB_ATTRIB_UNMNT);
 		attrib |= cpu_to_be16(HFS_SB_ATTRIB_INCNSTNT);
 		mdb->drAtrb = attrib;
-		mdb->drWrCnt = cpu_to_be32(be32_to_cpu(mdb->drWrCnt) + 1);
+		be32_add_cpu(&mdb->drWrCnt, 1);
 		mdb->drLsMod = hfs_mtime();
 
 		mark_buffer_dirty(HFS_SB(sb)->mdb_bh);
fs/hfsplus/super.c +1 -1
index b0f9ad3..068523b 100644
@@ -423,7 +423,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
 	 */
 	vhdr->last_mount_vers = cpu_to_be32(HFSP_MOUNT_VERSION);
 	vhdr->modify_date = hfsp_now2mt();
-	vhdr->write_count = cpu_to_be32(be32_to_cpu(vhdr->write_count) + 1);
+	be32_add_cpu(&vhdr->write_count, 1);
 	vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_UNMNT);
 	vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_INCNSTNT);
 	mark_buffer_dirty(HFSPLUS_SB(sb).s_vhbh);
Signature · 1 line
1.5.3.7
#17 lore raw

PATCH 1/1 scsi: le*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

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

---
 drivers/scsi/aacraid/commsup.c |    2 +-
 drivers/scsi/ips.c             |    8 ++------
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/scsi/aacraid/commsup.c +1 -1
index 81b3692..3ac8c82 100644
@@ -594,7 +594,7 @@ void aac_consumer_free(struct aac_dev * dev, struct aac_queue *q, u32 qid)
 	if (le32_to_cpu(*q->headers.consumer) >= q->entries)
 		*q->headers.consumer = cpu_to_le32(1);
 	else
-		*q->headers.consumer = cpu_to_le32(le32_to_cpu(*q->headers.consumer)+1);
+		le32_add_cpu(q->headers.consumer, 1);
 
 	if (wasfull) {
 		switch (qid) {
drivers/scsi/ips.c +2 -6
index bb152fb..f45770a 100644
@@ -3696,9 +3696,7 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb)
 			scb->cmd.basic_io.sg_count = scb->sg_len;
 
 			if (scb->cmd.basic_io.lba)
-				scb->cmd.basic_io.lba =
-				    cpu_to_le32(le32_to_cpu
-						(scb->cmd.basic_io.lba) +
+				le32_add_cpu(&scb->cmd.basic_io.lba,
 						le16_to_cpu(scb->cmd.basic_io.
 							    sector_count));
 			else
@@ -3744,9 +3742,7 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb)
 			scb->cmd.basic_io.sg_count = scb->sg_len;
 
 			if (scb->cmd.basic_io.lba)
-				scb->cmd.basic_io.lba =
-				    cpu_to_le32(le32_to_cpu
-						(scb->cmd.basic_io.lba) +
+				le32_add_cpu(&scb->cmd.basic_io.lba,
 						le16_to_cpu(scb->cmd.basic_io.
 							    sector_count));
 			else
Signature · 1 line
1.5.3.7
#18 lore raw

RE: [PATCH] scsi: le*_add_cpu conversion

ACK

Sincerely -- Mark Salyzyn

Quoted 78 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Tuesday, February 12, 2008 6:06 PM
To: LKML
Cc: Marcin Slusarz; [email protected]; AACRAID; [email protected]
Subject: [PATCH] scsi: le*_add_cpu conversion

From: Marcin Slusarz <[email protected]>

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

---
 drivers/scsi/aacraid/commsup.c |    2 +-
 drivers/scsi/ips.c             |    8 ++------
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/scsi/aacraid/commsup.c +1 -1
index 81b3692..3ac8c82 100644
@@ -594,7 +594,7 @@ void aac_consumer_free(struct aac_dev *
 dev, struct aac_queue *q, u32 qid)
        if (le32_to_cpu(*q->headers.consumer) >= q->entries)
                *q->headers.consumer = cpu_to_le32(1);
        else
-               *q->headers.consumer =
 cpu_to_le32(le32_to_cpu(*q->headers.consumer)+1);
+               le32_add_cpu(q->headers.consumer, 1);
 
        if (wasfull) {
                switch (qid) {
drivers/scsi/ips.c +0 -3
index bb152fb..f45770a 100644
@@ -3696,9 +3696,7 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb)
                        scb->cmd.basic_io.sg_count = scb->sg_len;
 
                        if (scb->cmd.basic_io.lba)
-                               scb->cmd.basic_io.lba =
-                                   cpu_to_le32(le32_to_cpu
-

(scb->cmd.basic_io.lba) +
+ le32_add_cpu(&scb->cmd.basic_io.lba,

le16_to_cpu(scb->cmd.basic_io.

sector_count));
else

drivers/scsi/ips.c +0 -3
@@ -3744,9 +3742,7 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb)
                        scb->cmd.basic_io.sg_count = scb->sg_len;
 
                        if (scb->cmd.basic_io.lba)
-                               scb->cmd.basic_io.lba =
-                                   cpu_to_le32(le32_to_cpu
-

(scb->cmd.basic_io.lba) +
+ le32_add_cpu(&scb->cmd.basic_io.lba,

le16_to_cpu(scb->cmd.basic_io.

sector_count));
else
--
1.5.3.7

#19 lore raw

PATCH 1/1 ext2: le*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

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

---
 fs/ext2/ialloc.c |   12 ++++--------
 fs/ext2/super.c  |    2 +-
 fs/ext2/xattr.c  |    9 +++------
 3 files changed, 8 insertions(+), 15 deletions(-)
fs/ext2/ialloc.c +4 -8
index 5deb8b7..0f3e3f3 100644
@@ -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]--;
fs/ext2/super.c +1 -1
index 108f739..7e68673 100644
@@ -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, "
fs/ext2/xattr.c +3 -6
index 3e8683d..495ec0d 100644
@@ -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",
Signature · 1 line
1.5.3.7
#20 lore raw

PATCH 1/1 ocfs2: le*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

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

Cc Mark Fasheh <[email protected]>
Cc Kurt Hackel <[email protected]>
Cc ocfs2-devel at oss.oracle.com
---
 fs/ocfs2/dir.c        |    5 ++---
 fs/ocfs2/localalloc.c |    3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)
fs/ocfs2/dir.c +2 -3
index e280833..8a18758 100644
@@ -390,9 +390,8 @@ static int __ocfs2_delete_entry(handle_t *handle, struct inode *dir,
 				goto bail;
 			}
 			if (pde)
-				pde->rec_len =
-					cpu_to_le16(le16_to_cpu(pde->rec_len) +
-						    le16_to_cpu(de->rec_len));
+				le16_add_cpu(&pde->rec_len,
+						le16_to_cpu(de->rec_len));
 			else
 				de->inode = 0;
 			dir->i_version++;
fs/ocfs2/localalloc.c +1 -2
index add1ffd..d0e217e 100644
@@ -588,8 +588,7 @@ int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb,
 	while(bits_wanted--)
 		ocfs2_set_bit(start++, bitmap);
 
-	alloc->id1.bitmap1.i_used = cpu_to_le32(*num_bits +
-				le32_to_cpu(alloc->id1.bitmap1.i_used));
+	le32_add_cpu(&alloc->id1.bitmap1.i_used, *num_bits);
 
 	status = ocfs2_journal_dirty(handle, osb->local_alloc_bh);
 	if (status < 0) {
Signature · 1 line
1.5.3.7
#21 lore raw

Re: [PATCH] ocfs2: le*_add_cpu conversion

Quoted 8 lines · On Wed, Feb 13, 2008 at 12:06:18AM +0100, [email protected] wrote:

From: Marcin Slusarz <[email protected]>

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

Thanks, this is in ocfs2.git now.

	--Mark

--
Mark Fasheh
Principal Software Developer, Oracle
[email protected]

#22 lore raw

PATCH 1/1 jfs: le*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

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

---
 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(-)
fs/jfs/jfs_dmap.c +5 -6
index e198506..2bc7d8a 100644
@@ -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 */
fs/jfs/jfs_imap.c +6 -9
index 9bf29f7..734ec91 100644
@@ -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.
 	 */
fs/jfs/jfs_xtree.c +8 -18
index a000aaa..5a61ebf 100644
@@ -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);
 		}
Signature · 1 line
1.5.3.7
#23 lore raw

Re: [PATCH] jfs: le*_add_cpu conversion

Quoted 4 lines · On Wed, 2008-02-13 at 00:06 +0100, [email protected] wrote:

From: Marcin Slusarz <[email protected]>

replace all:
little_endian_variable = cpu_to_leX(leX_to_cpu(little_endian_variable) +

Quoted 8 lines
					expression_in_cpu_byteorder);
with:
	leX_add_cpu(&little_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

Applied to the jfs git tree.

Thanks,
Shaggy

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center
#24 lore raw

PATCH 1/1 ntfs: le*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

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

---
 fs/ntfs/upcase.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
fs/ntfs/upcase.c +2 -3
index 9101807..e2f72ca 100644
@@ -77,11 +77,10 @@ ntfschar *generate_default_upcase(void)
 		uc[i] = cpu_to_le16(i);
 	for (r = 0; uc_run_table[r][0]; r++)
 		for (i = uc_run_table[r][0]; i < uc_run_table[r][1]; i++)
-			uc[i] = cpu_to_le16(le16_to_cpu(uc[i]) +
-					uc_run_table[r][2]);
+			le16_add_cpu(&uc[i], uc_run_table[r][2]);
 	for (r = 0; uc_dup_table[r][0]; r++)
 		for (i = uc_dup_table[r][0]; i < uc_dup_table[r][1]; i += 2)
-			uc[i + 1] = cpu_to_le16(le16_to_cpu(uc[i + 1]) - 1);
+			le16_add_cpu(&uc[i + 1], -1);
 	for (r = 0; uc_word_table[r][0]; r++)
 		uc[uc_word_table[r][0]] = cpu_to_le16(uc_word_table[r][1]);
 	return uc;
Signature · 1 line
1.5.3.7
#25 lore raw

PATCH 1/1 quota: le*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

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

---
 fs/quota_v2.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/quota_v2.c +2 -2
index c519a58..a9f9eef 100644
@@ -303,7 +303,7 @@ static uint find_free_dqentry(struct dquot *dquot, int *err)
 			printk(KERN_ERR "VFS: find_free_dqentry(): Can't remove block (%u) from entry free list.\n", blk);
 			goto out_buf;
 		}
-	dh->dqdh_entries = cpu_to_le16(le16_to_cpu(dh->dqdh_entries)+1);
+	le16_add_cpu(&dh->dqdh_entries, 1);
 	memset(&fakedquot, 0, sizeof(struct v2_disk_dqblk));
 	/* Find free structure in block */
 	for (i = 0; i < V2_DQSTRINBLK && memcmp(&fakedquot, ddquot+i, sizeof(struct v2_disk_dqblk)); i++);
@@ -445,7 +445,7 @@ static int free_dqentry(struct dquot *dquot, uint blk)
 		goto out_buf;
 	}
 	dh = (struct v2_disk_dqdbheader *)buf;
-	dh->dqdh_entries = cpu_to_le16(le16_to_cpu(dh->dqdh_entries)-1);
+	le16_add_cpu(&dh->dqdh_entries, -1);
 	if (!le16_to_cpu(dh->dqdh_entries)) {	/* Block got free? */
 		if ((ret = remove_free_dqentry(sb, type, buf, blk)) < 0 ||
 		    (ret = put_free_dqblk(sb, type, buf, blk)) < 0) {
Signature · 1 line
1.5.3.7
reviewer Acked-by on v1 1/1
#26 lore raw

Re: [PATCH] quota: le*_add_cpu conversion

Quoted 11 lines · On Wed 13-02-08 00:06:19, [email protected] wrote:

From: Marcin Slusarz <[email protected]>

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

Honza

Quoted 29 lines
---
 fs/quota_v2.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/quota_v2.c +2 -2
index c519a58..a9f9eef 100644
@@ -303,7 +303,7 @@ static uint find_free_dqentry(struct dquot *dquot, int *err)
 			printk(KERN_ERR "VFS: find_free_dqentry(): Can't remove block (%u) from entry free list.\n", blk);
 			goto out_buf;
 		}
-	dh->dqdh_entries = cpu_to_le16(le16_to_cpu(dh->dqdh_entries)+1);
+	le16_add_cpu(&dh->dqdh_entries, 1);
 	memset(&fakedquot, 0, sizeof(struct v2_disk_dqblk));
 	/* Find free structure in block */
 	for (i = 0; i < V2_DQSTRINBLK && memcmp(&fakedquot, ddquot+i, sizeof(struct v2_disk_dqblk)); i++);
@@ -445,7 +445,7 @@ static int free_dqentry(struct dquot *dquot, uint blk)
 		goto out_buf;
 	}
 	dh = (struct v2_disk_dqdbheader *)buf;
-	dh->dqdh_entries = cpu_to_le16(le16_to_cpu(dh->dqdh_entries)-1);
+	le16_add_cpu(&dh->dqdh_entries, -1);
 	if (!le16_to_cpu(dh->dqdh_entries)) {	/* Block got free? */
 		if ((ret = remove_free_dqentry(sb, type, buf, blk)) < 0 ||
 		    (ret = put_free_dqblk(sb, type, buf, blk)) < 0) {
Signature · 1 line
1.5.3.7
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#27 lore raw

PATCH 1/1 sysv: [bl]e*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

replace all:
big/little_endian_variable = cpu_to_[bl]eX([bl]eX_to_cpu(big/little_endian_variable) +

					expression_in_cpu_byteorder);
with:
	[bl]eX_add_cpu(&big/little_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

Cc Christoph Hellwig <[email protected]>
---
 fs/sysv/sysv.h |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
fs/sysv/sysv.h +4 -4
index 42d51d1..38ebe3f 100644
@@ -217,9 +217,9 @@ static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d)
 	if (sbi->s_bytesex == BYTESEX_PDP)
 		*(__u32*)n = PDP_swab(PDP_swab(*(__u32*)n)+d);
 	else if (sbi->s_bytesex == BYTESEX_LE)
-		*(__le32*)n = cpu_to_le32(le32_to_cpu(*(__le32*)n)+d);
+		le32_add_cpu((__le32 *)n, d);
 	else
-		*(__be32*)n = cpu_to_be32(be32_to_cpu(*(__be32*)n)+d);
+		be32_add_cpu((__be32 *)n, d);
 	return *n;
 }
 
@@ -242,9 +242,9 @@ static inline __fs16 cpu_to_fs16(struct sysv_sb_info *sbi, __u16 n)
 static inline __fs16 fs16_add(struct sysv_sb_info *sbi, __fs16 *n, int d)
 {
 	if (sbi->s_bytesex != BYTESEX_BE)
-		*(__le16*)n = cpu_to_le16(le16_to_cpu(*(__le16 *)n)+d);
+		le16_add_cpu((__le16 *)n, d);
 	else
-		*(__be16*)n = cpu_to_be16(be16_to_cpu(*(__be16 *)n)+d);
+		be16_add_cpu((__be16 *)n, d);
 	return *n;
 }
 
Signature · 1 line
1.5.3.7
#28 lore raw

Re: [PATCH] sysv: [bl]e*_add_cpu conversion

Quoted 8 lines · On Wed, Feb 13, 2008 at 12:06:21AM +0100, [email protected] wrote:

From: Marcin Slusarz <[email protected]>

replace all:
big/little_endian_variable = cpu_to_[bl]eX([bl]eX_to_cpu(big/little_endian_variable) +

					expression_in_cpu_byteorder);
with:
	[bl]eX_add_cpu(&big/little_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

The patch looks correct to me, so ACK.

Quoted 5 lines
fs/sysv/sysv.h +0 -0
index 42d51d1..38ebe3f 100644

fs/sysv/sysv.h static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d) · line 223

Quoted 9 lines
fs/sysv/sysv.h +2 -2
@@ -217,9 +217,9 @@ static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d)
 	if (sbi->s_bytesex == BYTESEX_PDP)
 		*(__u32*)n = PDP_swab(PDP_swab(*(__u32*)n)+d);
 	else if (sbi->s_bytesex == BYTESEX_LE)
-		*(__le32*)n = cpu_to_le32(le32_to_cpu(*(__le32*)n)+d);
+		le32_add_cpu((__le32 *)n, d);
 	else
-		*(__be32*)n = cpu_to_be32(be32_to_cpu(*(__be32*)n)+d);
+		be32_add_cpu((__be32 *)n, d);
 	return *n;

but now that you've named the be and le primitives *_add_cpu it would be nice if you could submit a second patch to sysv to rename fs*_add to fs*_add_cpu aswell.

#29 lore raw

Re: [PATCH] sysv: [bl]e*_add_cpu conversion

Quoted 10 lines · Christoph Hellwig
Quoted 10 lines
fs/sysv/sysv.h +1 -1
index 42d51d1..38ebe3f 100644
@@ -217,9 +217,9 @@ static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d)
 	if (sbi->s_bytesex == BYTESEX_PDP)
 		*(__u32*)n = PDP_swab(PDP_swab(*(__u32*)n)+d);
 	else if (sbi->s_bytesex == BYTESEX_LE)
-		*(__le32*)n = cpu_to_le32(le32_to_cpu(*(__le32*)n)+d);
+		le32_add_cpu((__le32 *)n, d);
Quoted 8 lines

fs/sysv/sysv.h static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d) · line 223

Quoted 4 lines
fs/sysv/sysv.h +1 -1
 	else
-		*(__be32*)n = cpu_to_be32(be32_to_cpu(*(__be32*)n)+d);
+		be32_add_cpu((__be32 *)n, d);
 	return *n;

but now that you've named the be and le primitives *_add_cpu it would be nice if you could submit a second patch to sysv to rename fs*_add to fs*_add_cpu aswell.

Btw, the same applies to ufs aswell as it's using the same construct.

#30 lore raw

PATCH 1/1 ufs: [bl]e*_add_cpu conversion

In reply to [email protected]

From: Marcin Slusarz <[email protected]>

replace all:
big/little_endian_variable = cpu_to_[bl]eX([bl]eX_to_cpu(big/little_endian_variable) +

					expression_in_cpu_byteorder);
with:
	[bl]eX_add_cpu(&big/little_endian_variable, expression_in_cpu_byteorder);

generated with semantic patch

Cc Evgeniy Dushistov <[email protected]>
---
 fs/ufs/swab.h |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
fs/ufs/swab.h +8 -8
index 1683d2b..a4340d0 100644
@@ -80,18 +80,18 @@ static inline void
 fs32_add(struct super_block *sbp, __fs32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		*(__le32 *)n = cpu_to_le32(le32_to_cpu(*(__le32 *)n)+d);
+		le32_add_cpu((__le32 *)n, d);
 	else
-		*(__be32 *)n = cpu_to_be32(be32_to_cpu(*(__be32 *)n)+d);
+		be32_add_cpu((__be32 *)n, d);
 }
 
 static inline void
 fs32_sub(struct super_block *sbp, __fs32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		*(__le32 *)n = cpu_to_le32(le32_to_cpu(*(__le32 *)n)-d);
+		le32_add_cpu((__le32 *)n, -d);
 	else
-		*(__be32 *)n = cpu_to_be32(be32_to_cpu(*(__be32 *)n)-d);
+		be32_add_cpu((__be32 *)n, -d);
 }
 
 static inline u16
@@ -116,18 +116,18 @@ static inline void
 fs16_add(struct super_block *sbp, __fs16 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		*(__le16 *)n = cpu_to_le16(le16_to_cpu(*(__le16 *)n)+d);
+		le16_add_cpu((__le16 *)n, d);
 	else
-		*(__be16 *)n = cpu_to_be16(be16_to_cpu(*(__be16 *)n)+d);
+		be16_add_cpu((__be16 *)n, d);
 }
 
 static inline void
 fs16_sub(struct super_block *sbp, __fs16 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		*(__le16 *)n = cpu_to_le16(le16_to_cpu(*(__le16 *)n)-d);
+		le16_add_cpu((__le16 *)n, -d);
 	else
-		*(__be16 *)n = cpu_to_be16(be16_to_cpu(*(__be16 *)n)-d);
+		be16_add_cpu((__be16 *)n, -d);
 }
 
 #endif /* _UFS_SWAB_H */
Signature · 1 line
1.5.3.7
#31 lore raw

Re: [PATCH] ufs: [bl]e*_add_cpu conversion

Quoted 5 lines · [email protected] wrote:

replace all:
big/little_endian_variable = cpu_to_[bl]eX([bl]eX_to_cpu(big/little_endian_variable) +

					expression_in_cpu_byteorder);
with:
	[bl]eX_add_cpu(&big/little_endian_variable, expression_in_cpu_byteorder);

you may also want these:
---
[bl]e_add_cpu conversion in return

---

fs/ufs/swab.h +8 -4
index 1683d2b..a1e3000 100644
@@ -44,18 +44,22 @@ static __inline u32
 fs64_add(struct super_block *sbp, u32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		return *n = cpu_to_le64(le64_to_cpu(*n)+d);
+		le64_add_cpu(n, d);
 	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)+d);
+		be64_add_cpu(n, d);
+
+	return *n;
 }
 
 static __inline u32
 fs64_sub(struct super_block *sbp, u32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		return *n = cpu_to_le64(le64_to_cpu(*n)-d);
+		le64_add_cpu(n, -d);
 	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)-d);
+		be64_add_cpu(n, -d);
+
+	return *n;
 }
 
 static __inline u32
author Acked-by
#32 lore raw

Re: [PATCH] ufs: [bl]e*_add_cpu conversion

Quoted 7 lines · Roel Kluin
Quoted 5 lines · [email protected] wrote:

replace all:
big/little_endian_variable = cpu_to_[bl]eX([bl]eX_to_cpu(big/little_endian_variable) +

					expression_in_cpu_byteorder);
with:
	[bl]eX_add_cpu(&big/little_endian_variable, expression_in_cpu_byteorder);
Quoted 5 lines

you may also want these:
---
[bl]e_add_cpu conversion in return

Quoted 33 lines

---

fs/ufs/swab.h +8 -4
index 1683d2b..a1e3000 100644
@@ -44,18 +44,22 @@ static __inline u32
 fs64_add(struct super_block *sbp, u32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		return *n = cpu_to_le64(le64_to_cpu(*n)+d);
+		le64_add_cpu(n, d);
 	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)+d);
+		be64_add_cpu(n, d);
+
+	return *n;
 }
 
 static __inline u32
 fs64_sub(struct super_block *sbp, u32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		return *n = cpu_to_le64(le64_to_cpu(*n)-d);
+		le64_add_cpu(n, -d);
 	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)-d);
+		be64_add_cpu(n, -d);
+
+	return *n;
 }
 
 static __inline u32
#33 lore raw

Re: [PATCH] ufs: [bl]e*_add_cpu conversion

In reply to Roel Kluin
Quoted 27 lines · On Wed, 13 Feb 2008 10:41:44 +0100 Roel Kluin <[email protected]> wrote:

you may also want these:
---
[bl]e_add_cpu conversion in return

---

fs/ufs/swab.h +4 -2
index 1683d2b..a1e3000 100644
@@ -44,18 +44,22 @@ static __inline u32
 fs64_add(struct super_block *sbp, u32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		return *n = cpu_to_le64(le64_to_cpu(*n)+d);
+		le64_add_cpu(n, d);
 	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)+d);
+		be64_add_cpu(n, d);
+
+	return *n;
 }
 
 static __inline u32
 fs64_sub(struct super_block *sbp, u32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)

fs/ufs/swab.h static __inline u32 · line 65

Quoted 10 lines
fs/ufs/swab.h +4 -2
-		return *n = cpu_to_le64(le64_to_cpu(*n)-d);
+		le64_add_cpu(n, -d);
 	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)-d);
+		be64_add_cpu(n, -d);
+
+	return *n;
 }
 
 static __inline u32

upsets powerpc (at least):

fs/ufs/swab.h: In function `fs64_add':
fs/ufs/swab.h:47: warning: passing arg 1 of le64_add_cpu' from incompatible pointer type fs/ufs/swab.h:49: warning: passing arg 1 of be64_add_cpu' from incompatible pointer type fs/ufs/swab.h: In function `fs64_sub':
fs/ufs/swab.h:58: warning: passing arg 1 of le64_add_cpu' from incompatible pointer type fs/ufs/swab.h:60: warning: passing arg 1 of be64_add_cpu' from incompatible pointer type

#34 lore raw

Re: [PATCH] ufs: [bl]e*_add_cpu conversion

Quoted 6 lines · Andrew Morton
Quoted 3 lines · On Wed, 13 Feb 2008 10:41:44 +0100 Roel Kluin <[email protected]> wrote:

you may also want these:
---
[bl]e_add_cpu conversion in return

Quoted 8 lines

upsets powerpc (at least):

fs/ufs/swab.h: In function `fs64_add':
fs/ufs/swab.h:47: warning: passing arg 1 of le64_add_cpu' from incompatible pointer type fs/ufs/swab.h:49: warning: passing arg 1 of be64_add_cpu' from incompatible pointer type fs/ufs/swab.h: In function `fs64_sub':
fs/ufs/swab.h:58: warning: passing arg 1 of le64_add_cpu' from incompatible pointer type fs/ufs/swab.h:60: warning: passing arg 1 of be64_add_cpu' from incompatible pointer type

sorry for this. Is it correct to cast like the patch below does? If not (anyone) feel free to correct and send a patch yourself. The patch below was *not* tested
---
[bl]e_add_cpu conversion in return (with cast)

---

fs/ufs/swab.h +8 -4
index 1683d2b..594d6e8 100644
@@ -44,18 +44,22 @@ static __inline u32
 fs64_add(struct super_block *sbp, u32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		return *n = cpu_to_le64(le64_to_cpu(*n)+d);
+		le64_add_cpu((__le64 *)n, d);
 	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)+d);
+		be64_add_cpu((__le64 *)n, d);
+
+	return *n;
 }
 
 static __inline u32
 fs64_sub(struct super_block *sbp, u32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		return *n = cpu_to_le64(le64_to_cpu(*n)-d);
+		le64_add_cpu((__le64 *)n, -d);
 	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)-d);
+		be64_add_cpu((__le64 *)n, -d);
+
+	return *n;
 }
 
 static __inline u32
#35 lore raw

Re: [PATCH] ufs: [bl]e*_add_cpu conversion

Quoted 9 lines · Roel Kluin
Quoted 8 lines · Andrew Morton
Quoted 3 lines · On Wed, 13 Feb 2008 10:41:44 +0100 Roel Kluin <[email protected]> wrote:

you may also want these:
---
[bl]e_add_cpu conversion in return

upsets powerpc (at least):

Quoted 8 lines
Quoted 6 lines

fs/ufs/swab.h: In function `fs64_add':
fs/ufs/swab.h:47: warning: passing arg 1 of le64_add_cpu' from incompatible pointer type fs/ufs/swab.h:49: warning: passing arg 1 of be64_add_cpu' from incompatible pointer type fs/ufs/swab.h: In function `fs64_sub':
fs/ufs/swab.h:58: warning: passing arg 1 of le64_add_cpu' from incompatible pointer type fs/ufs/swab.h:60: warning: passing arg 1 of be64_add_cpu' from incompatible pointer type

sorry for this. Is it correct to cast like the patch below does?

I don't think so. Their prototypes are wrong. We can:
a) remove fs64_add and fs64_sub as nobody use them
b) fix them - change second parameter do __fs64 (and convert to [bl]e64_add_cpu)

Evgeniy?

Quoted 38 lines

If not (anyone) feel free to correct and send a patch yourself. The patch below was *not* tested
---
[bl]e_add_cpu conversion in return (with cast)

---

fs/ufs/swab.h +8 -4
index 1683d2b..594d6e8 100644
@@ -44,18 +44,22 @@ static __inline u32
 fs64_add(struct super_block *sbp, u32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		return *n = cpu_to_le64(le64_to_cpu(*n)+d);
+		le64_add_cpu((__le64 *)n, d);
 	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)+d);
+		be64_add_cpu((__le64 *)n, d);
+
+	return *n;
 }
 
 static __inline u32
 fs64_sub(struct super_block *sbp, u32 *n, int d)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		return *n = cpu_to_le64(le64_to_cpu(*n)-d);
+		le64_add_cpu((__le64 *)n, -d);
 	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)-d);
+		be64_add_cpu((__le64 *)n, -d);
+
+	return *n;
 }
 
 static __inline u32
#36 lore raw

Re: [PATCH] ufs: [bl]e*_add_cpu conversion

Quoted 17 lines · Marcin Slusarz
Quoted 16 lines · Roel Kluin
Quoted 14 lines · Andrew Morton
Quoted 3 lines · On Wed, 13 Feb 2008 10:41:44 +0100 Roel Kluin <[email protected]> wrote:

you may also want these:
---
[bl]e_add_cpu conversion in return

upsets powerpc (at least):

fs/ufs/swab.h: In function `fs64_add':
fs/ufs/swab.h:47: warning: passing arg 1 of le64_add_cpu' from incompatible pointer type fs/ufs/swab.h:49: warning: passing arg 1 of be64_add_cpu' from incompatible pointer type fs/ufs/swab.h: In function `fs64_sub':
fs/ufs/swab.h:58: warning: passing arg 1 of le64_add_cpu' from incompatible pointer type fs/ufs/swab.h:60: warning: passing arg 1 of be64_add_cpu' from incompatible pointer type

Quoted 7 lines
Quoted 1 line

sorry for this. Is it correct to cast like the patch below does?

I don't think so. Their prototypes are wrong. We can:
a) remove fs64_add and fs64_sub as nobody use them
b) fix them - change second parameter do __fs64 (and convert to [bl]e64_add_cpu)

Evgeniy?

I vote for removing unused code.

Signature · 1 line
/Evgeniy
#37 lore raw

Re: [PATCH] ufs: [bl]e*_add_cpu conversion

Quoted 19 lines · Evgeniy Dushistov
Quoted 18 lines · Marcin Slusarz
Quoted 17 lines · Roel Kluin
Quoted 6 lines · Andrew Morton
Quoted 3 lines · On Wed, 13 Feb 2008 10:41:44 +0100 Roel Kluin <[email protected]> wrote:

you may also want these:
---
[bl]e_add_cpu conversion in return

Quoted 8 lines

upsets powerpc (at least):

fs/ufs/swab.h: In function `fs64_add':
fs/ufs/swab.h:47: warning: passing arg 1 of le64_add_cpu' from incompatible pointer type fs/ufs/swab.h:49: warning: passing arg 1 of be64_add_cpu' from incompatible pointer type fs/ufs/swab.h: In function `fs64_sub':
fs/ufs/swab.h:58: warning: passing arg 1 of le64_add_cpu' from incompatible pointer type fs/ufs/swab.h:60: warning: passing arg 1 of be64_add_cpu' from incompatible pointer type

sorry for this. Is it correct to cast like the patch below does?

Quoted 8 lines
Quoted 6 lines

I don't think so. Their prototypes are wrong. We can:
a) remove fs64_add and fs64_sub as nobody use them
b) fix them - change second parameter do __fs64 (and convert to [bl]e64_add_cpu)

Evgeniy?

I vote for removing unused code.

ok, patch below:

---
ufs: remove unused fs64_add and fs64_sub

remove fs64_add and fs64_sub - they probably weren't ever used because their prototypes used u32 instead of __fs64

Cc Evgeniy Dushistov <[email protected]>
---
 fs/ufs/swab.h |   18 ------------------
 1 files changed, 0 insertions(+), 18 deletions(-)
fs/ufs/swab.h +0 -18
index a4340d0..c89e6ad 100644
@@ -41,24 +41,6 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
 }
 
 static __inline u32
-fs64_add(struct super_block *sbp, u32 *n, int d)
-{
-	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		return *n = cpu_to_le64(le64_to_cpu(*n)+d);
-	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)+d);
-}
-
-static __inline u32
-fs64_sub(struct super_block *sbp, u32 *n, int d)
-{
-	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
-		return *n = cpu_to_le64(le64_to_cpu(*n)-d);
-	else
-		return *n = cpu_to_be64(be64_to_cpu(*n)-d);
-}
-
-static __inline u32
 fs32_to_cpu(struct super_block *sbp, __fs32 n)
 {
 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
Signature · 1 line
1.5.3.7