summaryrefslogtreecommitdiff
path: root/drivers/mtd/spi/spansion.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/spi/spansion.c')
-rw-r--r--drivers/mtd/spi/spansion.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c
index b219b3c..28bb51a 100644
--- a/drivers/mtd/spi/spansion.c
+++ b/drivers/mtd/spi/spansion.c
@@ -63,17 +63,6 @@ struct spansion_spi_flash_params {
const char *name;
};
-struct spansion_spi_flash {
- struct spi_flash flash;
- const struct spansion_spi_flash_params *params;
-};
-
-static inline struct spansion_spi_flash *to_spansion_spi_flash(struct spi_flash
- *flash)
-{
- return container_of(flash, struct spansion_spi_flash, flash);
-}
-
static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
{
.idcode1 = SPSN_ID_S25FL008A,
@@ -141,7 +130,7 @@ static int spansion_erase(struct spi_flash *flash, u32 offset, size_t len)
struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
{
const struct spansion_spi_flash_params *params;
- struct spansion_spi_flash *spsn;
+ struct spi_flash *flash;
unsigned int i;
unsigned short jedec, ext_jedec;
@@ -161,22 +150,21 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
return NULL;
}
- spsn = malloc(sizeof(struct spansion_spi_flash));
- if (!spsn) {
+ flash = malloc(sizeof(*flash));
+ if (!flash) {
debug("SF: Failed to allocate memory\n");
return NULL;
}
- spsn->params = params;
- spsn->flash.spi = spi;
- spsn->flash.name = params->name;
+ flash->spi = spi;
+ flash->name = params->name;
- spsn->flash.write = spi_flash_cmd_write_multi;
- spsn->flash.erase = spansion_erase;
- spsn->flash.read = spi_flash_cmd_read_fast;
- spsn->flash.page_size = params->page_size;
- spsn->flash.sector_size = params->page_size * params->pages_per_sector;
- spsn->flash.size = spsn->flash.sector_size * params->nr_sectors;
+ flash->write = spi_flash_cmd_write_multi;
+ flash->erase = spansion_erase;
+ flash->read = spi_flash_cmd_read_fast;
+ flash->page_size = params->page_size;
+ flash->sector_size = params->page_size * params->pages_per_sector;
+ flash->size = flash->sector_size * params->nr_sectors;
- return &spsn->flash;
+ return flash;
}