From patchwork Mon Feb 20 13:10:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Gonzalez X-Patchwork-Id: 9582743 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2DF32604A0 for ; Mon, 20 Feb 2017 13:11:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D6C428481 for ; Mon, 20 Feb 2017 13:11:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11420287D0; Mon, 20 Feb 2017 13:11:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7548C28481 for ; Mon, 20 Feb 2017 13:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1QowsBhbMsMeBWqxALKco9vkT2UmDqmf7FGCWolsAoQ=; b=WSi4WWeGsExi00 LPx+tJf9Bqho29wKzQ6ar9S0I1jfJ0UJlM6+QOkE0qnspSlas0lcQoWMzcZVkZw2rpersCPYxc5Q6 MYvT6SlJW54bAap2Hxu2Vd/F+V3WfZphkts9a4WzN7DpoD69ihkWlEQw/mwowayeUgpxGCH0Yl5bH Fx2Re66WOWvcMIgAkvOKem3GNj1XVr049T75YWz8xs5akn98BspQYu1lOu4eGmT34NbaFa74+1W7x CXfn8BXyi50joG5D/UzdLgapI9+TGoYY+B+ja3IRD5uLG/3dPx0dbsB0LYbV26g/Kx/rWaUChuAQ5 be3GJOjJqVoXk+hyA4jw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cfnk4-0006Mv-1k; Mon, 20 Feb 2017 13:11:00 +0000 Received: from mail1.bemta8.messagelabs.com ([216.82.243.198]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cfnjd-0006Lx-Bj; Mon, 20 Feb 2017 13:10:36 +0000 Received: from [216.82.242.46] by server-6.bemta-8.messagelabs.com id 07/1A-09120-2BAEAA85; Mon, 20 Feb 2017 13:10:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMIsWRWlGSWpSXmKPExsVy+LrFKt1Nr1Z FGGzYLGpx4MVCFosjF9YyW9z7fp7ZYuLKycwWmx5fY7XY3bSM3eLonnvMFpN3vmF04PBY8Gsr i8eTTRcZPXbOusvusXmFlsfmJfUeN+cVBrBFsWbmJeVXJLBmPJ55gLmgjb9iw4ydzA2MX3m6G Lk4hASWMUos+3GctYuRk0NYwEHi7NavzCC2iICFRMfDo2wgRcwCs5gkHr+5wQaSEBLYyChxtS kWxGYTMJG4ef8cC4jNK+Ascb55NZjNIqAqMeXVFbBBogIJEhf/TGGFqBGUODnzCVgNp4ChxLF fHxlBbGYBfYmmrXOYIWx5ie1vIWwhAW2J9xsXg/VKCChITJ3cyjyBkX8WklGzkLTPQtK+gJF5 FaN6cWpRWWqRrrleUlFmekZJbmJmjq6hgYVebmpxcWJ6ak5iUrFecn7uJkZg4DMAwQ7GE5OdD zFKcjApifLeWbIqQogvKT+lMiOxOCO+qDQntfgQowwHh5IE74OXQDnBotT01Iq0zBxgDMKkJT h4lEQg0rzFBYm5xZnpEKlTjIpS4rxCwMgVEgBJZJTmwbXB4v4So6yUMC8j0CFCPAWpRbmZJaj yrxjFORiVhHnTQcbzZOaVwE1/BbSYCWjxTY+VIItLEhFSUg2MPMbsX4PvZzM/6liSl6z6Oy5M IP7e/Y2eB7oOrVn3T+qlXdC35PWHG/b3czqWKzM2XW4M4VxSKSY3r94i2+3Lmjrb5S1KX2/Kv g1pPx73w+/kybzJmTu/ftfyKOKSS7u1OYAph/XQOx3h3YcupCac2S34NrHrHU/CjM9eEc/Za9 +UC1ze0yCjxFKckWioxVxUnAgAaDx9ZfYCAAA= X-Env-Sender: Marc_Gonzalez@sigmadesigns.com X-Msg-Ref: server-2.tower-96.messagelabs.com!1487596209!51853354!1 X-Originating-IP: [195.215.56.170] X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26853 invoked from network); 20 Feb 2017 13:10:10 -0000 Received: from 195-215-56-170-static.dk.customer.tdc.net (HELO CPH-EX1.SDESIGNS.COM) (195.215.56.170) by server-2.tower-96.messagelabs.com with AES128-SHA encrypted SMTP; 20 Feb 2017 13:10:10 -0000 Received: from [172.27.0.114] (172.27.0.114) by CPH-EX1.sdesigns.com (192.168.10.36) with Microsoft SMTP Server (TLS) id 14.3.294.0; Mon, 20 Feb 2017 14:10:08 +0100 Subject: [PATCH v2] mtd: nand: tango: Enforce DMA direction type To: Boris Brezillon References: <1486979107-15362-1-git-send-email-boris.brezillon@free-electrons.com> <20170220133547.06c17a12@bbrezillon> From: Marc Gonzalez Message-ID: <72b68483-8a02-f6b8-f6b7-da492585c802@sigmadesigns.com> Date: Mon, 20 Feb 2017 14:10:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0 SeaMonkey/2.48 MIME-Version: 1.0 In-Reply-To: <20170220133547.06c17a12@bbrezillon> X-Originating-IP: [172.27.0.114] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170220_051033_487359_EB4AD746 X-CRM114-Status: GOOD ( 12.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , Marek Vasut , linux-mtd@lists.infradead.org, Cyrille Pitchen , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Boris Brezillon do_dma() uses an int to pass the DMA data direction information and pass the same value to dmaengine_prep_slave_sg(). Currently, DMA_{FROM,TO}_DEVICE match DMA_{DEV_TO_MEM,MEM_TO_DEV} definitions so it works fine, but assuming this will always be the case is not safe. Enforce enum dma_data_direction type in the function prototype and make the enum dma_data_direction -> enum dma_transfer_direction conversion explicit. Reported-by: Richard Weinberger Signed-off-by: Boris Brezillon Acked-by: Marc Gonzalez --- drivers/mtd/nand/tango_nand.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c index 4a5e948c62df..05b6e1065203 100644 --- a/drivers/mtd/nand/tango_nand.c +++ b/drivers/mtd/nand/tango_nand.c @@ -223,12 +223,13 @@ static void tango_dma_callback(void *arg) complete(arg); } -static int do_dma(struct tango_nfc *nfc, int dir, int cmd, const void *buf, - int len, int page) +static int do_dma(struct tango_nfc *nfc, enum dma_data_direction dir, int cmd, + const void *buf, int len, int page) { void __iomem *addr = nfc->reg_base + NFC_STATUS; struct dma_chan *chan = nfc->chan; struct dma_async_tx_descriptor *desc; + enum dma_transfer_direction tdir; struct scatterlist sg; struct completion tx_done; int err = -EIO; @@ -238,7 +239,8 @@ static int do_dma(struct tango_nfc *nfc, int dir, int cmd, const void *buf, if (dma_map_sg(chan->device->dev, &sg, 1, dir) != 1) return -EIO; - desc = dmaengine_prep_slave_sg(chan, &sg, 1, dir, DMA_PREP_INTERRUPT); + tdir = dir == DMA_TO_DEVICE ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; + desc = dmaengine_prep_slave_sg(chan, &sg, 1, tdir, DMA_PREP_INTERRUPT); if (!desc) goto dma_unmap;