From patchwork Tue Aug 23 08:27:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 661737 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3sJNrg24P1z9s2k for ; Tue, 23 Aug 2016 18:29:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=walle.cc header.i=@walle.cc header.b=SN8nmhcZ; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3DA5EA752A; Tue, 23 Aug 2016 10:29:01 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aCUqvNJbt2q3; Tue, 23 Aug 2016 10:29:00 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 96A834BA5C; Tue, 23 Aug 2016 10:29:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 10572A752D for ; Tue, 23 Aug 2016 10:28:57 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KM65BHIIozEi for ; Tue, 23 Aug 2016 10:28:56 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from ssl.serverraum.org (ssl.serverraum.org [213.133.101.245]) by theia.denx.de (Postfix) with ESMTPS id 0BD0E4BA16 for ; Tue, 23 Aug 2016 10:28:46 +0200 (CEST) Received: from mwalle01.kse.adk.loc (unknown [194.25.174.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 829BA223B0; Tue, 23 Aug 2016 10:28:40 +0200 (CEST) Authentication-Results: ssl.serverraum.org; dmarc=none header.from=walle.cc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1471940921; bh=wPEyYcbT3dsjGNDBUGaz7vl9Ioyl+QnEsWP7mWEwfCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SN8nmhcZpp8Lk6b7oCBLUxsvKLRiI9LQRg0WkdV1px4zSvCLAWGMcbnioRZAgTnnu xdYSuXwIAdW/6VkZYLZdN4u+i6HoKQTFPcpd24m/tyIt5wyzAPgtC5lvpedx+MstfQ HCsMqruSq43k3vcOWVO968LN8CiHaAEHhT3o6OuE= From: Michael Walle To: Tom Rini Date: Tue, 23 Aug 2016 10:27:39 +0200 Message-Id: <1471940862-6663-3-git-send-email-michael@walle.cc> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1471940862-6663-1-git-send-email-michael@walle.cc> References: <1471940862-6663-1-git-send-email-michael@walle.cc> X-Virus-Scanned: clamav-milter 0.99.2 at web X-Virus-Status: Clean X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on web.serverraum.org Cc: u-boot@lists.denx.de, thomas.schaefer@kontron.com Subject: [U-Boot] [PATCH v2 2/5] ext4: use kernel names for byte swaps X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Instead of __{be,le}{16,32}_to_cpu use {be,le}{16,32}_to_cpu. Signed-off-by: Michael Walle --- fs/ext4/ext4_common.c | 90 +++++++++++++++++++++++++-------------------------- fs/ext4/ext4_write.c | 14 ++++---- fs/ext4/ext4fs.c | 2 +- include/ext_common.h | 4 +-- 4 files changed, 55 insertions(+), 55 deletions(-) diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index eb49fce..e8ed30a 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -1454,7 +1454,7 @@ static int ext4fs_blockgroup desc_per_blk = EXT2_BLOCK_SIZE(data) / sizeof(struct ext2_block_group); - blkno = __le32_to_cpu(data->sblock.first_data_block) + 1 + + blkno = le32_to_cpu(data->sblock.first_data_block) + 1 + group / desc_per_blk; blkoff = (group % desc_per_blk) * sizeof(struct ext2_block_group); @@ -1479,14 +1479,14 @@ int ext4fs_read_inode(struct ext2_data *data, int ino, struct ext2_inode *inode) /* It is easier to calculate if the first inode is 0. */ ino--; - status = ext4fs_blockgroup(data, ino / __le32_to_cpu + status = ext4fs_blockgroup(data, ino / le32_to_cpu (sblock->inodes_per_group), &blkgrp); if (status == 0) return 0; inodes_per_block = EXT2_BLOCK_SIZE(data) / fs->inodesz; - blkno = __le32_to_cpu(blkgrp.inode_table_id) + - (ino % __le32_to_cpu(sblock->inodes_per_group)) / inodes_per_block; + blkno = le32_to_cpu(blkgrp.inode_table_id) + + (ino % le32_to_cpu(sblock->inodes_per_group)) / inodes_per_block; blkoff = (ino % inodes_per_block) * fs->inodesz; /* Read the inode. */ status = ext4fs_devread((lbaint_t)blkno << (LOG2_BLOCK_SIZE(data) - @@ -1559,7 +1559,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) /* Direct blocks. */ if (fileblock < INDIRECT_BLOCKS) - blknr = __le32_to_cpu(inode->b.blocks.dir_blocks[fileblock]); + blknr = le32_to_cpu(inode->b.blocks.dir_blocks[fileblock]); /* Indirect. */ else if (fileblock < (INDIRECT_BLOCKS + (blksz / 4))) { @@ -1586,10 +1586,10 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) } ext4fs_indir1_size = blksz; } - if ((__le32_to_cpu(inode->b.blocks.indir_block) << + if ((le32_to_cpu(inode->b.blocks.indir_block) << log2_blksz) != ext4fs_indir1_blkno) { status = - ext4fs_devread((lbaint_t)__le32_to_cpu + ext4fs_devread((lbaint_t)le32_to_cpu (inode->b.blocks. indir_block) << log2_blksz, 0, blksz, (char *)ext4fs_indir1_block); @@ -1599,10 +1599,10 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) return 0; } ext4fs_indir1_blkno = - __le32_to_cpu(inode->b.blocks. + le32_to_cpu(inode->b.blocks. indir_block) << log2_blksz; } - blknr = __le32_to_cpu(ext4fs_indir1_block + blknr = le32_to_cpu(ext4fs_indir1_block [fileblock - INDIRECT_BLOCKS]); } /* Double indirect. */ @@ -1635,10 +1635,10 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) } ext4fs_indir1_size = blksz; } - if ((__le32_to_cpu(inode->b.blocks.double_indir_block) << + if ((le32_to_cpu(inode->b.blocks.double_indir_block) << log2_blksz) != ext4fs_indir1_blkno) { status = - ext4fs_devread((lbaint_t)__le32_to_cpu + ext4fs_devread((lbaint_t)le32_to_cpu (inode->b.blocks. double_indir_block) << log2_blksz, 0, blksz, @@ -1649,7 +1649,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) return -1; } ext4fs_indir1_blkno = - __le32_to_cpu(inode->b.blocks.double_indir_block) << + le32_to_cpu(inode->b.blocks.double_indir_block) << log2_blksz; } @@ -1676,9 +1676,9 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) } ext4fs_indir2_size = blksz; } - if ((__le32_to_cpu(ext4fs_indir1_block[rblock / perblock]) << + if ((le32_to_cpu(ext4fs_indir1_block[rblock / perblock]) << log2_blksz) != ext4fs_indir2_blkno) { - status = ext4fs_devread((lbaint_t)__le32_to_cpu + status = ext4fs_devread((lbaint_t)le32_to_cpu (ext4fs_indir1_block [rblock / perblock]) << log2_blksz, 0, @@ -1690,12 +1690,12 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) return -1; } ext4fs_indir2_blkno = - __le32_to_cpu(ext4fs_indir1_block[rblock + le32_to_cpu(ext4fs_indir1_block[rblock / perblock]) << log2_blksz; } - blknr = __le32_to_cpu(ext4fs_indir2_block[rblock % perblock]); + blknr = le32_to_cpu(ext4fs_indir2_block[rblock % perblock]); } /* Tripple indirect. */ else { @@ -1727,11 +1727,11 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) } ext4fs_indir1_size = blksz; } - if ((__le32_to_cpu(inode->b.blocks.triple_indir_block) << + if ((le32_to_cpu(inode->b.blocks.triple_indir_block) << log2_blksz) != ext4fs_indir1_blkno) { status = ext4fs_devread ((lbaint_t) - __le32_to_cpu(inode->b.blocks.triple_indir_block) + le32_to_cpu(inode->b.blocks.triple_indir_block) << log2_blksz, 0, blksz, (char *)ext4fs_indir1_block); if (status == 0) { @@ -1740,7 +1740,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) return -1; } ext4fs_indir1_blkno = - __le32_to_cpu(inode->b.blocks.triple_indir_block) << + le32_to_cpu(inode->b.blocks.triple_indir_block) << log2_blksz; } @@ -1767,11 +1767,11 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) } ext4fs_indir2_size = blksz; } - if ((__le32_to_cpu(ext4fs_indir1_block[rblock / + if ((le32_to_cpu(ext4fs_indir1_block[rblock / perblock_parent]) << log2_blksz) != ext4fs_indir2_blkno) { - status = ext4fs_devread((lbaint_t)__le32_to_cpu + status = ext4fs_devread((lbaint_t)le32_to_cpu (ext4fs_indir1_block [rblock / perblock_parent]) << @@ -1783,7 +1783,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) return -1; } ext4fs_indir2_blkno = - __le32_to_cpu(ext4fs_indir1_block[rblock / + le32_to_cpu(ext4fs_indir1_block[rblock / perblock_parent]) << log2_blksz; } @@ -1811,12 +1811,12 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) } ext4fs_indir3_size = blksz; } - if ((__le32_to_cpu(ext4fs_indir2_block[rblock + if ((le32_to_cpu(ext4fs_indir2_block[rblock / perblock_child]) << log2_blksz) != ext4fs_indir3_blkno) { status = - ext4fs_devread((lbaint_t)__le32_to_cpu + ext4fs_devread((lbaint_t)le32_to_cpu (ext4fs_indir2_block [(rblock / perblock_child) % (blksz / 4)]) << log2_blksz, 0, @@ -1827,14 +1827,14 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock) return -1; } ext4fs_indir3_blkno = - __le32_to_cpu(ext4fs_indir2_block[(rblock / + le32_to_cpu(ext4fs_indir2_block[(rblock / perblock_child) % (blksz / 4)]) << log2_blksz; } - blknr = __le32_to_cpu(ext4fs_indir3_block + blknr = le32_to_cpu(ext4fs_indir3_block [rblock % perblock_child]); } debug("read_allocated_block %ld\n", blknr); @@ -1907,7 +1907,7 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name, return 0; } /* Search the file. */ - while (fpos < __le32_to_cpu(diro->inode.size)) { + while (fpos < le32_to_cpu(diro->inode.size)) { struct ext2_dirent dirent; status = ext4fs_read_file(diro, fpos, @@ -1939,7 +1939,7 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name, return 0; fdiro->data = diro->data; - fdiro->ino = __le32_to_cpu(dirent.inode); + fdiro->ino = le32_to_cpu(dirent.inode); filename[dirent.namelen] = '\0'; @@ -1954,7 +1954,7 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name, type = FILETYPE_REG; } else { status = ext4fs_read_inode(diro->data, - __le32_to_cpu + le32_to_cpu (dirent.inode), &fdiro->inode); if (status == 0) { @@ -1963,15 +1963,15 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name, } fdiro->inode_read = 1; - if ((__le16_to_cpu(fdiro->inode.mode) & + if ((le16_to_cpu(fdiro->inode.mode) & FILETYPE_INO_MASK) == FILETYPE_INO_DIRECTORY) { type = FILETYPE_DIRECTORY; - } else if ((__le16_to_cpu(fdiro->inode.mode) + } else if ((le16_to_cpu(fdiro->inode.mode) & FILETYPE_INO_MASK) == FILETYPE_INO_SYMLINK) { type = FILETYPE_SYMLINK; - } else if ((__le16_to_cpu(fdiro->inode.mode) + } else if ((le16_to_cpu(fdiro->inode.mode) & FILETYPE_INO_MASK) == FILETYPE_INO_REG) { type = FILETYPE_REG; @@ -1990,7 +1990,7 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name, } else { if (fdiro->inode_read == 0) { status = ext4fs_read_inode(diro->data, - __le32_to_cpu( + le32_to_cpu( dirent.inode), &fdiro->inode); if (status == 0) { @@ -2014,12 +2014,12 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name, break; } printf("%10u %s\n", - __le32_to_cpu(fdiro->inode.size), + le32_to_cpu(fdiro->inode.size), filename); } free(fdiro); } - fpos += __le16_to_cpu(dirent.direntlen); + fpos += le16_to_cpu(dirent.direntlen); } return 0; } @@ -2036,23 +2036,23 @@ static char *ext4fs_read_symlink(struct ext2fs_node *node) if (status == 0) return 0; } - symlink = zalloc(__le32_to_cpu(diro->inode.size) + 1); + symlink = zalloc(le32_to_cpu(diro->inode.size) + 1); if (!symlink) return 0; - if (__le32_to_cpu(diro->inode.size) < sizeof(diro->inode.b.symlink)) { + if (le32_to_cpu(diro->inode.size) < sizeof(diro->inode.b.symlink)) { strncpy(symlink, diro->inode.b.symlink, - __le32_to_cpu(diro->inode.size)); + le32_to_cpu(diro->inode.size)); } else { status = ext4fs_read_file(diro, 0, - __le32_to_cpu(diro->inode.size), + le32_to_cpu(diro->inode.size), symlink, &actread); if ((status < 0) || (actread == 0)) { free(symlink); return 0; } } - symlink[__le32_to_cpu(diro->inode.size)] = '\0'; + symlink[le32_to_cpu(diro->inode.size)] = '\0'; return symlink; } @@ -2200,7 +2200,7 @@ int ext4fs_open(const char *filename, loff_t *len) if (status == 0) goto fail; } - *len = __le32_to_cpu(fdiro->inode.size); + *len = le32_to_cpu(fdiro->inode.size); ext4fs_file = fdiro; return 0; @@ -2226,7 +2226,7 @@ int ext4fs_mount(unsigned part_length) goto fail; /* Make sure this is an ext2 filesystem. */ - if (__le16_to_cpu(data->sblock.magic) != EXT2_MAGIC) + if (le16_to_cpu(data->sblock.magic) != EXT2_MAGIC) goto fail; /* @@ -2239,13 +2239,13 @@ int ext4fs_mount(unsigned part_length) goto fail; } - if (__le32_to_cpu(data->sblock.revision_level == 0)) + if (le32_to_cpu(data->sblock.revision_level == 0)) fs->inodesz = 128; else - fs->inodesz = __le16_to_cpu(data->sblock.inode_size); + fs->inodesz = le16_to_cpu(data->sblock.inode_size); debug("EXT2 rev %d, inode_size %d\n", - __le32_to_cpu(data->sblock.revision_level), fs->inodesz); + le32_to_cpu(data->sblock.revision_level), fs->inodesz); data->diropen.data = data; data->diropen.ino = 2; diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c index e027916..1169ee3 100644 --- a/fs/ext4/ext4_write.c +++ b/fs/ext4/ext4_write.c @@ -520,8 +520,8 @@ static int ext4fs_delete_file(int inodeno) /* get the block no */ inodeno--; - blkno = __le32_to_cpu(bgd[ibmap_idx].inode_table_id) + - (inodeno % __le32_to_cpu(inode_per_grp)) / inodes_per_block; + blkno = le32_to_cpu(bgd[ibmap_idx].inode_table_id) + + (inodeno % le32_to_cpu(inode_per_grp)) / inodes_per_block; /* get the offset of the inode */ blkoff = ((inodeno) % inodes_per_block) * fs->inodesz; @@ -744,7 +744,7 @@ static int ext4fs_write_file(struct ext2_inode *file_inode, { int i; int blockcnt; - unsigned int filesize = __le32_to_cpu(file_inode->size); + unsigned int filesize = le32_to_cpu(file_inode->size); struct ext_filesystem *fs = get_fs(); int log2blksz = fs->dev_desc->log2blksz; int log2_fs_blocksize = LOG2_BLOCK_SIZE(ext4fs_root) - log2blksz; @@ -909,8 +909,8 @@ int ext4fs_write(const char *fname, unsigned char *buffer, goto fail; ibmap_idx = inodeno / ext4fs_root->sblock.inodes_per_group; inodeno--; - itable_blkno = __le32_to_cpu(fs->bgd[ibmap_idx].inode_table_id) + - (inodeno % __le32_to_cpu(sblock->inodes_per_group)) / + itable_blkno = le32_to_cpu(fs->bgd[ibmap_idx].inode_table_id) + + (inodeno % le32_to_cpu(sblock->inodes_per_group)) / inodes_per_block; blkoff = (inodeno % inodes_per_block) * fs->inodesz; ext4fs_devread((lbaint_t)itable_blkno * fs->sect_perblk, 0, fs->blksz, @@ -928,9 +928,9 @@ int ext4fs_write(const char *fname, unsigned char *buffer, } ibmap_idx = parent_inodeno / ext4fs_root->sblock.inodes_per_group; parent_inodeno--; - parent_itable_blkno = __le32_to_cpu(fs->bgd[ibmap_idx].inode_table_id) + + parent_itable_blkno = le32_to_cpu(fs->bgd[ibmap_idx].inode_table_id) + (parent_inodeno % - __le32_to_cpu(sblock->inodes_per_group)) / inodes_per_block; + le32_to_cpu(sblock->inodes_per_group)) / inodes_per_block; blkoff = (parent_inodeno % inodes_per_block) * fs->inodesz; if (parent_itable_blkno != itable_blkno) { memset(temp_ptr, '\0', fs->blksz); diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index 43c8897..3078737 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -55,7 +55,7 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos, int log2blksz = fs->dev_desc->log2blksz; int log2_fs_blocksize = LOG2_BLOCK_SIZE(node->data) - log2blksz; int blocksize = (1 << (log2_fs_blocksize + log2blksz)); - unsigned int filesize = __le32_to_cpu(node->inode.size); + unsigned int filesize = le32_to_cpu(node->inode.size); lbaint_t previous_block_number = -1; lbaint_t delayed_start = 0; lbaint_t delayed_extent = 0; diff --git a/include/ext_common.h b/include/ext_common.h index c12e526..3220091 100644 --- a/include/ext_common.h +++ b/include/ext_common.h @@ -49,10 +49,10 @@ #define EXT2_BLOCK_SIZE(data) (1 << LOG2_BLOCK_SIZE(data)) /* Log2 size of ext2 block in bytes. */ -#define LOG2_BLOCK_SIZE(data) (__le32_to_cpu \ +#define LOG2_BLOCK_SIZE(data) (le32_to_cpu \ (data->sblock.log2_block_size) \ + EXT2_MIN_BLOCK_LOG_SIZE) -#define INODE_SIZE_FILESYSTEM(data) (__le32_to_cpu \ +#define INODE_SIZE_FILESYSTEM(data) (le32_to_cpu \ (data->sblock.inode_size)) #define EXT2_FT_DIR 2