diff options
Diffstat (limited to 'drivers/mtd/nand/docg4.c')
| -rw-r--r-- | drivers/mtd/nand/docg4.c | 24 | 
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c index 548db2389fa..ce24637e14f 100644 --- a/drivers/mtd/nand/docg4.c +++ b/drivers/mtd/nand/docg4.c @@ -44,6 +44,7 @@  #include <linux/mtd/nand.h>  #include <linux/bch.h>  #include <linux/bitrev.h> +#include <linux/jiffies.h>  /*   * In "reliable mode" consecutive 2k pages are used in parallel (in some @@ -269,7 +270,7 @@ static int poll_status(struct docg4_priv *doc)  	 */  	uint16_t flash_status; -	unsigned int timeo; +	unsigned long timeo;  	void __iomem *docptr = doc->virtadr;  	dev_dbg(doc->dev, "%s...\n", __func__); @@ -277,22 +278,18 @@ static int poll_status(struct docg4_priv *doc)  	/* hardware quirk requires reading twice initially */  	flash_status = readw(docptr + DOC_FLASHCONTROL); -	timeo = 1000; +	timeo = jiffies + msecs_to_jiffies(200); /* generous timeout */  	do {  		cpu_relax();  		flash_status = readb(docptr + DOC_FLASHCONTROL); -	} while (!(flash_status & DOC_CTRL_FLASHREADY) && --timeo); +	} while (!(flash_status & DOC_CTRL_FLASHREADY) && +		 time_before(jiffies, timeo)); - -	if (!timeo) { +	if (unlikely(!(flash_status & DOC_CTRL_FLASHREADY))) {  		dev_err(doc->dev, "%s: timed out!\n", __func__);  		return NAND_STATUS_FAIL;  	} -	if (unlikely(timeo < 50)) -		dev_warn(doc->dev, "%s: nearly timed out; %d remaining\n", -			 __func__, timeo); -  	return 0;  } @@ -494,7 +491,7 @@ static uint8_t docg4_read_byte(struct mtd_info *mtd)  		return status;  	} -	dev_warn(doc->dev, "unexpectd call to read_byte()\n"); +	dev_warn(doc->dev, "unexpected call to read_byte()\n");  	return 0;  } @@ -875,7 +872,7 @@ static int docg4_read_oob(struct mtd_info *mtd, struct nand_chip *nand,  	return 0;  } -static void docg4_erase_block(struct mtd_info *mtd, int page) +static int docg4_erase_block(struct mtd_info *mtd, int page)  {  	struct nand_chip *nand = mtd->priv;  	struct docg4_priv *doc = nand->priv; @@ -919,6 +916,8 @@ static void docg4_erase_block(struct mtd_info *mtd, int page)  	write_nop(docptr);  	poll_status(doc);  	write_nop(docptr); + +	return nand->waitfunc(mtd, nand);  }  static int write_page(struct mtd_info *mtd, struct nand_chip *nand, @@ -1239,8 +1238,7 @@ static void __init init_mtd_structs(struct mtd_info *mtd)  	nand->block_markbad = docg4_block_markbad;  	nand->read_buf = docg4_read_buf;  	nand->write_buf = docg4_write_buf16; -	nand->scan_bbt = nand_default_bbt; -	nand->erase_cmd = docg4_erase_block; +	nand->erase = docg4_erase_block;  	nand->ecc.read_page = docg4_read_page;  	nand->ecc.write_page = docg4_write_page;  	nand->ecc.read_page_raw = docg4_read_page_raw;  | 
