|
@@ -317,9 +317,9 @@ static void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len)
|
|
|
*
|
|
|
* Check, if the block is bad.
|
|
|
*/
|
|
|
-static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
|
|
|
+static int nand_block_bad(struct mtd_info *mtd, loff_t ofs)
|
|
|
{
|
|
|
- int page, chipnr, res = 0, i = 0;
|
|
|
+ int page, res = 0, i = 0;
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
|
|
u16 bad;
|
|
|
|
|
@@ -328,15 +328,6 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
|
|
|
|
|
|
page = (int)(ofs >> chip->page_shift) & chip->pagemask;
|
|
|
|
|
|
- if (getchip) {
|
|
|
- chipnr = (int)(ofs >> chip->chip_shift);
|
|
|
-
|
|
|
- nand_get_device(mtd, FL_READING);
|
|
|
-
|
|
|
- /* Select the NAND device */
|
|
|
- chip->select_chip(mtd, chipnr);
|
|
|
- }
|
|
|
-
|
|
|
do {
|
|
|
if (chip->options & NAND_BUSWIDTH_16) {
|
|
|
chip->cmdfunc(mtd, NAND_CMD_READOOB,
|
|
@@ -361,11 +352,6 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
|
|
|
i++;
|
|
|
} while (!res && i < 2 && (chip->bbt_options & NAND_BBT_SCAN2NDPAGE));
|
|
|
|
|
|
- if (getchip) {
|
|
|
- chip->select_chip(mtd, -1);
|
|
|
- nand_release_device(mtd);
|
|
|
- }
|
|
|
-
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@@ -503,19 +489,17 @@ static int nand_block_isreserved(struct mtd_info *mtd, loff_t ofs)
|
|
|
* nand_block_checkbad - [GENERIC] Check if a block is marked bad
|
|
|
* @mtd: MTD device structure
|
|
|
* @ofs: offset from device start
|
|
|
- * @getchip: 0, if the chip is already selected
|
|
|
* @allowbbt: 1, if its allowed to access the bbt area
|
|
|
*
|
|
|
* Check, if the block is bad. Either by reading the bad block table or
|
|
|
* calling of the scan function.
|
|
|
*/
|
|
|
-static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
|
|
|
- int allowbbt)
|
|
|
+static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int allowbbt)
|
|
|
{
|
|
|
struct nand_chip *chip = mtd_to_nand(mtd);
|
|
|
|
|
|
if (!chip->bbt)
|
|
|
- return chip->block_bad(mtd, ofs, getchip);
|
|
|
+ return chip->block_bad(mtd, ofs);
|
|
|
|
|
|
/* Return info from the table */
|
|
|
return nand_isbad_bbt(mtd, ofs, allowbbt);
|
|
@@ -2949,7 +2933,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
|
|
|
while (len) {
|
|
|
/* Check if we have a bad block, we do not erase bad blocks! */
|
|
|
if (nand_block_checkbad(mtd, ((loff_t) page) <<
|
|
|
- chip->page_shift, 0, allowbbt)) {
|
|
|
+ chip->page_shift, allowbbt)) {
|
|
|
pr_warn("%s: attempt to erase a bad block at page 0x%08x\n",
|
|
|
__func__, page);
|
|
|
instr->state = MTD_ERASE_FAILED;
|
|
@@ -3036,7 +3020,20 @@ static void nand_sync(struct mtd_info *mtd)
|
|
|
*/
|
|
|
static int nand_block_isbad(struct mtd_info *mtd, loff_t offs)
|
|
|
{
|
|
|
- return nand_block_checkbad(mtd, offs, 1, 0);
|
|
|
+ struct nand_chip *chip = mtd_to_nand(mtd);
|
|
|
+ int chipnr = (int)(offs >> chip->chip_shift);
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ /* Select the NAND device */
|
|
|
+ nand_get_device(mtd, FL_READING);
|
|
|
+ chip->select_chip(mtd, chipnr);
|
|
|
+
|
|
|
+ ret = nand_block_checkbad(mtd, offs, 0);
|
|
|
+
|
|
|
+ chip->select_chip(mtd, -1);
|
|
|
+ nand_release_device(mtd);
|
|
|
+
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
/**
|