[PATCH v3 7/8] MTD: xway: add nandaddr to own struct
Boris Brezillon
boris.brezillon at free-electrons.com
Sun Jun 19 09:32:11 PDT 2016
On Sun, 19 Jun 2016 18:29:46 +0200
Boris Brezillon <boris.brezillon at free-electrons.com> wrote:
> On Sun, 19 Jun 2016 18:08:16 +0200
> Hauke Mehrtens <hauke at hauke-m.de> wrote:
>
> > Instead of using IO_ADDR_W and IO_ADDR_R use an own pointer to the NAND
> > controller memory area.
> >
> > Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
> > ---
> > drivers/mtd/nand/xway_nand.c | 22 +++++++++++-----------
> > 1 file changed, 11 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/xway_nand.c b/drivers/mtd/nand/xway_nand.c
> > index 6fac4c6..282258f 100644
> > --- a/drivers/mtd/nand/xway_nand.c
> > +++ b/drivers/mtd/nand/xway_nand.c
> > @@ -66,22 +66,23 @@
> > struct xway_nand_data {
> > struct nand_chip chip;
> > unsigned long csflags;
> > + void __iomem *nandaddr;
> > };
> >
> > static u8 xway_readb(struct mtd_info *mtd, int op)
> > {
> > struct nand_chip *chip = mtd_to_nand(mtd);
> > - void __iomem *nandaddr = chip->IO_ADDR_R;
> > + struct xway_nand_data *data = nand_get_controller_data(chip);
> >
> > - return readb(nandaddr + op);
> > + return readb(data->nandaddr + op);
> > }
> >
> > static void xway_writeb(struct mtd_info *mtd, int op, u8 value)
> > {
> > struct nand_chip *chip = mtd_to_nand(mtd);
> > - void __iomem *nandaddr = chip->IO_ADDR_W;
> > + struct xway_nand_data *data = nand_get_controller_data(chip);
> >
> > - writeb(value, nandaddr + op);
> > + writeb(value, data->nandaddr + op);
> > }
> >
> > static void xway_select_chip(struct mtd_info *mtd, int select)
> > @@ -138,7 +139,6 @@ static int xway_nand_probe(struct platform_device *pdev)
> > struct mtd_info *mtd;
> > struct resource *res;
> > int err;
> > - void __iomem *nandaddr;
> > u32 cs;
> > u32 cs_flag = 0;
> >
> > @@ -149,16 +149,16 @@ static int xway_nand_probe(struct platform_device *pdev)
> > return -ENOMEM;
> >
> > res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > - nandaddr = devm_ioremap_resource(&pdev->dev, res);
> > - if (IS_ERR(nandaddr))
> > - return PTR_ERR(nandaddr);
> > + data->nandaddr = devm_ioremap_resource(&pdev->dev, res);
> > + if (IS_ERR(data->nandaddr))
> > + return PTR_ERR(data->nandaddr);
> >
> > nand_set_flash_node(&data->chip, pdev->dev.of_node);
> > mtd = nand_to_mtd(&data->chip);
> > mtd->dev.parent = &pdev->dev;
> >
> > - data->chip.IO_ADDR_R = nandaddr;
> > - data->chip.IO_ADDR_W = nandaddr;
> > + data->chip.IO_ADDR_R = data->nandaddr;
> > + data->chip.IO_ADDR_W = data->nandaddr;
>
> If you patched all places using ->IO_ADDR_R/W you should be able to get
> rid of these assignments. If you didn't, please do it in this patch.
Just realized this implies moving patch 8 before this one, because the
default ->read_buf()/->write_buf() are making use of ->IO_ADDR_R/W.
More information about the linux-mtd
mailing list