From patchwork Tue Jun 28 02:41:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 9201701 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 B1299607D3 for ; Tue, 28 Jun 2016 02:42:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0386285E3 for ; Tue, 28 Jun 2016 02:42:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91DF1285EA; Tue, 28 Jun 2016 02:42:56 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3986C285E1 for ; Tue, 28 Jun 2016 02:42:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752077AbcF1CmP (ORCPT ); Mon, 27 Jun 2016 22:42:15 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:34444 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbcF1CmJ (ORCPT ); Mon, 27 Jun 2016 22:42:09 -0400 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9G017IENH5TE20@mailout4.samsung.com>; Tue, 28 Jun 2016 11:41:29 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id AC.CB.05174.8D3E1775; Tue, 28 Jun 2016 11:41:29 +0900 (KST) X-AuditID: cbfee68d-f79876d000001436-b5-5771e3d87907 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 35.27.04429.8D3E1775; Mon, 27 Jun 2016 19:41:28 -0700 (MST) Received: from samsunx.samsung ([10.113.63.54]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O9G00A9QNH1H050@mmp2.samsung.com>; Tue, 28 Jun 2016 11:41:28 +0900 (KST) From: Andi Shyti To: Kukjin Kim , Krzysztof Kozlowski , Mark Brown Cc: Jaehoon Chung , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH v2 4/5] spi: s3c64xx: simplify if statement in prepare_transfer function Date: Tue, 28 Jun 2016 11:41:14 +0900 Message-id: <1467081676-8442-5-git-send-email-andi.shyti@samsung.com> X-Mailer: git-send-email 2.8.1 In-reply-to: <1467081676-8442-1-git-send-email-andi.shyti@samsung.com> References: <1467081676-8442-1-git-send-email-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGLMWRmVeSWpSXmKPExsWyRsSkUPfm48Jwg9Y+RovtR56xWiz+8ZzJ YurDJ2wWN361sVq8fmFo0f/4NbPFpsfXWC0u75rDZjHj/D4mi8aPN9kduDyuL/nE7LFpVSeb x+Yl9R59W1YxenzeJBfAGsVlk5Kak1mWWqRvl8CVsf7SHuaCJUIVD9tvsjYwfuHrYuTkkBAw kdi5dSk7hC0mceHeejYQW0hgBaPEz6UKMDUTZi0CinMBxWcxSsw99QHK+cgo0fj5AgtIFZuA pkTT7R9g3SICxRJPrv5nBSliFvjGKLHg5ETGLkYODmGBKInpxx1BalgEVCU2THjPDhLmFXC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sbIqtSg/vqg0J7X4EKMp0F0TmaVEk/OBCSCvJN7Q2MTMyNLI3NDCyNhcSZz3 8f91YUIC6YklqdmpqQWpRTB9TBycUg2MK9jfdlg8Z3N+qHTbK89F9rVw/Lnsgwb/ju9n9FH0 YZ5wdXWbwF5nrUmfWHY+ung5rT1MlmXfurw29TdJ57n3mjw/aXX3/Ux3vpOagTY/5Vr/1rC9 Tc5/dlJL3/yQm6XRw9htzbMFeuZ/LTOKNRTKCHskIC5zxWevbbXTv/fW1k1nd+exT49QYinO SDTUYi4qTgQAdZiAisgCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The whole function is inside an 'if' statement ("!is_polling(sdd)"). Check the opposite of that statement at the beginning and exit, this way we can have one level less of indentation. Remove the goto paths as they are redundant. Signed-off-by: Andi Shyti --- drivers/spi/spi-s3c64xx.c | 50 +++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index c65a9e6..6d8486f 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -341,38 +341,32 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) dma_filter_fn filter = sdd->cntrlr_info->filter; struct device *dev = &sdd->pdev->dev; dma_cap_mask_t mask; - int ret; - if (!is_polling(sdd)) { - dma_cap_zero(mask); - dma_cap_set(DMA_SLAVE, mask); - - /* Acquire DMA channels */ - sdd->rx_dma.ch = dma_request_slave_channel_compat(mask, filter, - sdd->cntrlr_info->dma_rx, dev, "rx"); - if (!sdd->rx_dma.ch) { - dev_err(dev, "Failed to get RX DMA channel\n"); - ret = -EBUSY; - goto out; - } - spi->dma_rx = sdd->rx_dma.ch; - - sdd->tx_dma.ch = dma_request_slave_channel_compat(mask, filter, - sdd->cntrlr_info->dma_tx, dev, "tx"); - if (!sdd->tx_dma.ch) { - dev_err(dev, "Failed to get TX DMA channel\n"); - ret = -EBUSY; - goto out_rx; - } - spi->dma_tx = sdd->tx_dma.ch; + if (is_polling(sdd)) + return 0; + + dma_cap_zero(mask); + dma_cap_set(DMA_SLAVE, mask); + + /* Acquire DMA channels */ + sdd->rx_dma.ch = dma_request_slave_channel_compat(mask, filter, + sdd->cntrlr_info->dma_rx, dev, "rx"); + if (!sdd->rx_dma.ch) { + dev_err(dev, "Failed to get RX DMA channel\n"); + return -EBUSY; } + spi->dma_rx = sdd->rx_dma.ch; - return 0; + sdd->tx_dma.ch = dma_request_slave_channel_compat(mask, filter, + sdd->cntrlr_info->dma_tx, dev, "tx"); + if (!sdd->tx_dma.ch) { + dev_err(dev, "Failed to get TX DMA channel\n"); + dma_release_channel(sdd->rx_dma.ch); + return -EBUSY; + } + spi->dma_tx = sdd->tx_dma.ch; -out_rx: - dma_release_channel(sdd->rx_dma.ch); -out: - return ret; + return 0; } static int s3c64xx_spi_unprepare_transfer(struct spi_master *spi)