summaryrefslogtreecommitdiff
path: root/src/drivers/spi/spansion.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/spi/spansion.c')
-rw-r--r--src/drivers/spi/spansion.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/src/drivers/spi/spansion.c b/src/drivers/spi/spansion.c
index 139e8239a0..8f9e96687d 100644
--- a/src/drivers/spi/spansion.c
+++ b/src/drivers/spi/spansion.c
@@ -64,17 +64,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(const struct spi_flash *flash)
-{
- return container_of(flash, struct spansion_spi_flash, flash);
-}
-
/*
* returns non-zero if the given idcode matches the ID of the chip. this is for
* chips which use 2nd, 3rd, 4th, and 5th byte.
@@ -204,7 +193,6 @@ static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
static int spansion_write(const struct spi_flash *flash, u32 offset, size_t len,
const void *buf)
{
- struct spansion_spi_flash *spsn = to_spansion_spi_flash(flash);
unsigned long byte_addr;
unsigned long page_size;
size_t chunk_len;
@@ -212,7 +200,7 @@ static int spansion_write(const struct spi_flash *flash, u32 offset, size_t len,
int ret = 0;
u8 cmd[4];
- page_size = spsn->params->page_size;
+ page_size = flash->page_size;
for (actual = 0; actual < len; actual += chunk_len) {
byte_addr = offset % page_size;
@@ -258,12 +246,11 @@ static int spansion_write(const struct spi_flash *flash, u32 offset, size_t len,
return ret;
}
-static struct spansion_spi_flash spsn_flash;
+static struct spi_flash flash;
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;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(spansion_spi_flash_table); i++) {
@@ -279,20 +266,18 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
return NULL;
}
- spsn = &spsn_flash;
-
- spsn->params = params;
- memcpy(&spsn->flash.spi, spi, sizeof(*spi));
- spsn->flash.name = params->name;
+ memcpy(&flash.spi, spi, sizeof(*spi));
+ flash.name = params->name;
+ flash.page_size = params->page_size;
+ flash.sector_size = params->page_size * params->pages_per_sector;
+ flash.size = flash.sector_size * params->nr_sectors;
+ flash.erase_cmd = CMD_S25FLXX_SE;
+ flash.status_cmd = CMD_S25FLXX_RDSR;
- spsn->flash.internal_write = spansion_write;
- spsn->flash.internal_erase = spi_flash_cmd_erase;
- spsn->flash.internal_read = spi_flash_cmd_read_slow;
- spsn->flash.internal_status = spi_flash_cmd_status;
- spsn->flash.sector_size = params->page_size * params->pages_per_sector;
- spsn->flash.size = spsn->flash.sector_size * params->nr_sectors;
- spsn->flash.erase_cmd = CMD_S25FLXX_SE;
- spsn->flash.status_cmd = CMD_S25FLXX_RDSR;
+ flash.internal_write = spansion_write;
+ flash.internal_erase = spi_flash_cmd_erase;
+ flash.internal_read = spi_flash_cmd_read_slow;
+ flash.internal_status = spi_flash_cmd_status;
- return &spsn->flash;
+ return &flash;
}