Re: [PATCH 2/2] dma-coherent: remove the DMA_MEMORY_MAP and DMA_MEMORY_IO flags
From: Robin Murphy
Date: Wed Jun 28 2017 - 10:43:06 EST
On 27/06/17 21:17, Christoph Hellwig wrote:
> DMA_MEMORY_IO was never used in the tree, so remove it. That means there is
> no need for the DMA_MEMORY_MAP flag either now, so remove it as well and
> change dma_declare_coherent_memory to return a normal errno value.
>
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> ---
[...]
> diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
> index 10e7c022e8cf..b96bfffd314e 100644
> --- a/drivers/base/dma-mapping.c
> +++ b/drivers/base/dma-mapping.c
> @@ -176,13 +176,10 @@ int dmam_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
>
> rc = dma_declare_coherent_memory(dev, phys_addr, device_addr, size,
> flags);
> - if (rc) {
> + if (rc)
if (!rc)
> devres_add(dev, res);
> - rc = 0;
> - } else {
> + else
> devres_free(res);
> - rc = -ENOMEM;
> - }
>
> return rc;
> }
[...]
> diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
> index a8b8d8b8d9f3..21302a0f82e2 100644
> --- a/drivers/usb/host/ohci-sm501.c
> +++ b/drivers/usb/host/ohci-sm501.c
> @@ -123,11 +123,11 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
> * regular memory. The HCD_LOCAL_MEM flag does just that.
> */
>
> - if (!dma_declare_coherent_memory(dev, mem->start,
> + retval = dma_declare_coherent_memory(dev, mem->start,
> mem->start - mem->parent->start,
> resource_size(mem),
> - DMA_MEMORY_MAP |
> - DMA_MEMORY_EXCLUSIVE)) {
> + DMA_MEMORY_EXCLUSIVE);
> + if (retval) {
> dev_err(dev, "cannot declare coherent memory\n");
> retval = -ENXIO;
It looks like we could just let retval propagate here, rather than
rewriting it, since we're only bailing out of a probe routine.
Robin.
> goto err1;