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 |