From 7ae9b47e4ecf4e9765d8b40a81c00a39d9f828bf Mon Sep 17 00:00:00 2001 From: Jagannadha Sutradharudu Teki Date: Mon, 10 Jun 2013 15:26:03 +0530 Subject: [PATCH] sf: Use spi_xfer in spi_flash_cmd_wait_ready 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 --- drivers/mtd/spi/spi_flash.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index bd679bf5e49..d2611f2484f 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -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; -- 2.47.3