From patchwork Tue May 20 04:32:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ritesh Harjani X-Patchwork-Id: 4207281 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7DA809F1CD for ; Tue, 20 May 2014 04:45:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA42F20219 for ; Tue, 20 May 2014 04:45:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 912AA20212 for ; Tue, 20 May 2014 04:45:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wmbjy-00077f-Mw; Tue, 20 May 2014 04:33:26 +0000 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wmbjw-00073A-88 for linux-arm-kernel@lists.infradead.org; Tue, 20 May 2014 04:33:24 +0000 X-IronPort-AV: E=Sophos;i="4.98,871,1392192000"; d="scan'208";a="30211620" Received: from irvexchcas07.broadcom.com (HELO IRVEXCHCAS07.corp.ad.broadcom.com) ([10.9.208.55]) by mail-gw2-out.broadcom.com with ESMTP; 19 May 2014 21:33:13 -0700 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.3.174.1; Mon, 19 May 2014 21:33:02 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.3.174.1; Mon, 19 May 2014 21:33:02 -0700 Received: from xl-blr-mob1.broadcom.com (xl-blr-mob1.ban.broadcom.com [10.132.132.208]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id CD9989F9F7; Mon, 19 May 2014 21:33:01 -0700 (PDT) Received: by xl-blr-mob1.broadcom.com (Postfix, from userid 29513) id A8653680E8F; Tue, 20 May 2014 10:03:00 +0530 (IST) From: To: , Subject: [PATCH v2] arm: dma-iommu: Clean up redundant variable Date: Tue, 20 May 2014 10:02:59 +0530 Message-ID: <1400560379-1502-1-git-send-email-ritesh.harjani@gmail.com> X-Mailer: git-send-email 1.8.1.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140519_213324_354881_CF93CB6A X-CRM114-Status: GOOD ( 12.77 ) X-Spam-Score: -1.7 (-) Cc: mp.vikram@gmail.com, Will.Deacon@arm.com, iommu@lists.linux-foundation.org, laurent.pinchart@ideasonboard.com, ritesh.harjani@gmail.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ritesh Harjani mapping->size can be derived from mapping->bits << PAGE_SHIFT which makes mapping->size as redundant. Clean this up. Signed-off-by: Ritesh Harjani Reported-by: Will Deacon --- arch/arm/include/asm/dma-iommu.h | 1 - arch/arm/mm/dma-mapping.c | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-iommu.h index eec0a12..8e3fcb9 100644 --- a/arch/arm/include/asm/dma-iommu.h +++ b/arch/arm/include/asm/dma-iommu.h @@ -18,7 +18,6 @@ struct dma_iommu_mapping { unsigned int extensions; size_t bitmap_size; /* size of a single bitmap */ size_t bits; /* per bitmap */ - unsigned int size; /* per bitmap */ dma_addr_t base; spinlock_t lock; diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 6b00be1..3d43c41 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1074,6 +1074,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping, unsigned int order = get_order(size); unsigned int align = 0; unsigned int count, start; + size_t mapping_size = mapping->bits << PAGE_SHIFT; unsigned long flags; dma_addr_t iova; int i; @@ -1119,7 +1120,7 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping, } spin_unlock_irqrestore(&mapping->lock, flags); - iova = mapping->base + (mapping->size * i); + iova = mapping->base + (mapping_size * i); iova += start << PAGE_SHIFT; return iova; @@ -1129,6 +1130,7 @@ static inline void __free_iova(struct dma_iommu_mapping *mapping, dma_addr_t addr, size_t size) { unsigned int start, count; + size_t mapping_size = mapping->bits << PAGE_SHIFT; unsigned long flags; dma_addr_t bitmap_base; u32 bitmap_index; @@ -1136,14 +1138,14 @@ static inline void __free_iova(struct dma_iommu_mapping *mapping, if (!size) return; - bitmap_index = (u32) (addr - mapping->base) / (u32) mapping->size; + bitmap_index = (u32) (addr - mapping->base) / (u32) mapping_size; BUG_ON(addr < mapping->base || bitmap_index > mapping->extensions); - bitmap_base = mapping->base + mapping->size * bitmap_index; + bitmap_base = mapping->base + mapping_size * bitmap_index; start = (addr - bitmap_base) >> PAGE_SHIFT; - if (addr + size > bitmap_base + mapping->size) { + if (addr + size > bitmap_base + mapping_size) { /* * The address range to be freed reaches into the iova * range of the next bitmap. This should not happen as @@ -1964,7 +1966,6 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size) mapping->extensions = extensions; mapping->base = base; mapping->bits = BITS_PER_BYTE * bitmap_size; - mapping->size = mapping->bits << PAGE_SHIFT; spin_lock_init(&mapping->lock);