summaryrefslogtreecommitdiff
path: root/drivers/mtd/spi/winbond.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-06-28 07:38:10 +0000
committerWolfgang Denk <wd@denx.de>2011-07-26 16:29:59 +0200
commitb06afa75faeea2498447c56df1abaa23dbedb689 (patch)
tree4bc3eb8909e65e73cbaf5429866907225c5019ee /drivers/mtd/spi/winbond.c
parentd4aa500913adf074ad85b1b74bf79e9abb104a70 (diff)
sf: kill off now-unused local state
Now that the common spi_flash structure tracks all the info that these drivers need, kill off their local state indirection and use just what the common code provides. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'drivers/mtd/spi/winbond.c')
-rw-r--r--drivers/mtd/spi/winbond.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c
index 3db0cb0224..45bd1461eb 100644
--- a/drivers/mtd/spi/winbond.c
+++ b/drivers/mtd/spi/winbond.c
@@ -34,18 +34,6 @@ struct winbond_spi_flash_params {
const char *name;
};
-/* spi_flash needs to be first so upper layers can free() it */
-struct winbond_spi_flash {
- struct spi_flash flash;
- const struct winbond_spi_flash_params *params;
-};
-
-static inline struct winbond_spi_flash *
-to_winbond_spi_flash(struct spi_flash *flash)
-{
- return container_of(flash, struct winbond_spi_flash, flash);
-}
-
static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
{
.id = 0x3015,
@@ -113,9 +101,9 @@ static int winbond_erase(struct spi_flash *flash, u32 offset, size_t len)
struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)
{
const struct winbond_spi_flash_params *params;
- unsigned page_size;
- struct winbond_spi_flash *stm;
+ struct spi_flash *flash;
unsigned int i;
+ unsigned page_size;
for (i = 0; i < ARRAY_SIZE(winbond_spi_flash_table); i++) {
params = &winbond_spi_flash_table[i];
@@ -129,27 +117,26 @@ struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)
return NULL;
}
- stm = malloc(sizeof(struct winbond_spi_flash));
- if (!stm) {
+ flash = malloc(sizeof(*flash));
+ if (!flash) {
debug("SF: Failed to allocate memory\n");
return NULL;
}
- stm->params = params;
- stm->flash.spi = spi;
- stm->flash.name = params->name;
+ flash->spi = spi;
+ flash->name = params->name;
/* Assuming power-of-two page size initially. */
page_size = 1 << params->l2_page_size;
- stm->flash.write = spi_flash_cmd_write_multi;
- stm->flash.erase = winbond_erase;
- stm->flash.read = spi_flash_cmd_read_fast;
- stm->flash.page_size = page_size;
- stm->flash.sector_size = page_size * stm->params->pages_per_sector;
- stm->flash.size = page_size * params->pages_per_sector
+ flash->write = spi_flash_cmd_write_multi;
+ flash->erase = winbond_erase;
+ flash->read = spi_flash_cmd_read_fast;
+ flash->page_size = page_size;
+ flash->sector_size = page_size * params->pages_per_sector;
+ flash->size = page_size * params->pages_per_sector
* params->sectors_per_block
* params->nr_blocks;
- return &stm->flash;
+ return flash;
}