From patchwork Fri Sep 2 17:32:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ohad Ben Cohen X-Patchwork-Id: 1122782 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p82HZ5SM023907 for ; Fri, 2 Sep 2011 17:35:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754006Ab1IBRej (ORCPT ); Fri, 2 Sep 2011 13:34:39 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:41213 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753810Ab1IBRdG (ORCPT ); Fri, 2 Sep 2011 13:33:06 -0400 Received: by mail-wy0-f174.google.com with SMTP id 22so2141299wyh.19 for ; Fri, 02 Sep 2011 10:33:05 -0700 (PDT) Received: by 10.216.70.147 with SMTP id p19mr1242367wed.76.1314984785634; Fri, 02 Sep 2011 10:33:05 -0700 (PDT) Received: from localhost.localdomain (93-173-174-182.bb.netvision.net.il [93.173.174.182]) by mx.google.com with ESMTPS id fq2sm2376189wbb.24.2011.09.02.10.33.03 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 02 Sep 2011 10:33:04 -0700 (PDT) From: Ohad Ben-Cohen To: Cc: , Hiroshi DOYU , Laurent Pinchart , Joerg Roedel , David Woodhouse , , David Brown , Arnd Bergmann , , Ohad Ben-Cohen Subject: [PATCH 3/7] iommu/core: use the existing IS_ALIGNED macro Date: Fri, 2 Sep 2011 20:32:32 +0300 Message-Id: <1314984756-4400-4-git-send-email-ohad@wizery.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1314984756-4400-1-git-send-email-ohad@wizery.com> References: <1314984756-4400-1-git-send-email-ohad@wizery.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 02 Sep 2011 17:35:05 +0000 (UTC) Replace iommu's alignment checks with the existing IS_ALIGNED macro, to drop a few lines of code and utilize IS_ALIGNED's type safety. Signed-off-by: Ohad Ben-Cohen --- drivers/iommu/iommu.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 6e6b6a1..e61a9ba 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include #include @@ -97,13 +98,11 @@ EXPORT_SYMBOL_GPL(iommu_domain_has_cap); int iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, int gfp_order, int prot) { - unsigned long invalid_mask; size_t size; size = 0x1000UL << gfp_order; - invalid_mask = size - 1; - BUG_ON((iova | paddr) & invalid_mask); + BUG_ON(!IS_ALIGNED(iova | paddr, size)); return iommu_ops->map(domain, iova, paddr, gfp_order, prot); } @@ -111,13 +110,11 @@ EXPORT_SYMBOL_GPL(iommu_map); int iommu_unmap(struct iommu_domain *domain, unsigned long iova, int gfp_order) { - unsigned long invalid_mask; size_t size; size = 0x1000UL << gfp_order; - invalid_mask = size - 1; - BUG_ON(iova & invalid_mask); + BUG_ON(!IS_ALIGNED(iova, size)); return iommu_ops->unmap(domain, iova, gfp_order); }