From 2e3c135d24560ec9fc5f6b44ca7f22ad1f7d43e3 Mon Sep 17 00:00:00 2001 From: Jagannadha Sutradharudu Teki Date: Wed, 15 May 2013 23:42:52 +0530 Subject: [PATCH] sf: Use spi_flash_addr() in write call Use the existing spi_flash_addr() for 3-byte addressing cmd filling in write call. Signed-off-by: Jagannadha Sutradharudu Teki --- drivers/mtd/spi/spi_flash.c | 9 +++------ drivers/mtd/spi/spi_flash_internal.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 2eb3e2b8ad8..88c7f1b00dd 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -74,7 +74,7 @@ int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len, int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, size_t len, const void *buf) { - unsigned long page_addr, byte_addr, page_size; + unsigned long byte_addr, page_size; size_t chunk_len, actual; int ret; u8 cmd[4]; @@ -113,17 +113,14 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, return ret; } - page_addr = (offset & SPI_FLASH_16MB_MASK) / page_size; - byte_addr = (offset & SPI_FLASH_16MB_MASK) % page_size; + byte_addr = offset % page_size; chunk_len = min(len - actual, page_size - byte_addr); if (flash->spi->max_write_size) chunk_len = min(chunk_len, flash->spi->max_write_size); - cmd[1] = page_addr >> 8; - cmd[2] = page_addr; - cmd[3] = byte_addr; + spi_flash_addr(offset, cmd); debug("PP: 0x%p => cmd = { 0x%02x 0x%02x%02x%02x } chunk_len = %zu\n", buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len); diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index b669e61a96d..11304e59a77 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -13,7 +13,6 @@ #define SPI_FLASH_SECTOR_ERASE_TIMEOUT (10 * CONFIG_SYS_HZ) #define SPI_FLASH_16MB_BOUN 0x1000000 -#define SPI_FLASH_16MB_MASK 0xFFFFFF #define SPI_FLASH_512MB_MIC 0x4000000 /* Common commands */ -- 2.47.3