2008-02-12 23:07:00

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCHSET] [bl]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


2008-02-12 23:07:28

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] crypto: be*_add_cpu conversion

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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Herbert Xu <[email protected]>
Cc: David S. Miller <[email protected]>
---
crypto/lrw.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/crypto/lrw.c b/crypto/lrw.c
index 9d52e58..4d93928 100644
--- a/crypto/lrw.c
+++ b/crypto/lrw.c
@@ -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)
--
1.5.3.7

2008-02-12 23:07:46

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] ieee 1394: be*_add_cpu conversion

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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Ben Collins <[email protected]>
Cc: Stefan Richter <[email protected]>
---
drivers/ieee1394/csr.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/ieee1394/csr.c b/drivers/ieee1394/csr.c
index 52ac83e..c90be40 100644
--- a/drivers/ieee1394/csr.c
+++ b/drivers/ieee1394/csr.c
@@ -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));
--
1.5.3.7

2008-02-12 23:08:04

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] infiniband: be*_add_cpu conversion

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

Signed-off-by: Marcin Slusarz <[email protected]>
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(-)

diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index 6bd9f13..1e1e336 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -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;

--
1.5.3.7

2008-02-12 23:08:27

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] affs: be*_add_cpu conversion

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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Roman Zippel <[email protected]>
---
fs/affs/file.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/affs/file.c b/fs/affs/file.c
index 6e0c939..95b48af 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -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;
--
1.5.3.7

2008-02-12 23:08:43

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] gfs2: be*_add_cpu conversion

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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Steven Whitehouse <[email protected]>
Cc: [email protected]
---
fs/gfs2/dir.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index c347095..6f2e382 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -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);
--
1.5.3.7

2008-02-12 23:09:07

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] hfs/hfsplus: be*_add_cpu conversion

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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Roman Zippel <[email protected]>
---
fs/hfs/mdb.c | 2 +-
fs/hfsplus/super.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/hfs/mdb.c b/fs/hfs/mdb.c
index b4651e1..36ca2e1 100644
--- a/fs/hfs/mdb.c
+++ b/fs/hfs/mdb.c
@@ -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);
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index b0f9ad3..068523b 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -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);
--
1.5.3.7

2008-02-12 23:09:41

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] ipw2200: 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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Zhu Yi <[email protected]>
Cc: John W. Linville <[email protected]>
Cc: [email protected]
---
drivers/net/wireless/ipw2200.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 3e6ad7b..5d9854e 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -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);
}
}

--
1.5.3.7

2008-02-12 23:09:59

by Marcin Slusarz

[permalink] [raw]
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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
drivers/scsi/aacraid/commsup.c | 2 +-
drivers/scsi/ips.c | 8 ++------
2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 81b3692..3ac8c82 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -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) {
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index bb152fb..f45770a 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -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
--
1.5.3.7

2008-02-12 23:10:53

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] ext2: 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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: [email protected]
---
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

2008-02-12 23:11:17

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] 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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: Andrew Morton <[email protected]>
Cc: [email protected]
Cc: "Theodore Ts'o" <[email protected]>
Cc: Mingming Cao <[email protected]>
---
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(-)

diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 0737e05..5d34899 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -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);
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index bc7081f..ad628ff 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -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);
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index da18a74..843664c 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -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));
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index dd0fcfc..586a320 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -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);
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 9477a2b..f9e716a 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -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
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 6627ee0..5aa0a50 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -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);
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index d796213..fedaa4f 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -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);
--
1.5.3.7

2008-02-12 23:11:37

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] jfs: 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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
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

2008-02-12 23:12:01

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] ntfs: 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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Anton Altaparmakov <[email protected]>
Cc: [email protected]
---
fs/ntfs/upcase.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/ntfs/upcase.c b/fs/ntfs/upcase.c
index 9101807..e2f72ca 100644
--- a/fs/ntfs/upcase.c
+++ b/fs/ntfs/upcase.c
@@ -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;
--
1.5.3.7

2008-02-12 23:12:42

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] ocfs2: 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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Mark Fasheh <[email protected]>
Cc: Kurt Hackel <[email protected]>
Cc: [email protected]
---
fs/ocfs2/dir.c | 5 ++---
fs/ocfs2/localalloc.c | 3 +--
2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index e280833..8a18758 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -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++;
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index add1ffd..d0e217e 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -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) {
--
1.5.3.7

2008-02-12 23:12:58

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] quota: 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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Jan Kara <[email protected]>
---
fs/quota_v2.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/quota_v2.c b/fs/quota_v2.c
index c519a58..a9f9eef 100644
--- a/fs/quota_v2.c
+++ b/fs/quota_v2.c
@@ -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) {
--
1.5.3.7

2008-02-12 23:14:35

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] sysv: [bl]e*_add_cpu conversion

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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Christoph Hellwig <[email protected]>
---
fs/sysv/sysv.h | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
index 42d51d1..38ebe3f 100644
--- a/fs/sysv/sysv.h
+++ b/fs/sysv/sysv.h
@@ -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;
}

--
1.5.3.7

2008-02-12 23:14:57

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] ufs: [bl]e*_add_cpu conversion

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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Evgeniy Dushistov <[email protected]>
---
fs/ufs/swab.h | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
index 1683d2b..a4340d0 100644
--- a/fs/ufs/swab.h
+++ b/fs/ufs/swab.h
@@ -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 */
--
1.5.3.7

2008-02-12 23:13:29

by Marcin Slusarz

[permalink] [raw]
Subject: [PATCH] reiserfs: 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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
fs/reiserfs/objectid.c | 5 ++---
fs/reiserfs/stree.c | 3 +--
2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/fs/reiserfs/objectid.c b/fs/reiserfs/objectid.c
index 65feba4..f0c1543 100644
--- a/fs/reiserfs/objectid.c
+++ b/fs/reiserfs/objectid.c
@@ -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;
}

diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index d2db241..abbc64d 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -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
--
1.5.3.7

2008-02-13 00:32:34

by Roland Dreier

[permalink] [raw]

2008-02-13 08:26:04

by Roel Kluin

[permalink] [raw]
Subject: Re: [PATCH] crypto: be*_add_cpu conversion

[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
>
> Signed-off-by: Marcin Slusarz <[email protected]>
> Cc: Herbert Xu <[email protected]>
> Cc: David S. Miller <[email protected]>
> ---
> crypto/lrw.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/crypto/lrw.c b/crypto/lrw.c
> index 9d52e58..4d93928 100644
> --- a/crypto/lrw.c
> +++ b/crypto/lrw.c
> @@ -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)

> - 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)

2008-02-13 09:41:55

by Roel Kluin

[permalink] [raw]
Subject: Re: [PATCH] ufs: [bl]e*_add_cpu conversion

[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

Signed-off-by: Roel Kluin <[email protected]>
---
diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
index 1683d2b..a1e3000 100644
--- a/fs/ufs/swab.h
+++ b/fs/ufs/swab.h
@@ -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

2008-02-13 09:52:59

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH] quota: le*_add_cpu conversion

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
>
> Signed-off-by: Marcin Slusarz <[email protected]>
> Cc: Jan Kara <[email protected]>
Acked-by: Jan Kara <[email protected]>

Honza
> ---
> fs/quota_v2.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/quota_v2.c b/fs/quota_v2.c
> index c519a58..a9f9eef 100644
> --- a/fs/quota_v2.c
> +++ b/fs/quota_v2.c
> @@ -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) {
> --
> 1.5.3.7
>
--
Jan Kara <[email protected]>
SUSE Labs, CR

2008-02-13 09:56:07

by Steven Whitehouse

[permalink] [raw]
Subject: Re: [PATCH] gfs2: be*_add_cpu conversion

Hi,

Now in the GFS2 -nmw git tree. Thanks,

Steve.

On Wed, 2008-02-13 at 00:06 +0100, [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
>
> Signed-off-by: Marcin Slusarz <[email protected]>
> Cc: Steven Whitehouse <[email protected]>
> Cc: [email protected]
> ---
> fs/gfs2/dir.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
> index c347095..6f2e382 100644
> --- a/fs/gfs2/dir.c
> +++ b/fs/gfs2/dir.c
> @@ -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);

2008-02-13 14:06:36

by Mark Salyzyn

[permalink] [raw]
Subject: RE: [PATCH] scsi: le*_add_cpu conversion

ACK

Sincerely -- Mark Salyzyn

> -----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
>
> Signed-off-by: Marcin Slusarz <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> ---
> drivers/scsi/aacraid/commsup.c | 2 +-
> drivers/scsi/ips.c | 8 ++------
> 2 files changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/aacraid/commsup.c
> b/drivers/scsi/aacraid/commsup.c
> index 81b3692..3ac8c82 100644
> --- a/drivers/scsi/aacraid/commsup.c
> +++ b/drivers/scsi/aacraid/commsup.c
> @@ -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) {
> diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
> index bb152fb..f45770a 100644
> --- a/drivers/scsi/ips.c
> +++ b/drivers/scsi/ips.c
> @@ -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
> --
> 1.5.3.7

2008-02-13 16:56:00

by Reinette Chatre

[permalink] [raw]
Subject: RE: [PATCH] ipw2200: le*_add_cpu conversion

On Tuesday, February 12, 2008 3:06 PM,
[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
>
> Signed-off-by: Marcin Slusarz <[email protected]>
> Cc: Zhu Yi <[email protected]>
> Cc: John W. Linville <[email protected]>
> Cc: [email protected]
> ---
> drivers/net/wireless/ipw2200.c | 4 +---
> 1 files changed, 1 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/ipw2200.c
> b/drivers/net/wireless/ipw2200.c
> index 3e6ad7b..5d9854e 100644
> --- a/drivers/net/wireless/ipw2200.c
> +++ b/drivers/net/wireless/ipw2200.c
> @@ -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);
> }
> }
>
> --
> 1.5.3.7

Thanks!

Signed-off-by: Reinette Chatre <[email protected]>

Reinette

2008-02-13 18:22:19

by Marcin Slusarz

[permalink] [raw]
Subject: Re: [PATCH] ufs: [bl]e*_add_cpu conversion

On Wed, Feb 13, 2008 at 10:41:44AM +0100, Roel Kluin wrote:
> [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
>
> Signed-off-by: Roel Kluin <[email protected]>
Acked-by: Marcin Slusarz <[email protected]>

> ---
> diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
> index 1683d2b..a1e3000 100644
> --- a/fs/ufs/swab.h
> +++ b/fs/ufs/swab.h
> @@ -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
>

2008-02-13 18:37:53

by Marcin Slusarz

[permalink] [raw]
Subject: Re: [PATCH] crypto: be*_add_cpu conversion

On Wed, Feb 13, 2008 at 09:25:47AM +0100, Roel Kluin wrote:
> [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
> >
> > Signed-off-by: Marcin Slusarz <[email protected]>
> > Cc: Herbert Xu <[email protected]>
> > Cc: David S. Miller <[email protected]>
> > ---
> > crypto/lrw.c | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/crypto/lrw.c b/crypto/lrw.c
> > index 9d52e58..4d93928 100644
> > --- a/crypto/lrw.c
> > +++ b/crypto/lrw.c
> > @@ -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)
>
> > - 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);

Signed-off-by: Marcin Slusarz <[email protected]>
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(-)

diff --git a/crypto/lrw.c b/crypto/lrw.c
index 9d52e58..8ef664e 100644
--- a/crypto/lrw.c
+++ b/crypto/lrw.c
@@ -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)
--
1.5.3.7

2008-02-13 22:04:13

by Dave Kleikamp

[permalink] [raw]
Subject: Re: [PATCH] jfs: le*_add_cpu conversion

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) +
> expression_in_cpu_byteorder);
> with:
> leX_add_cpu(&little_endian_variable, expression_in_cpu_byteorder);
> generated with semantic patch
>
> Signed-off-by: Marcin Slusarz <[email protected]>
> Cc: [email protected]
> Cc: [email protected]

Applied to the jfs git tree.

Thanks,
Shaggy
--
David Kleikamp
IBM Linux Technology Center

2008-02-14 07:04:48

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] sysv: [bl]e*_add_cpu conversion

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.

> diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
> index 42d51d1..38ebe3f 100644
> --- a/fs/sysv/sysv.h
> +++ b/fs/sysv/sysv.h
> @@ -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.

2008-02-16 05:29:04

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] ufs: [bl]e*_add_cpu conversion

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
>
> Signed-off-by: Roel Kluin <[email protected]>
> ---
> diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
> index 1683d2b..a1e3000 100644
> --- a/fs/ufs/swab.h
> +++ b/fs/ufs/swab.h
> @@ -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

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

2008-02-16 13:31:17

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] sysv: [bl]e*_add_cpu conversion

On Thu, Feb 14, 2008 at 02:04:37AM -0500, Christoph Hellwig wrote:
> > diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
> > index 42d51d1..38ebe3f 100644
> > --- a/fs/sysv/sysv.h
> > +++ b/fs/sysv/sysv.h
> > @@ -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.

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

2008-02-16 16:54:30

by Stefan Richter

[permalink] [raw]
Subject: Re: [PATCH] ieee 1394: be*_add_cpu conversion

[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,
--
Stefan Richter
-=====-==--- --=- =----
http://arcgraph.de/sr/

2008-02-18 21:04:01

by Mark Fasheh

[permalink] [raw]
Subject: Re: [PATCH] ocfs2: le*_add_cpu conversion

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]

2008-02-18 23:22:38

by Roel Kluin

[permalink] [raw]
Subject: Re: [PATCH] ufs: [bl]e*_add_cpu conversion

Andrew Morton wrote:
> 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

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)

Signed-off-by: Roel Kluin <[email protected]>
---
diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
index 1683d2b..594d6e8 100644
--- a/fs/ufs/swab.h
+++ b/fs/ufs/swab.h
@@ -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

2008-02-19 17:47:19

by Marcin Slusarz

[permalink] [raw]
Subject: Re: [PATCH] ufs: [bl]e*_add_cpu conversion

On Tue, Feb 19, 2008 at 12:22:19AM +0100, Roel Kluin wrote:
> Andrew Morton wrote:
> > 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
>
> 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?

> 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)
>
> Signed-off-by: Roel Kluin <[email protected]>
> ---
> diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
> index 1683d2b..594d6e8 100644
> --- a/fs/ufs/swab.h
> +++ b/fs/ufs/swab.h
> @@ -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

2008-02-19 19:15:01

by Evgeniy Dushistov

[permalink] [raw]
Subject: Re: [PATCH] ufs: [bl]e*_add_cpu conversion

On Tue, Feb 19, 2008 at 06:45:42PM +0100, Marcin Slusarz wrote:
> On Tue, Feb 19, 2008 at 12:22:19AM +0100, Roel Kluin wrote:
> > Andrew Morton wrote:
> > > 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
> >
> > 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.

--
/Evgeniy

2008-03-09 10:22:47

by Marcin Slusarz

[permalink] [raw]
Subject: Re: [PATCH] ufs: [bl]e*_add_cpu conversion

On Tue, Feb 19, 2008 at 10:16:21PM +0300, Evgeniy Dushistov wrote:
> On Tue, Feb 19, 2008 at 06:45:42PM +0100, Marcin Slusarz wrote:
> > On Tue, Feb 19, 2008 at 12:22:19AM +0100, Roel Kluin wrote:
> > > Andrew Morton wrote:
> > > > 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
> > >
> > > 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.
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

Signed-off-by: Marcin Slusarz <[email protected]>
Cc: Evgeniy Dushistov <[email protected]>
---
fs/ufs/swab.h | 18 ------------------
1 files changed, 0 insertions(+), 18 deletions(-)

diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
index a4340d0..c89e6ad 100644
--- a/fs/ufs/swab.h
+++ b/fs/ufs/swab.h
@@ -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)
--
1.5.3.7

2008-03-14 08:24:23

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: be*_add_cpu conversion

On Wed, Feb 13, 2008 at 07:36:49PM +0100, Marcin Slusarz wrote:
>
> 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);
>
> Signed-off-by: Marcin Slusarz <[email protected]>
> Cc: Herbert Xu <[email protected]>
> Cc: David S. Miller <[email protected]>
> Cc: Roel Kluin <[email protected]>

Patch applied. Thanks a lot!
--
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