From patchwork Fri Dec 4 20:14:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Nazarewicz?= X-Patchwork-Id: 7771501 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 03593BEEE1 for ; Fri, 4 Dec 2015 20:17:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3385F205EB for ; Fri, 4 Dec 2015 20:17:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25C37205DD for ; Fri, 4 Dec 2015 20:17:38 +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 1a4wkq-0003re-U5; Fri, 04 Dec 2015 20:14:56 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a4wkn-0003pn-E0 for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2015 20:14:54 +0000 Received: by wmvv187 with SMTP id v187so90589359wmv.1 for ; Fri, 04 Dec 2015 12:14:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=bmOCdEvbux2gHYtPUtGq5DE/eHmf4jhXEQFsItZsW5Y=; b=mbi0F/s8BnAAs6rFFpLRwGpkThyqATIuMvH5U4yl+56KoCXQSjYGqvH5Mp8cxSRVQE e+wXMxazQqkXdAkK5YYYBBwgQRmRn0smwl/xQRY4dp2lNLDDEOwR8152djhKVIYwSxzW yemIQt67Fcmz8Mn/SZ70iCk+FZfnkJB8pOLGpNm0SG/4Q0as5cIS5EgUsg3MCttLV8Co Fm1Fi/gB7ZoxYMSU3ddc4jKQXg5ddVL/NfZzISaoekQEzR1z9lb6mqVEDqVX1PncW4Y/ anGHtll+IvYDp49TESN6NZ0m9TuS4RE354rqW/+n3g/DXtW9ZigZDkIqrk9RBFtrHkwr qnOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=bmOCdEvbux2gHYtPUtGq5DE/eHmf4jhXEQFsItZsW5Y=; b=arBtEbBBt2cj2Lvv1RF2VM8l5JcCwZ/ZGKMkkxdHJ9d56CPYl+ntmiuy6U1BSZ457U LDxQ2k/i4uuDGI0Yl6QgqKQvQebp59wZyzF/IVopHBdjjKubzfWL4gU94l2w4DKl9iF7 h9IJONckpm/FFAddNH79uAoIXUzGr8SDIbdjdYXlsjfa7eYF1Sx/jUOlq6N5vV/e/Dgl 7bnNvT2sgJdyNO8Ygq7nSk4vv/vMqeGA1lvNHt9t1gMtG+I2fsGqVaKin7jPNJsN37wh mXb1Rx3mhhfGaeCqNqYQK4m8FlGCFX9UETE6X0elzCbaIqvtTFgMXArWuukeQ45nPQsi JoBQ== X-Gm-Message-State: ALoCoQlTmmsfQAWzXY2u1aNygfrWAzssaQ8ZJT/Q8p2QP+TNCoATFguQIhcW56h/ZLG413/kOsrr7GzKgZZMqMAZG1pi/YZHng== X-Received: by 10.28.63.22 with SMTP id m22mr7439319wma.58.1449260071233; Fri, 04 Dec 2015 12:14:31 -0800 (PST) Received: from mpn.zrh.corp.google.com ([172.16.114.66]) by smtp.gmail.com with ESMTPSA id s11sm4953036wmb.14.2015.12.04.12.14.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Dec 2015 12:14:29 -0800 (PST) Received: by mpn.zrh.corp.google.com (Postfix, from userid 126942) id 7D22A1E0266; Fri, 4 Dec 2015 21:14:27 +0100 (CET) From: Michal Nazarewicz To: Greg Kroah-Hartman Subject: [PATCH] drivers: dma-coherent: simplify dma_init_coherent_memory return value Date: Fri, 4 Dec 2015 21:14:18 +0100 Message-Id: <1449260058-3572-1-git-send-email-mina86@mina86.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151204_121453_631727_FBF08A23 X-CRM114-Status: GOOD ( 14.59 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, Michal Nazarewicz , iamjoonsoo.kim@lge.com, torvalds@linux-foundation.org, linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 Since only dma_declare_coherent_memory cares about dma_init_coherent_memory returning part of flags as it return value, move the condition to the former and simplify the latter. This in turn makes rmem_dma_device_init less confusing. Reported-by: Fugang Duan Signed-off-by: Michal Nazarewicz Acked-by: Marek Szyprowski --- drivers/base/dma-coherent.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index 55b8398..87b8083 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -17,9 +17,9 @@ struct dma_coherent_mem { spinlock_t spinlock; }; -static int dma_init_coherent_memory(phys_addr_t phys_addr, dma_addr_t device_addr, - size_t size, int flags, - struct dma_coherent_mem **mem) +static bool dma_init_coherent_memory( + phys_addr_t phys_addr, dma_addr_t device_addr, size_t size, int flags, + struct dma_coherent_mem **mem) { struct dma_coherent_mem *dma_mem = NULL; void __iomem *mem_base = NULL; @@ -50,17 +50,13 @@ static int dma_init_coherent_memory(phys_addr_t phys_addr, dma_addr_t device_add spin_lock_init(&dma_mem->spinlock); *mem = dma_mem; - - if (flags & DMA_MEMORY_MAP) - return DMA_MEMORY_MAP; - - return DMA_MEMORY_IO; + return true; out: kfree(dma_mem); if (mem_base) iounmap(mem_base); - return 0; + return false; } static void dma_release_coherent_memory(struct dma_coherent_mem *mem) @@ -88,15 +84,13 @@ int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr, dma_addr_t device_addr, size_t size, int flags) { struct dma_coherent_mem *mem; - int ret; - ret = dma_init_coherent_memory(phys_addr, device_addr, size, flags, - &mem); - if (ret == 0) + if (!dma_init_coherent_memory(phys_addr, device_addr, size, flags, + &mem)) return 0; if (dma_assign_coherent_memory(dev, mem) == 0) - return ret; + return flags & DMA_MEMORY_MAP ? DMA_MEMORY_MAP : DMA_MEMORY_IO; dma_release_coherent_memory(mem); return 0; @@ -281,9 +275,9 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev) struct dma_coherent_mem *mem = rmem->priv; if (!mem && - dma_init_coherent_memory(rmem->base, rmem->base, rmem->size, - DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE, - &mem) != DMA_MEMORY_MAP) { + !dma_init_coherent_memory(rmem->base, rmem->base, rmem->size, + DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE, + &mem)) { pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n", &rmem->base, (unsigned long)rmem->size / SZ_1M); return -ENODEV;