iommu: add iommu_num_pages helper function

Calculating the number of pages from given address and length numbers is a task
required in multiple IOMMU implementations. So implement this as a generic
function into the IOMMU helper code.

Signed-off-by: Joerg Roedel <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: FUJITA Tomonori <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
Joerg Roedel 2008-07-25 14:57:58 +02:00 • committed by Ingo Molnar
commit 3bc9f79ee1
2 changed files with 9 additions and 0 deletions

View file

@ -80,3 +80,11 @@ void iommu_area_free(unsigned long *map, unsigned long start, unsigned int nr)
}
}
EXPORT_SYMBOL(iommu_area_free);
unsigned long iommu_num_pages(unsigned long addr, unsigned long len)
{
unsigned long size = roundup((addr & ~PAGE_MASK) + len, PAGE_SIZE);
return size >> PAGE_SHIFT;
}
EXPORT_SYMBOL(iommu_num_pages);