[PATCH v2 5/8] MTD: xway: add missing write_buf and read_buf to nand driver
Boris Brezillon
boris.brezillon at free-electrons.com
Sun Jun 19 05:38:18 PDT 2016
On Sat, 18 Jun 2016 21:14:09 +0200
Hauke Mehrtens <hauke at hauke-m.de> wrote:
Please add a commit message.
> From: John Crispin <john at phrozen.org>
>
> Signed-off-by: John Crispin <john at phrozen.org>
> Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
> ---
> drivers/mtd/nand/xway_nand.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/drivers/mtd/nand/xway_nand.c b/drivers/mtd/nand/xway_nand.c
> index 61176c4..1511bdb 100644
> --- a/drivers/mtd/nand/xway_nand.c
> +++ b/drivers/mtd/nand/xway_nand.c
> @@ -151,6 +151,33 @@ static unsigned char xway_read_byte(struct mtd_info *mtd)
> return ret;
> }
>
> +
> +static void xway_read_buf(struct mtd_info *mtd, u_char *buf, int len)
> +{
> + struct nand_chip *this = mtd_to_nand(mtd);
> + unsigned long nandaddr = (unsigned long) this->IO_ADDR_R;
> + unsigned long flags;
> + int i;
> +
> + spin_lock_irqsave(&ebu_lock, flags);
> + for (i = 0; i < len; i++)
> + buf[i] = ltq_r8((void __iomem *)(nandaddr | NAND_READ_DATA));
Please remove these useless cast and use the + operator.
buf[i] = ltq_r8(this->IO_ADDR_R + NAND_READ_DATA);
> + spin_unlock_irqrestore(&ebu_lock, flags);
Reading data through the NAND bus can be quite long, do you really need
to take a spinlock and disable irqs for while doing that?
A mutex would be more appropriate IMO.
> +}
> +
> +static void xway_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
> +{
> + struct nand_chip *this = mtd_to_nand(mtd);
> + unsigned long nandaddr = (unsigned long) this->IO_ADDR_W;
> + unsigned long flags;
> + int i;
> +
> + spin_lock_irqsave(&ebu_lock, flags);
> + for (i = 0; i < len; i++)
> + ltq_w8(buf[i], (void __iomem *)(nandaddr | NAND_WRITE_DATA));
Ditto.
> + spin_unlock_irqrestore(&ebu_lock, flags);
> +}
> +
> /*
> * Probe for the NAND device.
> */
> @@ -184,6 +211,8 @@ static int xway_nand_probe(struct platform_device *pdev)
> data->chip.cmd_ctrl = xway_cmd_ctrl;
> data->chip.dev_ready = xway_dev_ready;
> data->chip.select_chip = xway_select_chip;
> + data->chip.write_buf = xway_write_buf;
> + data->chip.read_buf = xway_read_buf;
> data->chip.read_byte = xway_read_byte;
> data->chip.chip_delay = 30;
>
More information about the linux-mtd
mailing list