public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] spi: ftssp010_spi: Simplify code flow in ftssp010_[wait|wait_tx|wait_rx]
@ 2015-01-08  1:47 Axel Lin
  2015-01-08  6:34 ` Jagan Teki
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2015-01-08  1:47 UTC (permalink / raw)
  To: u-boot

No functional change, just simplify the code a bit.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/spi/ftssp010_spi.c | 36 ++++++++++++------------------------
 1 file 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(&regs->sr) & SR_BUSY)
-			continue;
-		ret = 0;
-		break;
+		if (!(readl(&regs->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(&regs->sr) & SR_TFNF))
-			continue;
-		ret = 0;
-		break;
+		if (readl(&regs->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(&regs->sr)))
-			continue;
-		ret = 0;
-		break;
+		if (SR_RFVE(readl(&regs->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,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] spi: ftssp010_spi: Simplify code flow in ftssp010_[wait|wait_tx|wait_rx]
  2015-01-08  1:47 [U-Boot] [PATCH] spi: ftssp010_spi: Simplify code flow in ftssp010_[wait|wait_tx|wait_rx] Axel Lin
@ 2015-01-08  6:34 ` Jagan Teki
  0 siblings, 0 replies; 2+ messages in thread
From: Jagan Teki @ 2015-01-08  6:34 UTC (permalink / raw)
  To: u-boot

On 8 January 2015 at 07:17, Axel Lin <axel.lin@ingics.com> wrote:
> No functional change, just simplify the code a bit.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/spi/ftssp010_spi.c | 36 ++++++++++++------------------------
>  1 file 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(&regs->sr) & SR_BUSY)
> -                       continue;
> -               ret = 0;
> -               break;
> +               if (!(readl(&regs->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(&regs->sr) & SR_TFNF))
> -                       continue;
> -               ret = 0;
> -               break;
> +               if (readl(&regs->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(&regs->sr)))
> -                       continue;
> -               ret = 0;
> -               break;
> +               if (SR_RFVE(readl(&regs->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,
> --
> 1.9.1
>
>
>

Applied to u-boot-spi/master

thanks!
-- 
Jagan.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-08  6:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08  1:47 [U-Boot] [PATCH] spi: ftssp010_spi: Simplify code flow in ftssp010_[wait|wait_tx|wait_rx] Axel Lin
2015-01-08  6:34 ` Jagan Teki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox