From 4e6a515899290635bfd7fe3aef8c4d4d9e88fced Mon Sep 17 00:00:00 2001 From: Richard Retanubun Date: Wed, 16 Feb 2011 16:37:22 -0500 Subject: 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 Signed-off-by: Mike Frysinger --- drivers/mtd/spi/spi_flash.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/mtd/spi/spi_flash.c') diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 5c261f14a6..ccb7e31408 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -131,12 +131,13 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout) } 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 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, 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; -- cgit v1.2.3 From 493c36072160d72d5a8fe5943539da47c0a702a6 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 12 Apr 2011 02:09:28 -0400 Subject: sf: use print_size() for sector_size output Signed-off-by: Mike Frysinger --- drivers/mtd/spi/spi_flash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/mtd/spi/spi_flash.c') diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index ccb7e31408..c75b716fd4 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -297,8 +297,8 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, goto err_manufacturer_probe; } - printf("SF: Detected %s with page size %u, total ", - flash->name, flash->sector_size); + printf("SF: Detected %s with page size ", flash->name); + print_size(flash->sector_size, ", total "); print_size(flash->size, "\n"); spi_release_bus(spi); -- cgit v1.2.3