On Tue, May 6, 2025 at 5:32 PM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote: > > On Tue, May 06, 2025 at 05:16:03PM +0800, Keguang Zhang wrote: > > On Fri, May 2, 2025 at 4:39 PM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote: > > > > > > The "desc" variable is NULL and PTR_ERR(NULL) is zero/success. Return > > > a negative error code instead. > > > > > > Fixes: d2d10ede04b1 ("mtd: rawnand: Add Loongson-1 NAND Controller Driver") > > > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> > > > --- > > > It's hard to know what the patch prefix should be here. Ideally when we > > > add a new driver we would use the patch prefix for the driver. > > > > > > Tired: subsystem: Add driver XXX > > > Wired: subsystem: XXX: Add driver for XXX > > > > > > drivers/mtd/nand/raw/loongson1-nand-controller.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/mtd/nand/raw/loongson1-nand-controller.c b/drivers/mtd/nand/raw/loongson1-nand-controller.c > > > index 6a369b1c7d86..8754bb4f8b56 100644 > > > --- a/drivers/mtd/nand/raw/loongson1-nand-controller.c > > > +++ b/drivers/mtd/nand/raw/loongson1-nand-controller.c > > > @@ -371,7 +371,7 @@ static int ls1x_nand_dma_transfer(struct ls1x_nand_host *host, struct ls1x_nand_ > > > desc = dmaengine_prep_slave_single(chan, dma_addr, op->len, xfer_dir, DMA_PREP_INTERRUPT); > > > if (!desc) { > > > dev_err(dev, "failed to prepare DMA descriptor\n"); > > > - ret = PTR_ERR(desc); > > > + ret = -ENOMEM; > > > > Thank you for fixing this issue. > > However, I believe -EIO is more appropriate than -ENOMEM, since > > dmaengine_prep_slave_single() can return errors other than -ENOMEM. > > > > It's not an I/O error so -EIO isn't correct. > > There are a bunch of reasons it could fail but most likely > dma_pool_alloc() failed. I think -ENOMEM is correct. > Have you reviewed the implementation of ls1x_dma_prep_slave_sg()? Errors in this function can be caused not only by -ENOMEM, but also by -EINVAL. Moreover, in most cases, the error handling logic for dmaengine_prep_slave_single() returns -EIO when the function returns NULL. > regards, > dan carpenter > -- Best regards, Keguang Zhang