diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2008-07-25 14:57:58 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-26 15:43:05 +0200 |
commit | 3bc9f79ee1ddc913be0a6d3592036683ef8a3148 (patch) | |
tree | 21f0dc5f5feb140d8566e22fa3c7ecac009e27f3 /lib/iommu-helper.c | |
parent | 024e8ac04453b3525448c31ef39848cf675ba6db (diff) | |
download | lwn-3bc9f79ee1ddc913be0a6d3592036683ef8a3148.tar.gz lwn-3bc9f79ee1ddc913be0a6d3592036683ef8a3148.zip |
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 <joerg.roedel@amd.com>
Cc: iommu@lists.linux-foundation.org
Cc: bhavna.sarathy@amd.com
Cc: robert.richter@amd.com
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'lib/iommu-helper.c')
-rw-r--r-- | lib/iommu-helper.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/iommu-helper.c b/lib/iommu-helper.c index a3b8d4c3f77a..889ddce2021e 100644 --- a/lib/iommu-helper.c +++ b/lib/iommu-helper.c @@ -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); |