[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZvERI9fscLBC09_F@pengutronix.de>
Date: Mon, 23 Sep 2024 08:56:35 +0200
From: Sascha Hauer <s.hauer@...gutronix.de>
To: Amit Singh Tomar <amitsinght@...vell.com>
Cc: Hui-Ping Chen <hpchen0nvt@...il.com>, miquel.raynal@...tlin.com,
richard@....at, vigneshr@...com, robh@...nel.org,
krzk+dt@...nel.org, conor+dt@...nel.org, esben@...nix.com,
linux-arm-kernel@...ts.infradead.org, linux-mtd@...ts.infradead.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 2/2] mtd: rawnand: nuvoton: add new driver for the
Nuvoton MA35 SoC
Hi Amit,
On Mon, Sep 23, 2024 at 01:19:03AM +0530, Amit Singh Tomar wrote:
> Hi,
>
> > +static int ma35_nand_do_write(struct nand_chip *chip, const u8 *addr, u32 len)
> > +{
> > + struct ma35_nand_info *nand = nand_get_controller_data(chip);
> > + struct mtd_info *mtd = nand_to_mtd(chip);
> > + dma_addr_t dma_addr;
> > + int ret = 0, i;
> > + u32 reg;
> > +
> > + if (len != mtd->writesize) {
> > + for (i = 0; i < len; i++)
> > + writel(addr[i], nand->regs + MA35_NFI_REG_NANDDATA);
> > + return 0;
> > + }
> > +
> > + ma35_nand_dmac_init(nand);
> > +
> > + writel(mtd->oobsize, nand->regs + MA35_NFI_REG_NANDRACTL);
> > +
> > + writel(INT_DMA, nand->regs + MA35_NFI_REG_NANDINTEN);
> > + /* To mark this page as dirty. */
> > + reg = readl(nand->regs + MA35_NFI_REG_NANDRA0);
> > + if (reg & 0xffff0000)
> > + writel(reg & 0xffff, nand->regs + MA35_NFI_REG_NANDRA0);
> > +
> > + dma_addr = dma_map_single(nand->dev, (void *)addr, len, DMA_TO_DEVICE);
> > + ret = dma_mapping_error(nand->dev, dma_addr);
> > + if (ret) {
> > + dev_err(nand->dev, "dma mapping error\n");
> > + return -EINVAL;
> Shouldn't this return -ENOMEM or simply ret when there's an error? Also,
> should we consider unmapping the page with dma_unmap_single in that case?
When dma_map_single() returns an error the pages are not mapped, no
need to unmap then.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Powered by blists - more mailing lists