Skip to content

Commit

Permalink
arm: dma-iommu: Clean up redundant variable
Browse files Browse the repository at this point in the history
mapping->size can be derived from mapping->bits << PAGE_SHIFT
which makes mapping->size as redundant.

Clean this up.

Signed-off-by: Ritesh Harjani <ritesh.harjani@gmail.com>
Reported-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
  • Loading branch information
Ritesh Harjani authored and Marek Szyprowski committed May 20, 2014
1 parent 7ee793a commit 006f841
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion arch/arm/include/asm/dma-iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ struct dma_iommu_mapping {
unsigned int extensions;
size_t bitmap_size; /* size of a single bitmap */
size_t bits; /* per bitmap */
unsigned int size; /* per bitmap */
dma_addr_t base;

spinlock_t lock;
Expand Down
11 changes: 6 additions & 5 deletions arch/arm/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping,
unsigned int order = get_order(size);
unsigned int align = 0;
unsigned int count, start;
size_t mapping_size = mapping->bits << PAGE_SHIFT;
unsigned long flags;
dma_addr_t iova;
int i;
Expand Down Expand Up @@ -1119,7 +1120,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping,
}
spin_unlock_irqrestore(&mapping->lock, flags);

iova = mapping->base + (mapping->size * i);
iova = mapping->base + (mapping_size * i);
iova += start << PAGE_SHIFT;

return iova;
Expand All @@ -1129,21 +1130,22 @@ static inline void __free_iova(struct dma_iommu_mapping *mapping,
dma_addr_t addr, size_t size)
{
unsigned int start, count;
size_t mapping_size = mapping->bits << PAGE_SHIFT;
unsigned long flags;
dma_addr_t bitmap_base;
u32 bitmap_index;

if (!size)
return;

bitmap_index = (u32) (addr - mapping->base) / (u32) mapping->size;
bitmap_index = (u32) (addr - mapping->base) / (u32) mapping_size;
BUG_ON(addr < mapping->base || bitmap_index > mapping->extensions);

bitmap_base = mapping->base + mapping->size * bitmap_index;
bitmap_base = mapping->base + mapping_size * bitmap_index;

start = (addr - bitmap_base) >> PAGE_SHIFT;

if (addr + size > bitmap_base + mapping->size) {
if (addr + size > bitmap_base + mapping_size) {
/*
* The address range to be freed reaches into the iova
* range of the next bitmap. This should not happen as
Expand Down Expand Up @@ -1964,7 +1966,6 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size)
mapping->extensions = extensions;
mapping->base = base;
mapping->bits = BITS_PER_BYTE * bitmap_size;
mapping->size = mapping->bits << PAGE_SHIFT;

spin_lock_init(&mapping->lock);

Expand Down

0 comments on commit 006f841

Please sign in to comment.