From: andi.shyti@samsung.com (Andi Shyti)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 4/5] spi: s3c64xx: simplify if statement in prepare_transfer function
Date: Tue, 28 Jun 2016 11:41:14 +0900 [thread overview]
Message-ID: <1467081676-8442-5-git-send-email-andi.shyti@samsung.com> (raw)
In-Reply-To: <1467081676-8442-1-git-send-email-andi.shyti@samsung.com>
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 <andi.shyti@samsung.com>
---
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)
--
2.8.1
next prev parent reply other threads:[~2016-06-28 2:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-28 2:41 [PATCH v2 0/5] s3c64xx: consider the case of a disconnected CS line and some code rework Andi Shyti
2016-06-28 2:41 ` [PATCH v2 1/5] spi: s3c64xx: group the CS signalling writes in a single function Andi Shyti
2016-06-28 2:41 ` [PATCH v2 2/5] spi: s3c64xx: consider the case when the CS line is not connected Andi Shyti
2016-06-30 12:15 ` Applied "spi: s3c64xx: consider the case when the CS line is not connected" to the spi tree Mark Brown
2016-06-28 2:41 ` [PATCH v2 3/5] spi: s3c64xx: do not configure the device twice Andi Shyti
2016-06-28 2:41 ` Andi Shyti [this message]
2016-06-28 2:41 ` [PATCH v2 5/5] spi: s3c64xx: use unsigned type for fifo handling variables Andi Shyti
2016-07-05 14:55 ` Mark Brown
2016-07-05 15:01 ` Andi Shyti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467081676-8442-5-git-send-email-andi.shyti@samsung.com \
--to=andi.shyti@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox