sf: add struct spi_flash.sector_size parameter
This patch adds a new member to struct spi_flash (u16 sector_size)
and updates the spi flash drivers to start populating it.
This parameter can be used by spi flash commands that need to round
up units of operation to the flash's sector_size.
Having this number in one place also allows duplicated code to be
further collapsed into one common location (such as erase parameter
and the detected message).
Signed-off-by: Richard Retanubun <RichardRetanubun@RuggedCom.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 5c261f1..ccb7e31 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -131,12 +131,13 @@
}
int spi_flash_cmd_erase(struct spi_flash *flash, u8 erase_cmd,
- u32 erase_size, u32 offset, size_t len)
+ u32 offset, size_t len)
{
- u32 start, end;
+ u32 start, end, erase_size;
int ret;
u8 cmd[4];
+ erase_size = flash->sector_size;
if (offset % erase_size || len % erase_size) {
debug("SF: Erase offset/length not multiple of erase size\n");
return -1;
@@ -296,6 +297,10 @@
goto err_manufacturer_probe;
}
+ printf("SF: Detected %s with page size %u, total ",
+ flash->name, flash->sector_size);
+ print_size(flash->size, "\n");
+
spi_release_bus(spi);
return flash;