[U-Boot] [PATCH v2 14/16] sf: Use spi_flash_read_common() in write status poll
Jagannadha Sutradharudu Teki
jagannadha.sutradharudu-teki at xilinx.com
Fri May 31 14:52:27 CEST 2013
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 at 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;
+ }
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
More information about the U-Boot
mailing list