Skip to content
Snippets Groups Projects
Commit 78c80114 authored by Axel Lin's avatar Axel Lin Committed by Jagannadha Sutradharudu Teki
Browse files

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: default avatarAxel Lin <axel.lin@ingics.com>
Reviewed-by: default avatarJagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
parent 1dc7d00f
No related branches found
No related tags found
Loading
...@@ -169,61 +169,49 @@ static int get_spi_gpio(int bus, struct ftssp010_gpio *chip) ...@@ -169,61 +169,49 @@ static int get_spi_gpio(int bus, struct ftssp010_gpio *chip)
static int ftssp010_wait(struct ftssp010_spi *chip) static int ftssp010_wait(struct ftssp010_spi *chip)
{ {
struct ftssp010_regs *regs = chip->regs; struct ftssp010_regs *regs = chip->regs;
int ret = -1;
ulong t; ulong t;
/* wait until device idle */ /* wait until device idle */
for (t = get_timer(0); get_timer(t) < CONFIG_FTSSP010_TIMEOUT; ) { for (t = get_timer(0); get_timer(t) < CONFIG_FTSSP010_TIMEOUT; ) {
if (readl(&regs->sr) & SR_BUSY) if (!(readl(&regs->sr) & SR_BUSY))
continue; return 0;
ret = 0;
break;
} }
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) static int ftssp010_wait_tx(struct ftssp010_spi *chip)
{ {
struct ftssp010_regs *regs = chip->regs; struct ftssp010_regs *regs = chip->regs;
int ret = -1;
ulong t; ulong t;
/* wait until tx fifo not full */ /* wait until tx fifo not full */
for (t = get_timer(0); get_timer(t) < CONFIG_FTSSP010_TIMEOUT; ) { for (t = get_timer(0); get_timer(t) < CONFIG_FTSSP010_TIMEOUT; ) {
if (!(readl(&regs->sr) & SR_TFNF)) if (readl(&regs->sr) & SR_TFNF)
continue; return 0;
ret = 0;
break;
} }
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) static int ftssp010_wait_rx(struct ftssp010_spi *chip)
{ {
struct ftssp010_regs *regs = chip->regs; struct ftssp010_regs *regs = chip->regs;
int ret = -1;
ulong t; ulong t;
/* wait until rx fifo not empty */ /* wait until rx fifo not empty */
for (t = get_timer(0); get_timer(t) < CONFIG_FTSSP010_TIMEOUT; ) { for (t = get_timer(0); get_timer(t) < CONFIG_FTSSP010_TIMEOUT; ) {
if (!SR_RFVE(readl(&regs->sr))) if (SR_RFVE(readl(&regs->sr)))
continue; return 0;
ret = 0;
break;
} }
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, static int ftssp010_spi_work_transfer_v2(struct ftssp010_spi *chip,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment