Commit 661803b2 authored by Boris Brezillon's avatar Boris Brezillon Committed by Miquel Raynal

mtd: rawnand: Stop using chip->state in drivers

We are about to simplify the locking in the rawnand framework, and part
of this simplication is about getting rid of chip->state, so let's
first patch drivers that check the state.

All of them do that to get a timeout value based on the operation that
is being executed. Since a timeout is, by definition, something that
is here to prevent hanging on an event that might never happen,
picking the maximum timeout value no matter the operation should be
harmless.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent efe5d132
...@@ -994,12 +994,9 @@ static int omap_wait(struct nand_chip *this) ...@@ -994,12 +994,9 @@ static int omap_wait(struct nand_chip *this)
{ {
struct omap_nand_info *info = mtd_to_omap(nand_to_mtd(this)); struct omap_nand_info *info = mtd_to_omap(nand_to_mtd(this));
unsigned long timeo = jiffies; unsigned long timeo = jiffies;
int status, state = this->state; int status;
if (state == FL_ERASING)
timeo += msecs_to_jiffies(400); timeo += msecs_to_jiffies(400);
else
timeo += msecs_to_jiffies(20);
writeb(NAND_CMD_STATUS & 0xFF, info->reg.gpmc_nand_command); writeb(NAND_CMD_STATUS & 0xFF, info->reg.gpmc_nand_command);
while (time_before(jiffies, timeo)) { while (time_before(jiffies, timeo)) {
......
...@@ -369,8 +369,7 @@ static int r852_wait(struct nand_chip *chip) ...@@ -369,8 +369,7 @@ static int r852_wait(struct nand_chip *chip)
unsigned long timeout; unsigned long timeout;
u8 status; u8 status;
timeout = jiffies + (chip->state == FL_ERASING ? timeout = jiffies + msecs_to_jiffies(400);
msecs_to_jiffies(400) : msecs_to_jiffies(20));
while (time_before(jiffies, timeout)) while (time_before(jiffies, timeout))
if (chip->legacy.dev_ready(chip)) if (chip->legacy.dev_ready(chip))
......
...@@ -195,15 +195,13 @@ static int tmio_nand_wait(struct nand_chip *nand_chip) ...@@ -195,15 +195,13 @@ static int tmio_nand_wait(struct nand_chip *nand_chip)
reinit_completion(&tmio->comp); reinit_completion(&tmio->comp);
tmio_iowrite8(0x81, tmio->fcr + FCR_IMR); tmio_iowrite8(0x81, tmio->fcr + FCR_IMR);
timeout = nand_chip->state == FL_ERASING ? 400 : 20; timeout = 400;
timeout = wait_for_completion_timeout(&tmio->comp, timeout = wait_for_completion_timeout(&tmio->comp,
msecs_to_jiffies(timeout)); msecs_to_jiffies(timeout));
if (unlikely(!tmio_nand_dev_ready(nand_chip))) { if (unlikely(!tmio_nand_dev_ready(nand_chip))) {
tmio_iowrite8(0x00, tmio->fcr + FCR_IMR); tmio_iowrite8(0x00, tmio->fcr + FCR_IMR);
dev_warn(&tmio->dev->dev, "still busy with %s after %d ms\n", dev_warn(&tmio->dev->dev, "still busy after 400 ms\n");
nand_chip->state == FL_ERASING ? "erase" : "program",
nand_chip->state == FL_ERASING ? 400 : 20);
} else if (unlikely(!timeout)) { } else if (unlikely(!timeout)) {
tmio_iowrite8(0x00, tmio->fcr + FCR_IMR); tmio_iowrite8(0x00, tmio->fcr + FCR_IMR);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment