[PATCH 3/6] refactor mtd wait code
Artem Bityutskiy
dedekind1 at gmail.com
Tue Jun 28 04:00:27 EDT 2011
On Sun, 2011-06-26 at 18:26 +0200, Matthieu CASTET wrote:
> +/**
> + * This is call after sending a read command, or for autoincrement
> + * chip that need it (!NAND_NO_READRDY).
> + *
> + * We can't call NAND_CMD_STATUS here, because the read command
> + * is not finished
> + */
> +static void nand_wait_read(struct mtd_info *mtd, struct nand_chip *chip)
> +{
> + /*
> + * If we don't have access to the busy pin, we apply the given
> + * command delay
> + */
> + if (!chip->dev_ready) {
> + udelay(chip->chip_delay);
> + }
> + else {
> + /* Apply this short delay always to ensure that we do wait tWB in
> + * any case on any machine. */
> + ndelay(100);
Please, all these hard-coded numbers should be hidden in the specific
driver.
> + nand_wait_ready(mtd);
> + }
> +}
> +
> +/**
> * __nand_unlock - [REPLACEABLE] unlocks specified locked blocks
> *
> * @mtd: mtd info
> @@ -1526,10 +1540,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
> * increment is marked as NOAUTOINCR by the
> * board driver.
> */
> - if (!chip->dev_ready)
> - udelay(chip->chip_delay);
> - else
> - nand_wait_ready(mtd);
> + nand_wait_read(mtd, chip);
> }
> } else {
> memcpy(buf, chip->buffers->databuf + col, bytes);
> @@ -1811,10 +1822,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
> * chip which does auto increment is marked as
> * NOAUTOINCR by the board driver.
> */
> - if (!chip->dev_ready)
> - udelay(chip->chip_delay);
> - else
> - nand_wait_ready(mtd);
> + nand_wait_read(mtd, chip);
I think one thing which you should do as part of this series is to get
rid of all the if (!chip->dev_ready) checks. Instead, you should
introduce something like default_chip_ready and make it do the job.
Also, make sure nand_wait_ready() works in that case.
--
Best Regards,
Artem Bityutskiy
More information about the linux-mtd
mailing list