diff options
author | Adrian Hunter <ext-adrian.hunter@nokia.com> | 2008-12-10 08:37:21 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2008-12-10 08:37:21 -0500 |
commit | 69423d99fc182a81f3c5db3eb5c140acc6fc64be (patch) | |
tree | 5f1818e6fb69388f0da276152646bf0597e318c0 /drivers/mtd/nand/nand_base.c | |
parent | 8a4c2495b142fe612b291a810d9e695f269c26db (diff) |
[MTD] update internal API to support 64-bit device size
MTD internal API presently uses 32-bit values to represent
device size. This patch updates them to 64-bits but leaves
the external API unchanged. Extending the external API
is a separate issue for several reasons. First, no one
needs it at the moment. Secondly, whether the implementation
is done with IOCTLs, sysfs or both is still debated. Thirdly
external API changes require the internal API to be accepted
first.
Note that although the MTD API will be able to support 64-bit
device sizes, existing drivers do not and are not required
to do so, although NAND base has been updated.
In general, changing from 32-bit to 64-bit values cause little
or no changes to the majority of the code with the following
exceptions:
- printk message formats
- division and modulus of 64-bit values
- NAND base support
- 32-bit local variables used by mtdpart and mtdconcat
- naughtily assuming one structure maps to another
in MEMERASE ioctl
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand/nand_base.c')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 0a9c9cd33f96..ff2d33e4d6d6 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -2014,13 +2014,14 @@ static int nand_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
2014 | int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | 2014 | int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, |
2015 | int allowbbt) | 2015 | int allowbbt) |
2016 | { | 2016 | { |
2017 | int page, len, status, pages_per_block, ret, chipnr; | 2017 | int page, status, pages_per_block, ret, chipnr; |
2018 | struct nand_chip *chip = mtd->priv; | 2018 | struct nand_chip *chip = mtd->priv; |
2019 | int rewrite_bbt[NAND_MAX_CHIPS]={0}; | 2019 | loff_t rewrite_bbt[NAND_MAX_CHIPS]={0}; |
2020 | unsigned int bbt_masked_page = 0xffffffff; | 2020 | unsigned int bbt_masked_page = 0xffffffff; |
2021 | loff_t len; | ||
2021 | 2022 | ||
2022 | DEBUG(MTD_DEBUG_LEVEL3, "nand_erase: start = 0x%08x, len = %i\n", | 2023 | DEBUG(MTD_DEBUG_LEVEL3, "nand_erase: start = 0x%012llx, len = %llu\n", |
2023 | (unsigned int)instr->addr, (unsigned int)instr->len); | 2024 | (unsigned long long)instr->addr, (unsigned long long)instr->len); |
2024 | 2025 | ||
2025 | /* Start address must align on block boundary */ | 2026 | /* Start address must align on block boundary */ |
2026 | if (instr->addr & ((1 << chip->phys_erase_shift) - 1)) { | 2027 | if (instr->addr & ((1 << chip->phys_erase_shift) - 1)) { |
@@ -2116,7 +2117,8 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | |||
2116 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: " | 2117 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: " |
2117 | "Failed erase, page 0x%08x\n", page); | 2118 | "Failed erase, page 0x%08x\n", page); |
2118 | instr->state = MTD_ERASE_FAILED; | 2119 | instr->state = MTD_ERASE_FAILED; |
2119 | instr->fail_addr = (page << chip->page_shift); | 2120 | instr->fail_addr = |
2121 | ((loff_t)page << chip->page_shift); | ||
2120 | goto erase_exit; | 2122 | goto erase_exit; |
2121 | } | 2123 | } |
2122 | 2124 | ||
@@ -2126,7 +2128,8 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | |||
2126 | */ | 2128 | */ |
2127 | if (bbt_masked_page != 0xffffffff && | 2129 | if (bbt_masked_page != 0xffffffff && |
2128 | (page & BBT_PAGE_MASK) == bbt_masked_page) | 2130 | (page & BBT_PAGE_MASK) == bbt_masked_page) |
2129 | rewrite_bbt[chipnr] = (page << chip->page_shift); | 2131 | rewrite_bbt[chipnr] = |
2132 | ((loff_t)page << chip->page_shift); | ||
2130 | 2133 | ||
2131 | /* Increment page address and decrement length */ | 2134 | /* Increment page address and decrement length */ |
2132 | len -= (1 << chip->phys_erase_shift); | 2135 | len -= (1 << chip->phys_erase_shift); |
@@ -2173,7 +2176,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | |||
2173 | continue; | 2176 | continue; |
2174 | /* update the BBT for chip */ | 2177 | /* update the BBT for chip */ |
2175 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt " | 2178 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt " |
2176 | "(%d:0x%0x 0x%0x)\n", chipnr, rewrite_bbt[chipnr], | 2179 | "(%d:0x%0llx 0x%0x)\n", chipnr, rewrite_bbt[chipnr], |
2177 | chip->bbt_td->pages[chipnr]); | 2180 | chip->bbt_td->pages[chipnr]); |
2178 | nand_update_bbt(mtd, rewrite_bbt[chipnr]); | 2181 | nand_update_bbt(mtd, rewrite_bbt[chipnr]); |
2179 | } | 2182 | } |
@@ -2365,7 +2368,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, | |||
2365 | if (!mtd->name) | 2368 | if (!mtd->name) |
2366 | mtd->name = type->name; | 2369 | mtd->name = type->name; |
2367 | 2370 | ||
2368 | chip->chipsize = type->chipsize << 20; | 2371 | chip->chipsize = (uint64_t)type->chipsize << 20; |
2369 | 2372 | ||
2370 | /* Newer devices have all the information in additional id bytes */ | 2373 | /* Newer devices have all the information in additional id bytes */ |
2371 | if (!type->pagesize) { | 2374 | if (!type->pagesize) { |
@@ -2423,7 +2426,10 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, | |||
2423 | 2426 | ||
2424 | chip->bbt_erase_shift = chip->phys_erase_shift = | 2427 | chip->bbt_erase_shift = chip->phys_erase_shift = |
2425 | ffs(mtd->erasesize) - 1; | 2428 | ffs(mtd->erasesize) - 1; |
2426 | chip->chip_shift = ffs(chip->chipsize) - 1; | 2429 | if (chip->chipsize & 0xffffffff) |
2430 | chip->chip_shift = ffs((unsigned)chip->chipsize) - 1; | ||
2431 | else | ||
2432 | chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32)) + 32 - 1; | ||
2427 | 2433 | ||
2428 | /* Set the bad block position */ | 2434 | /* Set the bad block position */ |
2429 | chip->badblockpos = mtd->writesize > 512 ? | 2435 | chip->badblockpos = mtd->writesize > 512 ? |