diff mbox

[U-Boot,v2,14/16] sf: Use spi_flash_read_common() in write status poll

Message ID 4339c21f-7068-4a4c-a993-930813f461c7@CO9EHSMHS017.ehs.local
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Jagannadha Sutradharudu Teki May 31, 2013, 12:52 p.m. UTC
Instead of using spi_xfer for SPI_XFER_BEGIN and SPI_XFER_END
separatley use common read call spi_flash_read_common() which
does the same.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
---
Changes for v2:
        - none

 drivers/mtd/spi/spi_flash.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

Comments

Simon Glass June 8, 2013, 2:43 p.m. UTC | #1
Hi Jagan,

On Fri, May 31, 2013 at 5:52 AM, Jagannadha Sutradharudu Teki <
jagannadha.sutradharudu-teki@xilinx.com> wrote:

> Instead of using spi_xfer for SPI_XFER_BEGIN and SPI_XFER_END
> separatley use common read call spi_flash_read_common() which
> does the same.
>
> Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
> ---
> Changes for v2:
>         - none
>
>  drivers/mtd/spi/spi_flash.c | 17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
> index 821aa2e..765d4bc 100644
> --- a/drivers/mtd/spi/spi_flash.c
> +++ b/drivers/mtd/spi/spi_flash.c
> @@ -193,32 +193,25 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash,
> u32 offset,
>  int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout,
>                            u8 cmd, u8 poll_bit)
>  {
> -       struct spi_slave *spi = flash->spi;
>         unsigned long timebase;
>         int ret;
>         u8 status;
>
> -       ret = spi_xfer(spi, 8, &cmd, NULL, SPI_XFER_BEGIN);
> -       if (ret) {
> -               debug("SF: Failed to send command %02x: %d\n", cmd, ret);
> -               return ret;
> -       }
> -
>         timebase = get_timer(0);
>         do {
>                 WATCHDOG_RESET();
>
> -               ret = spi_xfer(spi, 8, NULL, &status, 0);
> -               if (ret)
> -                       return -1;
> +               ret = spi_flash_read_common(flash, &cmd, 1, &status, 1);
> +               if (ret < 0) {
> +                       debug("SF: fail to read read status register\n");
> +                       return ret;
> +               }
>

As mentioned elsewhere, do you need to make this change? Is it not possible
to read the status register in the same way as now?

spi_flash_read_common() does a separate SPI transaction for each read.


>
>                 if ((status & poll_bit) == 0)
>                         break;
>
>         } while (get_timer(timebase) < timeout);
>
> -       spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END);
> -
>         if ((status & poll_bit) == 0)
>                 return 0;
>
> --
> 1.8.3
>
>
>

Regards,
Simon
diff mbox

Patch

diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 821aa2e..765d4bc 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -193,32 +193,25 @@  int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
 int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout,
 			   u8 cmd, u8 poll_bit)
 {
-	struct spi_slave *spi = flash->spi;
 	unsigned long timebase;
 	int ret;
 	u8 status;
 
-	ret = spi_xfer(spi, 8, &cmd, NULL, SPI_XFER_BEGIN);
-	if (ret) {
-		debug("SF: Failed to send command %02x: %d\n", cmd, ret);
-		return ret;
-	}
-
 	timebase = get_timer(0);
 	do {
 		WATCHDOG_RESET();
 
-		ret = spi_xfer(spi, 8, NULL, &status, 0);
-		if (ret)
-			return -1;
+		ret = spi_flash_read_common(flash, &cmd, 1, &status, 1);
+		if (ret < 0) {
+			debug("SF: fail to read read status register\n");
+			return ret;
+		}
 
 		if ((status & poll_bit) == 0)
 			break;
 
 	} while (get_timer(timebase) < timeout);
 
-	spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END);
-
 	if ((status & poll_bit) == 0)
 		return 0;