]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
iommu: add iommu_num_pages helper function
authorJoerg Roedel <joerg.roedel@amd.com>
Fri, 25 Jul 2008 12:57:58 +0000 (14:57 +0200)
committerIngo Molnar <mingo@elte.hu>
Sat, 26 Jul 2008 13:43:05 +0000 (15:43 +0200)
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>
include/linux/iommu-helper.h
lib/iommu-helper.c

index c975caf75385d2e634cdb151dae416e2487533a0..f8598f583944a5355b4ee33ddef3a785b3adcc79 100644 (file)
@@ -8,3 +8,4 @@ extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
                                      unsigned long align_mask);
 extern void iommu_area_free(unsigned long *map, unsigned long start,
                            unsigned int nr);
+extern unsigned long iommu_num_pages(unsigned long addr, unsigned long len);
index a3b8d4c3f77a5e7e466bd8f5e5591f3dcaa2c3bd..889ddce2021e26870b0b287ad0d28e7032e99028 100644 (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);