From patchwork Thu May 17 13:13:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 8730 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 20A7B23E13 for ; Thu, 17 May 2012 13:16:11 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id E50B4A18B69 for ; Thu, 17 May 2012 13:16:10 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so2107124yen.11 for ; Thu, 17 May 2012 06:16:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :in-reply-to:to:message-id:mime-version:x-mailer:references:cc :subject:x-beenthere:x-mailman-version:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :content-type:content-transfer-encoding:sender:errors-to :x-gm-message-state; bh=fFGqFOmHZHC2TBwa7scIomhkmRMeA/Q3TmI7E0wEVak=; b=FUX/Ao4TmrFPWujZKNkRnETaDThCwfOJgZjWfW2Ym3PquScHAckQpBd9UGuvhFPgT3 8f/HuAdiMK5l4jkbHL5FRuGCmj8dETKJDuKupKXCnvK53kXe8MSKmTviIy6MX5VLyKwI NNNZu305YghQoeAVN0InlSa0eUA6EGFamMOXZp+pawmApUAYobdmpGR1H4UxH8B+eN7o aN3ixZTpvcFvf/zkbMa0ICEqjyl2Iod+28tQRJdhScFNo0mAAls3m+V/HlGKxAZwQVEJ mUomNHkAvWTEeQ1GgQi4J4PTiOAiSzV91z4a1vE1Td4N0mPvfqkW4Zg0qm0y3hBFSRLr 0Yag== Received: by 10.50.85.163 with SMTP id i3mr5197408igz.57.1337260570488; Thu, 17 May 2012 06:16:10 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.35.72 with SMTP id o8csp27103ibd; Thu, 17 May 2012 06:16:07 -0700 (PDT) Received: by 10.180.102.9 with SMTP id fk9mr7890478wib.1.1337260566882; Thu, 17 May 2012 06:16:06 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id m21si7302003wee.82.2012.05.17.06.16.05; Thu, 17 May 2012 06:16:06 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SV0Yn-0000aA-2N; Thu, 17 May 2012 13:16:05 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SV0Yl-0000Ye-5d for linaro-mm-sig@lists.linaro.org; Thu, 17 May 2012 13:16:03 +0000 Received: from euspt2 (mailout2.w1.samsung.com [210.118.77.12]) by mailout2.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTP id <0M46007LK4UIQB@mailout2.w1.samsung.com> for linaro-mm-sig@lists.linaro.org; Thu, 17 May 2012 14:15:54 +0100 (BST) Received: from ubuntu.arm.acom ([106.210.236.191]) by spt2.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0M46005864TPC2@spt2.w1.samsung.com> for linaro-mm-sig@lists.linaro.org; Thu, 17 May 2012 14:16:00 +0100 (BST) Date: Thu, 17 May 2012 15:13:54 +0200 From: Marek Szyprowski In-reply-to: <1337260441-8121-1-git-send-email-m.szyprowski@samsung.com> To: linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, iommu@lists.linux-foundation.org Message-id: <1337260441-8121-5-git-send-email-m.szyprowski@samsung.com> MIME-version: 1.0 X-Mailer: git-send-email 1.7.10.1 References: <1337260441-8121-1-git-send-email-m.szyprowski@samsung.com> Cc: Russell King - ARM Linux , Arnd Bergmann , Konrad Rzeszutek Wilk , Benjamin Herrenschmidt , Kyungmin Park , Andrzej Pietrasiewicz , KyongHo Cho , Joerg Roedel Subject: [Linaro-mm-sig] [PATCHv10 04/11] ARM: dma-mapping: introduce DMA_ERROR_CODE constant X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQm0/8aHd2hk3NKKirluSRZCTx9DF9jVsyHlXwM3f+/bAmnYICLyQKY5z16QegJsGzB9wyBR Replace all uses of ~0 with DMA_ERROR_CODE, what should make the code easier to read. Signed-off-by: Marek Szyprowski Acked-by: Kyungmin Park Tested-By: Subash Patel --- arch/arm/common/dmabounce.c | 6 +++--- arch/arm/include/asm/dma-mapping.h | 4 +++- arch/arm/mm/dma-mapping.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 595ecd29..210ad1b 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c @@ -254,7 +254,7 @@ static inline dma_addr_t map_single(struct device *dev, void *ptr, size_t size, if (buf == NULL) { dev_err(dev, "%s: unable to map unsafe buffer %p!\n", __func__, ptr); - return ~0; + return DMA_ERROR_CODE; } dev_dbg(dev, "%s: unsafe buffer %p (dma=%#x) mapped to %p (dma=%#x)\n", @@ -320,7 +320,7 @@ dma_addr_t __dma_map_page(struct device *dev, struct page *page, ret = needs_bounce(dev, dma_addr, size); if (ret < 0) - return ~0; + return DMA_ERROR_CODE; if (ret == 0) { __dma_page_cpu_to_dev(page, offset, size, dir); @@ -329,7 +329,7 @@ dma_addr_t __dma_map_page(struct device *dev, struct page *page, if (PageHighMem(page)) { dev_err(dev, "DMA buffer bouncing of HIGHMEM pages is not supported\n"); - return ~0; + return DMA_ERROR_CODE; } return map_single(dev, page_address(page) + offset, size, dir); diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index cb3b7c9..6a838da 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -10,6 +10,8 @@ #include #include +#define DMA_ERROR_CODE (~0) + #ifdef __arch_page_to_dma #error Please update to __arch_pfn_to_dma #endif @@ -123,7 +125,7 @@ extern int dma_set_mask(struct device *, u64); */ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) { - return dma_addr == ~0; + return dma_addr == DMA_ERROR_CODE; } /* diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 322c70a..e4ac5fc 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -342,7 +342,7 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp, */ gfp &= ~(__GFP_COMP); - *handle = ~0; + *handle = DMA_ERROR_CODE; size = PAGE_ALIGN(size); page = __dma_alloc_buffer(dev, size, gfp);