diff options
Diffstat (limited to 'drivers/mtd/nand/nand_bbt.c')
-rw-r--r-- | drivers/mtd/nand/nand_bbt.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 0b1c48595f12..55c23e5cd210 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
@@ -171,16 +171,16 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, | |||
171 | if (tmp == msk) | 171 | if (tmp == msk) |
172 | continue; | 172 | continue; |
173 | if (reserved_block_code && (tmp == reserved_block_code)) { | 173 | if (reserved_block_code && (tmp == reserved_block_code)) { |
174 | printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n", | 174 | printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%012llx\n", |
175 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); | 175 | (loff_t)((offs << 2) + (act >> 1)) << this->bbt_erase_shift); |
176 | this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06); | 176 | this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06); |
177 | mtd->ecc_stats.bbtblocks++; | 177 | mtd->ecc_stats.bbtblocks++; |
178 | continue; | 178 | continue; |
179 | } | 179 | } |
180 | /* Leave it for now, if its matured we can move this | 180 | /* Leave it for now, if its matured we can move this |
181 | * message to MTD_DEBUG_LEVEL0 */ | 181 | * message to MTD_DEBUG_LEVEL0 */ |
182 | printk(KERN_DEBUG "nand_read_bbt: Bad block at 0x%08x\n", | 182 | printk(KERN_DEBUG "nand_read_bbt: Bad block at 0x%012llx\n", |
183 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); | 183 | (loff_t)((offs << 2) + (act >> 1)) << this->bbt_erase_shift); |
184 | /* Factory marked bad or worn out ? */ | 184 | /* Factory marked bad or worn out ? */ |
185 | if (tmp == 0) | 185 | if (tmp == 0) |
186 | this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); | 186 | this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); |
@@ -284,7 +284,7 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, | |||
284 | 284 | ||
285 | /* Read the primary version, if available */ | 285 | /* Read the primary version, if available */ |
286 | if (td->options & NAND_BBT_VERSION) { | 286 | if (td->options & NAND_BBT_VERSION) { |
287 | scan_read_raw(mtd, buf, td->pages[0] << this->page_shift, | 287 | scan_read_raw(mtd, buf, (loff_t)td->pages[0] << this->page_shift, |
288 | mtd->writesize); | 288 | mtd->writesize); |
289 | td->version[0] = buf[mtd->writesize + td->veroffs]; | 289 | td->version[0] = buf[mtd->writesize + td->veroffs]; |
290 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", | 290 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", |
@@ -293,7 +293,7 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, | |||
293 | 293 | ||
294 | /* Read the mirror version, if available */ | 294 | /* Read the mirror version, if available */ |
295 | if (md && (md->options & NAND_BBT_VERSION)) { | 295 | if (md && (md->options & NAND_BBT_VERSION)) { |
296 | scan_read_raw(mtd, buf, md->pages[0] << this->page_shift, | 296 | scan_read_raw(mtd, buf, (loff_t)md->pages[0] << this->page_shift, |
297 | mtd->writesize); | 297 | mtd->writesize); |
298 | md->version[0] = buf[mtd->writesize + md->veroffs]; | 298 | md->version[0] = buf[mtd->writesize + md->veroffs]; |
299 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", | 299 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", |
@@ -411,7 +411,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
411 | numblocks = this->chipsize >> (this->bbt_erase_shift - 1); | 411 | numblocks = this->chipsize >> (this->bbt_erase_shift - 1); |
412 | startblock = chip * numblocks; | 412 | startblock = chip * numblocks; |
413 | numblocks += startblock; | 413 | numblocks += startblock; |
414 | from = startblock << (this->bbt_erase_shift - 1); | 414 | from = (loff_t)startblock << (this->bbt_erase_shift - 1); |
415 | } | 415 | } |
416 | 416 | ||
417 | for (i = startblock; i < numblocks;) { | 417 | for (i = startblock; i < numblocks;) { |
@@ -428,8 +428,8 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
428 | 428 | ||
429 | if (ret) { | 429 | if (ret) { |
430 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); | 430 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); |
431 | printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", | 431 | printk(KERN_WARNING "Bad eraseblock %d at 0x%012llx\n", |
432 | i >> 1, (unsigned int)from); | 432 | i >> 1, (unsigned long long)from); |
433 | mtd->ecc_stats.badblocks++; | 433 | mtd->ecc_stats.badblocks++; |
434 | } | 434 | } |
435 | 435 | ||
@@ -495,7 +495,7 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
495 | for (block = 0; block < td->maxblocks; block++) { | 495 | for (block = 0; block < td->maxblocks; block++) { |
496 | 496 | ||
497 | int actblock = startblock + dir * block; | 497 | int actblock = startblock + dir * block; |
498 | loff_t offs = actblock << this->bbt_erase_shift; | 498 | loff_t offs = (loff_t)actblock << this->bbt_erase_shift; |
499 | 499 | ||
500 | /* Read first page */ | 500 | /* Read first page */ |
501 | scan_read_raw(mtd, buf, offs, mtd->writesize); | 501 | scan_read_raw(mtd, buf, offs, mtd->writesize); |
@@ -719,7 +719,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
719 | 719 | ||
720 | memset(&einfo, 0, sizeof(einfo)); | 720 | memset(&einfo, 0, sizeof(einfo)); |
721 | einfo.mtd = mtd; | 721 | einfo.mtd = mtd; |
722 | einfo.addr = (unsigned long)to; | 722 | einfo.addr = to; |
723 | einfo.len = 1 << this->bbt_erase_shift; | 723 | einfo.len = 1 << this->bbt_erase_shift; |
724 | res = nand_erase_nand(mtd, &einfo, 1); | 724 | res = nand_erase_nand(mtd, &einfo, 1); |
725 | if (res < 0) | 725 | if (res < 0) |
@@ -729,8 +729,8 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
729 | if (res < 0) | 729 | if (res < 0) |
730 | goto outerr; | 730 | goto outerr; |
731 | 731 | ||
732 | printk(KERN_DEBUG "Bad block table written to 0x%08x, version " | 732 | printk(KERN_DEBUG "Bad block table written to 0x%012llx, version " |
733 | "0x%02X\n", (unsigned int)to, td->version[chip]); | 733 | "0x%02X\n", (unsigned long long)to, td->version[chip]); |
734 | 734 | ||
735 | /* Mark it as used */ | 735 | /* Mark it as used */ |
736 | td->pages[chip] = page; | 736 | td->pages[chip] = page; |
@@ -910,7 +910,7 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) | |||
910 | newval = oldval | (0x2 << (block & 0x06)); | 910 | newval = oldval | (0x2 << (block & 0x06)); |
911 | this->bbt[(block >> 3)] = newval; | 911 | this->bbt[(block >> 3)] = newval; |
912 | if ((oldval != newval) && td->reserved_block_code) | 912 | if ((oldval != newval) && td->reserved_block_code) |
913 | nand_update_bbt(mtd, block << (this->bbt_erase_shift - 1)); | 913 | nand_update_bbt(mtd, (loff_t)block << (this->bbt_erase_shift - 1)); |
914 | continue; | 914 | continue; |
915 | } | 915 | } |
916 | update = 0; | 916 | update = 0; |
@@ -931,7 +931,7 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) | |||
931 | new ones have been marked, then we need to update the stored | 931 | new ones have been marked, then we need to update the stored |
932 | bbts. This should only happen once. */ | 932 | bbts. This should only happen once. */ |
933 | if (update && td->reserved_block_code) | 933 | if (update && td->reserved_block_code) |
934 | nand_update_bbt(mtd, (block - 2) << (this->bbt_erase_shift - 1)); | 934 | nand_update_bbt(mtd, (loff_t)(block - 2) << (this->bbt_erase_shift - 1)); |
935 | } | 935 | } |
936 | } | 936 | } |
937 | 937 | ||
@@ -1027,7 +1027,6 @@ int nand_update_bbt(struct mtd_info *mtd, loff_t offs) | |||
1027 | if (!this->bbt || !td) | 1027 | if (!this->bbt || !td) |
1028 | return -EINVAL; | 1028 | return -EINVAL; |
1029 | 1029 | ||
1030 | len = mtd->size >> (this->bbt_erase_shift + 2); | ||
1031 | /* Allocate a temporary buffer for one eraseblock incl. oob */ | 1030 | /* Allocate a temporary buffer for one eraseblock incl. oob */ |
1032 | len = (1 << this->bbt_erase_shift); | 1031 | len = (1 << this->bbt_erase_shift); |
1033 | len += (len >> this->page_shift) * mtd->oobsize; | 1032 | len += (len >> this->page_shift) * mtd->oobsize; |