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/macronix.c b/drivers/mtd/spi/macronix.c
index 4155d4d..a0512d1 100644
--- a/drivers/mtd/spi/macronix.c
+++ b/drivers/mtd/spi/macronix.c
@@ -177,11 +177,7 @@
int macronix_erase(struct spi_flash *flash, u32 offset, size_t len)
{
- struct macronix_spi_flash *mcx = to_macronix_spi_flash(flash);
- return spi_flash_cmd_erase(flash, CMD_MX25XX_BE,
- mcx->params->page_size * mcx->params->pages_per_sector *
- mcx->params->sectors_per_block,
- offset, len);
+ return spi_flash_cmd_erase(flash, CMD_MX25XX_BE, offset, len);
}
struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
@@ -215,12 +211,9 @@
mcx->flash.write = macronix_write;
mcx->flash.erase = macronix_erase;
mcx->flash.read = spi_flash_cmd_read_fast;
- mcx->flash.size = params->page_size * params->pages_per_sector
- * params->sectors_per_block * params->nr_blocks;
-
- printf("SF: Detected %s with page size %u, total ",
- params->name, params->page_size);
- print_size(mcx->flash.size, "\n");
+ mcx->flash.sector_size = params->page_size * params->pages_per_sector
+ * params->sectors_per_block;
+ mcx->flash.size = mcx->flash.sector_size * params->nr_blocks;
return &mcx->flash;
}