diff options
Diffstat (limited to 'drivers/mtd/nand/nand_base.c')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 6a5271256245..7f2691f94322 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -113,21 +113,19 @@ static int check_offs_len(struct mtd_info *mtd, | |||
113 | 113 | ||
114 | /* Start address must align on block boundary */ | 114 | /* Start address must align on block boundary */ |
115 | if (ofs & ((1 << chip->phys_erase_shift) - 1)) { | 115 | if (ofs & ((1 << chip->phys_erase_shift) - 1)) { |
116 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Unaligned address\n", __func__); | 116 | pr_debug("%s: unaligned address\n", __func__); |
117 | ret = -EINVAL; | 117 | ret = -EINVAL; |
118 | } | 118 | } |
119 | 119 | ||
120 | /* Length must align on block boundary */ | 120 | /* Length must align on block boundary */ |
121 | if (len & ((1 << chip->phys_erase_shift) - 1)) { | 121 | if (len & ((1 << chip->phys_erase_shift) - 1)) { |
122 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Length not block aligned\n", | 122 | pr_debug("%s: length not block aligned\n", __func__); |
123 | __func__); | ||
124 | ret = -EINVAL; | 123 | ret = -EINVAL; |
125 | } | 124 | } |
126 | 125 | ||
127 | /* Do not allow past end of device */ | 126 | /* Do not allow past end of device */ |
128 | if (ofs + len > mtd->size) { | 127 | if (ofs + len > mtd->size) { |
129 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Past end of device\n", | 128 | pr_debug("%s: past end of device\n", __func__); |
130 | __func__); | ||
131 | ret = -EINVAL; | 129 | ret = -EINVAL; |
132 | } | 130 | } |
133 | 131 | ||
@@ -913,7 +911,7 @@ static int __nand_unlock(struct mtd_info *mtd, loff_t ofs, | |||
913 | status = chip->waitfunc(mtd, chip); | 911 | status = chip->waitfunc(mtd, chip); |
914 | /* See if device thinks it succeeded */ | 912 | /* See if device thinks it succeeded */ |
915 | if (status & 0x01) { | 913 | if (status & 0x01) { |
916 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Error status = 0x%08x\n", | 914 | pr_debug("%s: error status = 0x%08x\n", |
917 | __func__, status); | 915 | __func__, status); |
918 | ret = -EIO; | 916 | ret = -EIO; |
919 | } | 917 | } |
@@ -935,7 +933,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
935 | int chipnr; | 933 | int chipnr; |
936 | struct nand_chip *chip = mtd->priv; | 934 | struct nand_chip *chip = mtd->priv; |
937 | 935 | ||
938 | DEBUG(MTD_DEBUG_LEVEL3, "%s: start = 0x%012llx, len = %llu\n", | 936 | pr_debug("%s: start = 0x%012llx, len = %llu\n", |
939 | __func__, (unsigned long long)ofs, len); | 937 | __func__, (unsigned long long)ofs, len); |
940 | 938 | ||
941 | if (check_offs_len(mtd, ofs, len)) | 939 | if (check_offs_len(mtd, ofs, len)) |
@@ -954,7 +952,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
954 | 952 | ||
955 | /* Check, if it is write protected */ | 953 | /* Check, if it is write protected */ |
956 | if (nand_check_wp(mtd)) { | 954 | if (nand_check_wp(mtd)) { |
957 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Device is write protected!!!\n", | 955 | pr_debug("%s: device is write protected!\n", |
958 | __func__); | 956 | __func__); |
959 | ret = -EIO; | 957 | ret = -EIO; |
960 | goto out; | 958 | goto out; |
@@ -988,7 +986,7 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
988 | int chipnr, status, page; | 986 | int chipnr, status, page; |
989 | struct nand_chip *chip = mtd->priv; | 987 | struct nand_chip *chip = mtd->priv; |
990 | 988 | ||
991 | DEBUG(MTD_DEBUG_LEVEL3, "%s: start = 0x%012llx, len = %llu\n", | 989 | pr_debug("%s: start = 0x%012llx, len = %llu\n", |
992 | __func__, (unsigned long long)ofs, len); | 990 | __func__, (unsigned long long)ofs, len); |
993 | 991 | ||
994 | if (check_offs_len(mtd, ofs, len)) | 992 | if (check_offs_len(mtd, ofs, len)) |
@@ -1003,7 +1001,7 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
1003 | 1001 | ||
1004 | /* Check, if it is write protected */ | 1002 | /* Check, if it is write protected */ |
1005 | if (nand_check_wp(mtd)) { | 1003 | if (nand_check_wp(mtd)) { |
1006 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Device is write protected!!!\n", | 1004 | pr_debug("%s: device is write protected!\n", |
1007 | __func__); | 1005 | __func__); |
1008 | status = MTD_ERASE_FAILED; | 1006 | status = MTD_ERASE_FAILED; |
1009 | ret = -EIO; | 1007 | ret = -EIO; |
@@ -1018,7 +1016,7 @@ int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
1018 | status = chip->waitfunc(mtd, chip); | 1016 | status = chip->waitfunc(mtd, chip); |
1019 | /* See if device thinks it succeeded */ | 1017 | /* See if device thinks it succeeded */ |
1020 | if (status & 0x01) { | 1018 | if (status & 0x01) { |
1021 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Error status = 0x%08x\n", | 1019 | pr_debug("%s: error status = 0x%08x\n", |
1022 | __func__, status); | 1020 | __func__, status); |
1023 | ret = -EIO; | 1021 | ret = -EIO; |
1024 | goto out; | 1022 | goto out; |
@@ -1756,7 +1754,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, | |||
1756 | int len; | 1754 | int len; |
1757 | uint8_t *buf = ops->oobbuf; | 1755 | uint8_t *buf = ops->oobbuf; |
1758 | 1756 | ||
1759 | DEBUG(MTD_DEBUG_LEVEL3, "%s: from = 0x%08Lx, len = %i\n", | 1757 | pr_debug("%s: from = 0x%08Lx, len = %i\n", |
1760 | __func__, (unsigned long long)from, readlen); | 1758 | __func__, (unsigned long long)from, readlen); |
1761 | 1759 | ||
1762 | stats = mtd->ecc_stats; | 1760 | stats = mtd->ecc_stats; |
@@ -1767,8 +1765,8 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, | |||
1767 | len = mtd->oobsize; | 1765 | len = mtd->oobsize; |
1768 | 1766 | ||
1769 | if (unlikely(ops->ooboffs >= len)) { | 1767 | if (unlikely(ops->ooboffs >= len)) { |
1770 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt to start read " | 1768 | pr_debug("%s: attempt to start read outside oob\n", |
1771 | "outside oob\n", __func__); | 1769 | __func__); |
1772 | return -EINVAL; | 1770 | return -EINVAL; |
1773 | } | 1771 | } |
1774 | 1772 | ||
@@ -1776,8 +1774,8 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, | |||
1776 | if (unlikely(from >= mtd->size || | 1774 | if (unlikely(from >= mtd->size || |
1777 | ops->ooboffs + readlen > ((mtd->size >> chip->page_shift) - | 1775 | ops->ooboffs + readlen > ((mtd->size >> chip->page_shift) - |
1778 | (from >> chip->page_shift)) * len)) { | 1776 | (from >> chip->page_shift)) * len)) { |
1779 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt read beyond end " | 1777 | pr_debug("%s: attempt to read beyond end of device\n", |
1780 | "of device\n", __func__); | 1778 | __func__); |
1781 | return -EINVAL; | 1779 | return -EINVAL; |
1782 | } | 1780 | } |
1783 | 1781 | ||
@@ -1856,8 +1854,8 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from, | |||
1856 | 1854 | ||
1857 | /* Do not allow reads past end of device */ | 1855 | /* Do not allow reads past end of device */ |
1858 | if (ops->datbuf && (from + ops->len) > mtd->size) { | 1856 | if (ops->datbuf && (from + ops->len) > mtd->size) { |
1859 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt read " | 1857 | pr_debug("%s: attempt to read beyond end of device\n", |
1860 | "beyond end of device\n", __func__); | 1858 | __func__); |
1861 | return -EINVAL; | 1859 | return -EINVAL; |
1862 | } | 1860 | } |
1863 | 1861 | ||
@@ -2352,7 +2350,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, | |||
2352 | int chipnr, page, status, len; | 2350 | int chipnr, page, status, len; |
2353 | struct nand_chip *chip = mtd->priv; | 2351 | struct nand_chip *chip = mtd->priv; |
2354 | 2352 | ||
2355 | DEBUG(MTD_DEBUG_LEVEL3, "%s: to = 0x%08x, len = %i\n", | 2353 | pr_debug("%s: to = 0x%08x, len = %i\n", |
2356 | __func__, (unsigned int)to, (int)ops->ooblen); | 2354 | __func__, (unsigned int)to, (int)ops->ooblen); |
2357 | 2355 | ||
2358 | if (ops->mode == MTD_OOB_AUTO) | 2356 | if (ops->mode == MTD_OOB_AUTO) |
@@ -2362,14 +2360,14 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, | |||
2362 | 2360 | ||
2363 | /* Do not allow write past end of page */ | 2361 | /* Do not allow write past end of page */ |
2364 | if ((ops->ooboffs + ops->ooblen) > len) { | 2362 | if ((ops->ooboffs + ops->ooblen) > len) { |
2365 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt to write " | 2363 | pr_debug("%s: attempt to write past end of page\n", |
2366 | "past end of page\n", __func__); | 2364 | __func__); |
2367 | return -EINVAL; | 2365 | return -EINVAL; |
2368 | } | 2366 | } |
2369 | 2367 | ||
2370 | if (unlikely(ops->ooboffs >= len)) { | 2368 | if (unlikely(ops->ooboffs >= len)) { |
2371 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt to start " | 2369 | pr_debug("%s: attempt to start write outside oob\n", |
2372 | "write outside oob\n", __func__); | 2370 | __func__); |
2373 | return -EINVAL; | 2371 | return -EINVAL; |
2374 | } | 2372 | } |
2375 | 2373 | ||
@@ -2378,8 +2376,8 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, | |||
2378 | ops->ooboffs + ops->ooblen > | 2376 | ops->ooboffs + ops->ooblen > |
2379 | ((mtd->size >> chip->page_shift) - | 2377 | ((mtd->size >> chip->page_shift) - |
2380 | (to >> chip->page_shift)) * len)) { | 2378 | (to >> chip->page_shift)) * len)) { |
2381 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt write beyond " | 2379 | pr_debug("%s: attempt to write beyond end of device\n", |
2382 | "end of device\n", __func__); | 2380 | __func__); |
2383 | return -EINVAL; | 2381 | return -EINVAL; |
2384 | } | 2382 | } |
2385 | 2383 | ||
@@ -2432,8 +2430,8 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, | |||
2432 | 2430 | ||
2433 | /* Do not allow writes past end of device */ | 2431 | /* Do not allow writes past end of device */ |
2434 | if (ops->datbuf && (to + ops->len) > mtd->size) { | 2432 | if (ops->datbuf && (to + ops->len) > mtd->size) { |
2435 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Attempt write beyond " | 2433 | pr_debug("%s: attempt to write beyond end of device\n", |
2436 | "end of device\n", __func__); | 2434 | __func__); |
2437 | return -EINVAL; | 2435 | return -EINVAL; |
2438 | } | 2436 | } |
2439 | 2437 | ||
@@ -2522,9 +2520,9 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | |||
2522 | unsigned int bbt_masked_page = 0xffffffff; | 2520 | unsigned int bbt_masked_page = 0xffffffff; |
2523 | loff_t len; | 2521 | loff_t len; |
2524 | 2522 | ||
2525 | DEBUG(MTD_DEBUG_LEVEL3, "%s: start = 0x%012llx, len = %llu\n", | 2523 | pr_debug("%s: start = 0x%012llx, len = %llu\n", |
2526 | __func__, (unsigned long long)instr->addr, | 2524 | __func__, (unsigned long long)instr->addr, |
2527 | (unsigned long long)instr->len); | 2525 | (unsigned long long)instr->len); |
2528 | 2526 | ||
2529 | if (check_offs_len(mtd, instr->addr, instr->len)) | 2527 | if (check_offs_len(mtd, instr->addr, instr->len)) |
2530 | return -EINVAL; | 2528 | return -EINVAL; |
@@ -2546,8 +2544,8 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | |||
2546 | 2544 | ||
2547 | /* Check, if it is write protected */ | 2545 | /* Check, if it is write protected */ |
2548 | if (nand_check_wp(mtd)) { | 2546 | if (nand_check_wp(mtd)) { |
2549 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Device is write protected!!!\n", | 2547 | pr_debug("%s: device is write protected!\n", |
2550 | __func__); | 2548 | __func__); |
2551 | instr->state = MTD_ERASE_FAILED; | 2549 | instr->state = MTD_ERASE_FAILED; |
2552 | goto erase_exit; | 2550 | goto erase_exit; |
2553 | } | 2551 | } |
@@ -2598,8 +2596,8 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, | |||
2598 | 2596 | ||
2599 | /* See if block erase succeeded */ | 2597 | /* See if block erase succeeded */ |
2600 | if (status & NAND_STATUS_FAIL) { | 2598 | if (status & NAND_STATUS_FAIL) { |
2601 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Failed erase, " | 2599 | pr_debug("%s: failed erase, page 0x%08x\n", |
2602 | "page 0x%08x\n", __func__, page); | 2600 | __func__, page); |
2603 | instr->state = MTD_ERASE_FAILED; | 2601 | instr->state = MTD_ERASE_FAILED; |
2604 | instr->fail_addr = | 2602 | instr->fail_addr = |
2605 | ((loff_t)page << chip->page_shift); | 2603 | ((loff_t)page << chip->page_shift); |
@@ -2659,9 +2657,9 @@ erase_exit: | |||
2659 | if (!rewrite_bbt[chipnr]) | 2657 | if (!rewrite_bbt[chipnr]) |
2660 | continue; | 2658 | continue; |
2661 | /* Update the BBT for chip */ | 2659 | /* Update the BBT for chip */ |
2662 | DEBUG(MTD_DEBUG_LEVEL0, "%s: nand_update_bbt " | 2660 | pr_debug("%s: nand_update_bbt (%d:0x%0llx 0x%0x)\n", |
2663 | "(%d:0x%0llx 0x%0x)\n", __func__, chipnr, | 2661 | __func__, chipnr, rewrite_bbt[chipnr], |
2664 | rewrite_bbt[chipnr], chip->bbt_td->pages[chipnr]); | 2662 | chip->bbt_td->pages[chipnr]); |
2665 | nand_update_bbt(mtd, rewrite_bbt[chipnr]); | 2663 | nand_update_bbt(mtd, rewrite_bbt[chipnr]); |
2666 | } | 2664 | } |
2667 | 2665 | ||
@@ -2679,7 +2677,7 @@ static void nand_sync(struct mtd_info *mtd) | |||
2679 | { | 2677 | { |
2680 | struct nand_chip *chip = mtd->priv; | 2678 | struct nand_chip *chip = mtd->priv; |
2681 | 2679 | ||
2682 | DEBUG(MTD_DEBUG_LEVEL3, "%s: called\n", __func__); | 2680 | pr_debug("%s: called\n", __func__); |
2683 | 2681 | ||
2684 | /* Grab the lock and see if the device is available */ | 2682 | /* Grab the lock and see if the device is available */ |
2685 | nand_get_device(chip, mtd, FL_SYNCING); | 2683 | nand_get_device(chip, mtd, FL_SYNCING); |