diff options
author | Axel Lin <axel.lin@ingics.com> | 2015-01-08 09:47:22 +0800 |
---|---|---|
committer | Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com> | 2015-01-08 12:02:55 +0530 |
commit | 78c80114b5f7f31b4a1c09bfd0db61ded24b1f6b (patch) | |
tree | d7605e86ddb942f3a3d53b02ed0ea562a87a656e /drivers | |
parent | 1dc7d00f2783991387fe715d61b50fe7b40fd30a (diff) | |
download | u-boot-imx-78c80114b5f7f31b4a1c09bfd0db61ded24b1f6b.zip u-boot-imx-78c80114b5f7f31b4a1c09bfd0db61ded24b1f6b.tar.gz u-boot-imx-78c80114b5f7f31b4a1c09bfd0db61ded24b1f6b.tar.bz2 |
spi: ftssp010_spi: Simplify code flow in ftssp010_[wait|wait_tx|wait_rx]
No functional change, just simplify the code a bit.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/spi/ftssp010_spi.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/drivers/spi/ftssp010_spi.c b/drivers/spi/ftssp010_spi.c index aa3b5a0..267e4d8 100644 --- a/drivers/spi/ftssp010_spi.c +++ b/drivers/spi/ftssp010_spi.c @@ -169,61 +169,49 @@ static int get_spi_gpio(int bus, struct ftssp010_gpio *chip) static int ftssp010_wait(struct ftssp010_spi *chip) { struct ftssp010_regs *regs = chip->regs; - int ret = -1; ulong t; /* wait until device idle */ for (t = get_timer(0); get_timer(t) < CONFIG_FTSSP010_TIMEOUT; ) { - if (readl(®s->sr) & SR_BUSY) - continue; - ret = 0; - break; + if (!(readl(®s->sr) & SR_BUSY)) + return 0; } - if (ret) - puts("ftspi010: busy timeout\n"); + puts("ftspi010: busy timeout\n"); - return ret; + return -1; } static int ftssp010_wait_tx(struct ftssp010_spi *chip) { struct ftssp010_regs *regs = chip->regs; - int ret = -1; ulong t; /* wait until tx fifo not full */ for (t = get_timer(0); get_timer(t) < CONFIG_FTSSP010_TIMEOUT; ) { - if (!(readl(®s->sr) & SR_TFNF)) - continue; - ret = 0; - break; + if (readl(®s->sr) & SR_TFNF) + return 0; } - if (ret) - puts("ftssp010: tx timeout\n"); + puts("ftssp010: tx timeout\n"); - return ret; + return -1; } static int ftssp010_wait_rx(struct ftssp010_spi *chip) { struct ftssp010_regs *regs = chip->regs; - int ret = -1; ulong t; /* wait until rx fifo not empty */ for (t = get_timer(0); get_timer(t) < CONFIG_FTSSP010_TIMEOUT; ) { - if (!SR_RFVE(readl(®s->sr))) - continue; - ret = 0; - break; + if (SR_RFVE(readl(®s->sr))) + return 0; } - if (ret) - puts("ftssp010: rx timeout\n"); + puts("ftssp010: rx timeout\n"); - return ret; + return -1; } static int ftssp010_spi_work_transfer_v2(struct ftssp010_spi *chip, |