Skip to content

Commit f51f288

Browse files
author
Christoph Hellwig
committed
dma-mapping: remove DMA_ERROR_CODE
And update the documentation - dma_mapping_error has been supported everywhere for a long time. Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 9eef8b8 commit f51f288

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

Documentation/DMA-API-HOWTO.txt

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -550,32 +550,11 @@ and to unmap it:
550550
dma_unmap_single(dev, dma_handle, size, direction);
551551

552552
You should call dma_mapping_error() as dma_map_single() could fail and return
553-
error. Not all DMA implementations support the dma_mapping_error() interface.
554-
However, it is a good practice to call dma_mapping_error() interface, which
555-
will invoke the generic mapping error check interface. Doing so will ensure
556-
that the mapping code will work correctly on all DMA implementations without
557-
any dependency on the specifics of the underlying implementation. Using the
558-
returned address without checking for errors could result in failures ranging
559-
from panics to silent data corruption. A couple of examples of incorrect ways
560-
to check for errors that make assumptions about the underlying DMA
561-
implementation are as follows and these are applicable to dma_map_page() as
562-
well.
563-
564-
Incorrect example 1:
565-
dma_addr_t dma_handle;
566-
567-
dma_handle = dma_map_single(dev, addr, size, direction);
568-
if ((dma_handle & 0xffff != 0) || (dma_handle >= 0x1000000)) {
569-
goto map_error;
570-
}
571-
572-
Incorrect example 2:
573-
dma_addr_t dma_handle;
574-
575-
dma_handle = dma_map_single(dev, addr, size, direction);
576-
if (dma_handle == DMA_ERROR_CODE) {
577-
goto map_error;
578-
}
553+
error. Doing so will ensure that the mapping code will work correctly on all
554+
DMA implementations without any dependency on the specifics of the underlying
555+
implementation. Using the returned address without checking for errors could
556+
result in failures ranging from panics to silent data corruption. The same
557+
applies to dma_map_page() as well.
579558

580559
You should call dma_unmap_single() when the DMA activity is finished, e.g.,
581560
from the interrupt which told you that the DMA transfer is done.

include/linux/dma-mapping.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,12 +546,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
546546

547547
if (get_dma_ops(dev)->mapping_error)
548548
return get_dma_ops(dev)->mapping_error(dev, dma_addr);
549-
550-
#ifdef DMA_ERROR_CODE
551-
return dma_addr == DMA_ERROR_CODE;
552-
#else
553549
return 0;
554-
#endif
555550
}
556551

557552
#ifndef HAVE_ARCH_DMA_SUPPORTED

0 commit comments

Comments
 (0)