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/spansion.c b/drivers/mtd/spi/spansion.c
index d54a5fa..f138d73 100644
--- a/drivers/mtd/spi/spansion.c
+++ b/drivers/mtd/spi/spansion.c
@@ -198,10 +198,7 @@
int spansion_erase(struct spi_flash *flash, u32 offset, size_t len)
{
- struct spansion_spi_flash *spsn = to_spansion_spi_flash(flash);
- return spi_flash_cmd_erase(flash, CMD_S25FLXX_SE,
- spsn->params->page_size * spsn->params->pages_per_sector,
- offset, len);
+ return spi_flash_cmd_erase(flash, CMD_S25FLXX_SE, offset, len);
}
struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
@@ -240,12 +237,8 @@
spsn->flash.write = spansion_write;
spsn->flash.erase = spansion_erase;
spsn->flash.read = spi_flash_cmd_read_fast;
- spsn->flash.size = params->page_size * params->pages_per_sector
- * params->nr_sectors;
-
- printf("SF: Detected %s with page size %u, total ",
- params->name, params->page_size);
- print_size(spsn->flash.size, "\n");
+ spsn->flash.sector_size = params->page_size * params->pages_per_sector;
+ spsn->flash.size = spsn->flash.sector_size * params->nr_sectors;
return &spsn->flash;
}