Commit f51f288e authored by Christoph Hellwig's avatar Christoph Hellwig

dma-mapping: remove DMA_ERROR_CODE

And update the documentation - dma_mapping_error has been supported
everywhere for a long time.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 9eef8b8c
...@@ -550,32 +550,11 @@ and to unmap it: ...@@ -550,32 +550,11 @@ and to unmap it:
dma_unmap_single(dev, dma_handle, size, direction); dma_unmap_single(dev, dma_handle, size, direction);
You should call dma_mapping_error() as dma_map_single() could fail and return You should call dma_mapping_error() as dma_map_single() could fail and return
error. Not all DMA implementations support the dma_mapping_error() interface. error. Doing so will ensure that the mapping code will work correctly on all
However, it is a good practice to call dma_mapping_error() interface, which DMA implementations without any dependency on the specifics of the underlying
will invoke the generic mapping error check interface. Doing so will ensure implementation. Using the returned address without checking for errors could
that the mapping code will work correctly on all DMA implementations without result in failures ranging from panics to silent data corruption. The same
any dependency on the specifics of the underlying implementation. Using the applies to dma_map_page() as well.
returned address without checking for errors could result in failures ranging
from panics to silent data corruption. A couple of examples of incorrect ways
to check for errors that make assumptions about the underlying DMA
implementation are as follows and these are applicable to dma_map_page() as
well.
Incorrect example 1:
dma_addr_t dma_handle;
dma_handle = dma_map_single(dev, addr, size, direction);
if ((dma_handle & 0xffff != 0) || (dma_handle >= 0x1000000)) {
goto map_error;
}
Incorrect example 2:
dma_addr_t dma_handle;
dma_handle = dma_map_single(dev, addr, size, direction);
if (dma_handle == DMA_ERROR_CODE) {
goto map_error;
}
You should call dma_unmap_single() when the DMA activity is finished, e.g., You should call dma_unmap_single() when the DMA activity is finished, e.g.,
from the interrupt which told you that the DMA transfer is done. from the interrupt which told you that the DMA transfer is done.
......
...@@ -546,12 +546,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) ...@@ -546,12 +546,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
if (get_dma_ops(dev)->mapping_error) if (get_dma_ops(dev)->mapping_error)
return get_dma_ops(dev)->mapping_error(dev, dma_addr); return get_dma_ops(dev)->mapping_error(dev, dma_addr);
#ifdef DMA_ERROR_CODE
return dma_addr == DMA_ERROR_CODE;
#else
return 0; return 0;
#endif
} }
#ifndef HAVE_ARCH_DMA_SUPPORTED #ifndef HAVE_ARCH_DMA_SUPPORTED
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment