Skip to content

Commit

Permalink
ARM: dma-mapping: introduce DMA_ERROR_CODE constant
Browse files Browse the repository at this point in the history
Replace all uses of ~0 with DMA_ERROR_CODE, what should make the code
easier to read.

Signed-off-by: Marek Szyprowski <[email protected]>
Acked-by: Kyungmin Park <[email protected]>
Tested-By: Subash Patel <[email protected]>
  • Loading branch information
mszyprow committed May 21, 2012
1 parent 6b6f770 commit 553ac78
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions arch/arm/common/dmabounce.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static inline dma_addr_t map_single(struct device *dev, void *ptr, size_t size,
if (buf == NULL) {
dev_err(dev, "%s: unable to map unsafe buffer %p!\n",
__func__, ptr);
return ~0;
return DMA_ERROR_CODE;
}

dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n",
Expand Down Expand Up @@ -320,7 +320,7 @@ dma_addr_t __dma_map_page(struct device *dev, struct page *page,

ret = needs_bounce(dev, dma_addr, size);
if (ret < 0)
return ~0;
return DMA_ERROR_CODE;

if (ret == 0) {
__dma_page_cpu_to_dev(page, offset, size, dir);
Expand All @@ -329,7 +329,7 @@ dma_addr_t __dma_map_page(struct device *dev, struct page *page,

if (PageHighMem(page)) {
dev_err(dev, "DMA buffer bouncing of HIGHMEM pages is not supported\n");
return ~0;
return DMA_ERROR_CODE;
}

return map_single(dev, page_address(page) + offset, size, dir);
Expand Down
4 changes: 3 additions & 1 deletion arch/arm/include/asm/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <asm-generic/dma-coherent.h>
#include <asm/memory.h>

#define DMA_ERROR_CODE (~0)

#ifdef __arch_page_to_dma
#error Please update to __arch_pfn_to_dma
#endif
Expand Down Expand Up @@ -123,7 +125,7 @@ extern int dma_set_mask(struct device *, u64);
*/
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
return dma_addr == ~0;
return dma_addr == DMA_ERROR_CODE;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
*/
gfp &= ~(__GFP_COMP);

*handle = ~0;
*handle = DMA_ERROR_CODE;
size = PAGE_ALIGN(size);

page = __dma_alloc_buffer(dev, size, gfp);
Expand Down

0 comments on commit 553ac78

Please sign in to comment.