public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Amit Singh Tomar <amitsinght@marvell.com>
Cc: Hui-Ping Chen <hpchen0nvt@gmail.com>,
	miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com,
	robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	esben@geanix.com, linux-arm-kernel@lists.infradead.org,
	linux-mtd@lists.infradead.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/2] mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC
Date: Mon, 23 Sep 2024 08:56:35 +0200	[thread overview]
Message-ID: <ZvERI9fscLBC09_F@pengutronix.de> (raw)
In-Reply-To: <9245120b-9901-45c3-9a6e-600653f94bba@marvell.com>

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 |

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2024-09-23  6:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-20  6:37 [PATCH v5 0/2] Add support for nuvoton ma35 nand controller Hui-Ping Chen
2024-09-20  6:37 ` [PATCH v5 1/2] dt-bindings: mtd: nuvoton,ma35d1-nand: add new bindings Hui-Ping Chen
2024-09-20  6:37 ` [PATCH v5 2/2] mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC Hui-Ping Chen
2024-09-22 19:49   ` Amit Singh Tomar
2024-09-23  6:56     ` Sascha Hauer [this message]
2024-09-23 18:05       ` Amit Singh Tomar
2024-09-24  2:11     ` Hui-Ping Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZvERI9fscLBC09_F@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=amitsinght@marvell.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=esben@geanix.com \
    --cc=hpchen0nvt@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=robh@kernel.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox