Skip to content

Commit

Permalink
[PATCH] Use valid_dma_direction() in include/asm-i386/dma-mapping.h
Browse files Browse the repository at this point in the history
Now that the generic DMA code has a function to decide if a given DMA
mapping is valid use it.  This will catch cases where direction is not any
of the defined enum values but some random number outside the valid range.
The current implementation will only catch the defined but invalid case
DMA_NONE.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
Acked-by: Muli Ben-Yehuda <muli@il.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Rolf Eike Beer authored and Linus Torvalds committed Sep 29, 2006
1 parent d6bd3a3 commit cd1c6a4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/asm-i386/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static inline dma_addr_t
dma_map_single(struct device *dev, void *ptr, size_t size,
enum dma_data_direction direction)
{
BUG_ON(direction == DMA_NONE);
BUG_ON(!valid_dma_direction(direction));
WARN_ON(size == 0);
flush_write_buffers();
return virt_to_phys(ptr);
Expand All @@ -31,7 +31,7 @@ static inline void
dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
enum dma_data_direction direction)
{
BUG_ON(direction == DMA_NONE);
BUG_ON(!valid_dma_direction(direction));
}

static inline int
Expand All @@ -40,7 +40,7 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
{
int i;

BUG_ON(direction == DMA_NONE);
BUG_ON(!valid_dma_direction(direction));
WARN_ON(nents == 0 || sg[0].length == 0);

for (i = 0; i < nents; i++ ) {
Expand All @@ -57,23 +57,23 @@ static inline dma_addr_t
dma_map_page(struct device *dev, struct page *page, unsigned long offset,
size_t size, enum dma_data_direction direction)
{
BUG_ON(direction == DMA_NONE);
BUG_ON(!valid_dma_direction(direction));
return page_to_phys(page) + offset;
}

static inline void
dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
enum dma_data_direction direction)
{
BUG_ON(direction == DMA_NONE);
BUG_ON(!valid_dma_direction(direction));
}


static inline void
dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
enum dma_data_direction direction)
{
BUG_ON(direction == DMA_NONE);
BUG_ON(!valid_dma_direction(direction));
}

static inline void
Expand Down

0 comments on commit cd1c6a4

Please sign in to comment.