]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
sf: Use spi_xfer in spi_flash_cmd_wait_ready
authorJagannadha Sutradharudu Teki <jaganna@xilinx.com>
Mon, 10 Jun 2013 09:56:03 +0000 (15:26 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 12 Jun 2013 09:52:09 +0000 (11:52 +0200)
Use spi_xfer instead of spi_flash_read_common() in spi_flash_cmd_wait_ready
to make sure that the read|flag_status poll happen on loop and
SPI_XFER_BEGIN and SPI_XFER_END will done in outof loop.

Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
drivers/mtd/spi/spi_flash.c

index bd679bf5e493504916b503baf26f12cf4728582a..d2611f2484fdb1aeebbacf757353338389958f99 100644 (file)
@@ -237,6 +237,7 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset,
 
 int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
 {
+       struct spi_slave *spi = flash->spi;
        unsigned long timebase;
        int ret;
        u8 status;
@@ -251,22 +252,28 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout)
                cmd = CMD_FLAG_STATUS;
        }
 
+       ret = spi_xfer(spi, 8, &cmd, NULL, SPI_XFER_BEGIN);
+       if (ret) {
+               debug("SF: fail to read %s status register\n",
+                       cmd == CMD_READ_STATUS ? "read" : "flag");
+               return ret;
+       }
+
        timebase = get_timer(0);
        do {
                WATCHDOG_RESET();
 
-               ret = spi_flash_read_common(flash, &cmd, 1, &status, 1);
-               if (ret < 0) {
-                       debug("SF: fail to read %s status register\n",
-                               cmd == CMD_READ_STATUS ? "read" : "flag");
-                       return ret;
-               }
+               ret = spi_xfer(spi, 8, NULL, &status, 0);
+               if (ret)
+                       return -1;
 
                if ((status & poll_bit) == check_status)
                        break;
 
        } while (get_timer(timebase) < timeout);
 
+       spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END);
+
        if ((status & poll_bit) == check_status)
                return 0;