Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753981AbYGYM6u (ORCPT ); Fri, 25 Jul 2008 08:58:50 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755678AbYGYM6i (ORCPT ); Fri, 25 Jul 2008 08:58:38 -0400 Received: from outbound-sin.frontbridge.com ([207.46.51.80]:42634 "EHLO SG2EHSOBE005.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755291AbYGYM6h (ORCPT ); Fri, 25 Jul 2008 08:58:37 -0400 X-BigFish: VPS4(zzzz10d3izzz32i43j65h) X-Spam-TCS-SCL: 4:0 X-WSS-ID: 0K4KC17-04-X3B-01 From: Joerg Roedel To: mingo@redhat.com, tglx@linutronix.de CC: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, bhavna.sarathy@amd.com, robert.richter@amd.com, Joerg Roedel , FUJITA Tomonori Subject: [PATCH] add iommu_num_pages helper function Date: Fri, 25 Jul 2008 14:57:58 +0200 Message-ID: <1216990680-1227-2-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.5.3.7 In-Reply-To: <1216990680-1227-1-git-send-email-joerg.roedel@amd.com> References: <1216990680-1227-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 25 Jul 2008 12:58:00.0309 (UTC) FILETIME=[11312250:01C8EE56] MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1657 Lines: 45 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. Cc: FUJITA Tomonori Signed-off-by: Joerg Roedel --- include/linux/iommu-helper.h | 1 + lib/iommu-helper.c | 8 ++++++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/include/linux/iommu-helper.h b/include/linux/iommu-helper.h index c975caf..f8598f5 100644 --- a/include/linux/iommu-helper.h +++ b/include/linux/iommu-helper.h @@ -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); diff --git a/lib/iommu-helper.c b/lib/iommu-helper.c index a3b8d4c..889ddce 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); -- 1.5.3.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/