Commit 34814545 authored by Eric Sesterhenn's avatar Eric Sesterhenn Committed by Adrian Bunk

BUG_ON() Conversion in lib/swiotlb.c

this changes if() BUG(); constructs to BUG_ON() which is
cleaner, contains unlikely() and can better optimized away.
Signed-off-by: default avatarEric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
parent 6978c705
...@@ -296,8 +296,7 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir) ...@@ -296,8 +296,7 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
else else
stride = 1; stride = 1;
if (!nslots) BUG_ON(!nslots);
BUG();
/* /*
* Find suitable number of IO TLB entries size that will fit this * Find suitable number of IO TLB entries size that will fit this
...@@ -416,14 +415,14 @@ sync_single(struct device *hwdev, char *dma_addr, size_t size, ...@@ -416,14 +415,14 @@ sync_single(struct device *hwdev, char *dma_addr, size_t size,
case SYNC_FOR_CPU: case SYNC_FOR_CPU:
if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)) if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL))
memcpy(buffer, dma_addr, size); memcpy(buffer, dma_addr, size);
else if (dir != DMA_TO_DEVICE) else
BUG(); BUG_ON(dir != DMA_TO_DEVICE);
break; break;
case SYNC_FOR_DEVICE: case SYNC_FOR_DEVICE:
if (likely(dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)) if (likely(dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL))
memcpy(dma_addr, buffer, size); memcpy(dma_addr, buffer, size);
else if (dir != DMA_FROM_DEVICE) else
BUG(); BUG_ON(dir != DMA_FROM_DEVICE);
break; break;
default: default:
BUG(); BUG();
...@@ -529,8 +528,7 @@ swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir) ...@@ -529,8 +528,7 @@ swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir)
unsigned long dev_addr = virt_to_phys(ptr); unsigned long dev_addr = virt_to_phys(ptr);
void *map; void *map;
if (dir == DMA_NONE) BUG_ON(dir == DMA_NONE);
BUG();
/* /*
* If the pointer passed in happens to be in the device's DMA window, * If the pointer passed in happens to be in the device's DMA window,
* we can safely return the device addr and not worry about bounce * we can safely return the device addr and not worry about bounce
...@@ -592,8 +590,7 @@ swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size, ...@@ -592,8 +590,7 @@ swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size,
{ {
char *dma_addr = phys_to_virt(dev_addr); char *dma_addr = phys_to_virt(dev_addr);
if (dir == DMA_NONE) BUG_ON(dir == DMA_NONE);
BUG();
if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end) if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
unmap_single(hwdev, dma_addr, size, dir); unmap_single(hwdev, dma_addr, size, dir);
else if (dir == DMA_FROM_DEVICE) else if (dir == DMA_FROM_DEVICE)
...@@ -616,8 +613,7 @@ swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr, ...@@ -616,8 +613,7 @@ swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
{ {
char *dma_addr = phys_to_virt(dev_addr); char *dma_addr = phys_to_virt(dev_addr);
if (dir == DMA_NONE) BUG_ON(dir == DMA_NONE);
BUG();
if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end) if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
sync_single(hwdev, dma_addr, size, dir, target); sync_single(hwdev, dma_addr, size, dir, target);
else if (dir == DMA_FROM_DEVICE) else if (dir == DMA_FROM_DEVICE)
...@@ -648,8 +644,7 @@ swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr, ...@@ -648,8 +644,7 @@ swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr,
{ {
char *dma_addr = phys_to_virt(dev_addr) + offset; char *dma_addr = phys_to_virt(dev_addr) + offset;
if (dir == DMA_NONE) BUG_ON(dir == DMA_NONE);
BUG();
if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end) if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
sync_single(hwdev, dma_addr, size, dir, target); sync_single(hwdev, dma_addr, size, dir, target);
else if (dir == DMA_FROM_DEVICE) else if (dir == DMA_FROM_DEVICE)
...@@ -696,8 +691,7 @@ swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems, ...@@ -696,8 +691,7 @@ swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
unsigned long dev_addr; unsigned long dev_addr;
int i; int i;
if (dir == DMA_NONE) BUG_ON(dir == DMA_NONE);
BUG();
for (i = 0; i < nelems; i++, sg++) { for (i = 0; i < nelems; i++, sg++) {
addr = SG_ENT_VIRT_ADDRESS(sg); addr = SG_ENT_VIRT_ADDRESS(sg);
...@@ -730,8 +724,7 @@ swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nelems, ...@@ -730,8 +724,7 @@ swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
{ {
int i; int i;
if (dir == DMA_NONE) BUG_ON(dir == DMA_NONE);
BUG();
for (i = 0; i < nelems; i++, sg++) for (i = 0; i < nelems; i++, sg++)
if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg)) if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg))
...@@ -753,8 +746,7 @@ swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sg, ...@@ -753,8 +746,7 @@ swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sg,
{ {
int i; int i;
if (dir == DMA_NONE) BUG_ON(dir == DMA_NONE);
BUG();
for (i = 0; i < nelems; i++, sg++) for (i = 0; i < nelems; i++, sg++)
if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg)) if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg))
......
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