summaryrefslogtreecommitdiff
path: root/drivers/mtd/spi/macronix.c
diff options
context:
space:
mode:
authorRichard Retanubun <RichardRetanubun@ruggedcom.com>2011-02-16 21:37:22 (GMT)
committerMike Frysinger <vapier@gentoo.org>2011-04-12 06:15:37 (GMT)
commit4e6a515899290635bfd7fe3aef8c4d4d9e88fced (patch)
treee4e38baaa882e2dab02c7a1ab83a0912029d605b /drivers/mtd/spi/macronix.c
parentcdb6a00fb8f96b9259ed7d77a1eacbfa3777ddac (diff)
downloadu-boot-4e6a515899290635bfd7fe3aef8c4d4d9e88fced.tar.xz
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>
Diffstat (limited to 'drivers/mtd/spi/macronix.c')
-rw-r--r--drivers/mtd/spi/macronix.c15
1 files changed, 4 insertions, 11 deletions
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 @@ static int macronix_write(struct spi_flash *flash,
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 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
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;
}