From patchwork Sun Nov 11 20:23:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10677853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8F61139B for ; Sun, 11 Nov 2018 20:25:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABACE2969C for ; Sun, 11 Nov 2018 20:25:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FBC6296F9; Sun, 11 Nov 2018 20:25:31 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 4A58B2969C for ; Sun, 11 Nov 2018 20:25:31 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hLouXFNypHlFaQAINMwgzkBeirVP1RY0gAHWHAnuLpo=; b=rmTlZsugtWGOssKkbRRBUkkaMC 1KnpesZRiXcQ3pdco/0rDLTQmYxTCEUjV4xsBFaLiaoMeezFdRRBXGZeSPhk38338Y976XJ4cVMz2 XEbMflV3FhK8eHtirh7evoVdHR93K8s2TnFG5umUjZP9CNK6jB1uaKvNeOQt7ysjNFYI/o6mSAWQ8 96SikljKpBqFYT7sfjGMWWxEneZVIcw0uQMa+gaOxVIiXtG4BrxHOs3Fw9RjRuZ5eKEU1p3gCQVbu XbZW1eUFOHav2KoX7nPYCjHgWhH6YwMTgEBBAnxobbfRHrCEpD9qTd5jujkCLDGdlUfcIs0x0gwMY NVzKWO6w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLwIR-0004Ov-6u; Sun, 11 Nov 2018 20:25:27 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLwHv-0002cX-I3; Sun, 11 Nov 2018 20:24:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EGvrhwUaJ7ExcJvbLK8/AQ0rd/CXDt+a3em7ick8oO0=; b=hfLWj/nwTsxPLUALv1QKEYerW kjTYzuw+nLWWi3Jmk4P9vRYMn7+DaGgrbi72/tY2ByngSSImu0PrCS8lm9Ptuq6yXd6tYsNVfzM2v rmYwqdSBQg1JTzAY2Z9nFvV3PB1XFF36Lt1oFlkORRtQJSII2YZBaRJeyhjLpTqzBUwi4KgcWj56K R6ymka+uGJPQ+KHwaOaS67glzE2ADOBMchS7gZu6WtPJEtwU5d7FMyWWPFV7PM4wKFS5Mkk59+9ee hj7e7Zi/7YhnCEfVfZf7C6h6ejiW9YdnMadgdZttuh9DdLGUYVyGszdcNAwmEbpJUSvqM0MxYOBG7 /ZftqWKLA==; Received: from mout.kundenserver.de ([212.227.126.130]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLwHs-0001em-CO; Sun, 11 Nov 2018 20:24:53 +0000 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MvsyF-1fX0UQ3835-00ssSz; Sun, 11 Nov 2018 21:24:33 +0100 From: Stefan Wahren To: Eric Anholt , Florian Fainelli , Ulf Hansson Subject: [PATCH V2 6/7] mmc: bcm2835: Refactor dma_map_sg handling Date: Sun, 11 Nov 2018 21:23:58 +0100 Message-Id: <1541967839-2847-7-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541967839-2847-1-git-send-email-stefan.wahren@i2se.com> References: <1541967839-2847-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K1:Sla5WKzJYGbilks4eIirHiMlx29aYsbN7KwNBzyZekQFCAy53V8 1SG4Lh3Be8yGw2tWhcGIWU4+p6Ui+o/TdYr+msz83Y0Sz252M6RAloy6wfmI9j/ONOhpARN +Df5870IhZ0IcFsZwP4UNPyitLHHEtB7F0h3fH1ljMmy4qfxVgId5TqXkESoEci3lMhK7jI tJt2agPN6ETkDIC1k0S1Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:SUFly36V7h8=:Vbqq6FwnjjUoAgvV8E+dwd bvly0MobT7aTFxA6S7rJV76JrzK5Re4JsOiUl+7WNjHC+DT2hjNquy1oxd711UcXEAOqmPFAy OJDhIHqS7UAkipQ25kMVV+BUFSDtsYwZhfhJUWMjETSgSOajgeWoTywu70K5P4OAAASvrVwUb 5TED1Vlj0n4fcrmLZdSEpborCiHk3YNdLhHxo7AG1BES3nZGoIOGVdoJ46ueOSmNZlp0owl9C M6Ojk98PRUoV+3jn1od8MDRUazJRG187IGTG+1VZESWHn7IZveLNLhDzy9+pchAhovgwQnFhL 7cEt1VIJEk2QWc/pp3PrNUoQCHOI5lull8+TfBIrkPFQShcmEsXvtJ6xW70m7LKvLB1hQyGue 51kaIx86/7KW5bKnONR8GsPRhAaPWpNwJGk0sl8QgnahjcjoSc5V1pcb41Zxsikmxh/zy3bUA 93kQOzW2tjR1yw/Ppz+A2pvnad6QRY2pxB6+t2MJdrZTc4LZGCE7kTqYpoV40uPFTb9VNxhJK fhNmDEgLBtlKz7usJIQXHfrsvC/0r0Efs194mqEs0U8S5C/ip+SYxzdNqy7950R3erQQJ4ABy 87xgLsDdOxe4m9f0ncvU1pd6Ys03Hw9vN4IKH11GptHYaTkZeCF5YTS6I+rIjI+6s8cB5AUV+ ZdjGUkrqxgkOsWgD1WRTl0+ejxE6GWxX+gsLRlzis74GhO5+V2G/x5/A9oPGp5YsT9ZzqWRb4 qP502rMnCPihAEgYTtgKeezNgBny3yQT+LvwXEj4gaeiyNOn/d7082ZRkf0TNexaK77RI3zqH C4R9zEnu6vgo7DndG6z+zIAO1Ihxg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181111_152452_682340_CD00EDF2 X-CRM114-Status: GOOD ( 12.64 ) 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: Stefan Wahren , Phil Elwell , linux-mmc@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Michal Suchanek , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 There are two variables len within bcm2835_prepare_dma. So rename the result of dma_map_sg to sg_len. While we are at this add a bail out to simplify the following change. Signed-off-by: Stefan Wahren --- drivers/mmc/host/bcm2835.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 2c7589f..c42bdaa 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -464,7 +464,7 @@ static void bcm2835_transfer_pio(struct bcm2835_host *host) static void bcm2835_prepare_dma(struct bcm2835_host *host, struct mmc_data *data) { - int len, dir_data, dir_slave; + int sg_len, dir_data, dir_slave; struct dma_async_tx_descriptor *desc = NULL; struct dma_chan *dma_chan; @@ -510,15 +510,13 @@ void bcm2835_prepare_dma(struct bcm2835_host *host, struct mmc_data *data) &host->dma_cfg_rx : &host->dma_cfg_tx); - len = dma_map_sg(dma_chan->device->dev, data->sg, data->sg_len, - dir_data); + sg_len = dma_map_sg(dma_chan->device->dev, data->sg, data->sg_len, + dir_data); + if (!sg_len) + return; - if (len > 0) { - desc = dmaengine_prep_slave_sg(dma_chan, data->sg, - len, dir_slave, - DMA_PREP_INTERRUPT | - DMA_CTRL_ACK); - } + desc = dmaengine_prep_slave_sg(dma_chan, data->sg, sg_len, dir_slave, + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); if (desc) { desc->callback = bcm2835_dma_complete;