Re: [PATCH v2 2/5] mtd: nand: Qualcomm NAND controller driver

From: Stephen Boyd
Date: Wed Jul 29 2015 - 14:34:06 EST


On 07/29, Archit Taneja wrote:
> On 07/29/2015 07:18 AM, Stephen Boyd wrote:
> >On 07/27/2015 09:34 PM, Archit Taneja wrote:
> >>Hi,
> >>
> >>On 07/25/2015 06:21 AM, Stephen Boyd wrote:
> >>>On 07/21/2015 03:34 AM, Archit Taneja wrote:
> >>>
> >>>>+ int size)
> >>>>+{Looks like a
> >>>>+ struct desc_info *desc;
> >>>>+ struct dma_async_tx_descriptor *dma_desc;
> >>>>+ struct scatterlist *sgl;
> >>>>+ int r;
> >>>>+
> >>>>+ desc = kzalloc(sizeof(*desc), GFP_KERNEL);
> >>>>+ if (!desc)
> >>>>+ return -ENOMEM;
> >>>>+
> >>>>+ list_add_tail(&desc->list, &this->list);
> >>>>+
> >>>>+ sgl = &desc->sgl;
> >>>>+
> >>>>+ sg_init_one(sgl, vaddr, size);
> >>>>+
> >>>>+ desc->dir = DMA_MEM_TO_DEV;
> >>>>+
> >>>>+ r = dma_map_sg(this->dev, sgl, 1, desc->dir);
> >>>>+ if (r == 0)
> >>>>+ goto err;
> >>>
> >>>Should we return an error in this case? Looks like return 0.
> >>
> >>dma_map_sg returns the number of sg entries successfully mapped. In
> >>this case, it should be 1.
> >
> >Right, but this function returns 0 (success?) if we failed to map anything.
>
> Yes. The return value is number of entries successfully mapped.
> dma_map_sg is a macro that is replaced by dma_map_sg_attrs. Its
> comment
> says:
>
> "dma_maps_sg_attrs returns 0 on error and > 0 on success. It should
> never return a value < 0."

Yes, and so this function that calls dma_map_sg() is going to
return 0 to the caller when it didn't do what it was asked to do?

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/