mtd: nand: silence some shift wrap warnings

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Aug 30 16:59:04 EDT 2013


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=daae74cad4bcd4566fcb82477e33c42bcdaa86e8
Commit:     daae74cad4bcd4566fcb82477e33c42bcdaa86e8
Parent:     7a96541a8e9fe720bec3900679ca514fefd2d516
Author:     Dan Carpenter <dan.carpenter at oracle.com>
AuthorDate: Fri Aug 9 12:49:05 2013 +0300
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Aug 30 21:36:35 2013 +0100

    mtd: nand: silence some shift wrap warnings
    
    There are static checkers which complain when we declare variables as
    64 bit bitfields but only use the lower 32 bits because of shift
    wrapping.  In this case "len" is declared as u64 as opposed to unsigned
    long or something which might be 32 bits.
    
    Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
    Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/nand_base.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 8f04fb0..761ef2f 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -108,13 +108,13 @@ static int check_offs_len(struct mtd_info *mtd,
 	int ret = 0;
 
 	/* Start address must align on block boundary */
-	if (ofs & ((1 << chip->phys_erase_shift) - 1)) {
+	if (ofs & ((1ULL << chip->phys_erase_shift) - 1)) {
 		pr_debug("%s: unaligned address\n", __func__);
 		ret = -EINVAL;
 	}
 
 	/* Length must align on block boundary */
-	if (len & ((1 << chip->phys_erase_shift) - 1)) {
+	if (len & ((1ULL << chip->phys_erase_shift) - 1)) {
 		pr_debug("%s: length not block aligned\n", __func__);
 		ret = -EINVAL;
 	}
@@ -394,7 +394,7 @@ static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs)
 		memset(&einfo, 0, sizeof(einfo));
 		einfo.mtd = mtd;
 		einfo.addr = ofs;
-		einfo.len = 1 << chip->phys_erase_shift;
+		einfo.len = 1ULL << chip->phys_erase_shift;
 		nand_erase_nand(mtd, &einfo, 0);
 
 		/* Write bad block marker to OOB */
@@ -2630,7 +2630,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
 		}
 
 		/* Increment page address and decrement length */
-		len -= (1 << chip->phys_erase_shift);
+		len -= (1ULL << chip->phys_erase_shift);
 		page += pages_per_block;
 
 		/* Check, if we cross a chip boundary */



More information about the linux-mtd-cvs mailing list