]> git.sur5r.net Git - u-boot/commitdiff
sf: kill off now-unused local state
authorMike Frysinger <vapier@gentoo.org>
Tue, 28 Jun 2011 07:38:10 +0000 (07:38 +0000)
committerWolfgang Denk <wd@denx.de>
Tue, 26 Jul 2011 14:29:59 +0000 (16:29 +0200)
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>
drivers/mtd/spi/eon.c
drivers/mtd/spi/macronix.c
drivers/mtd/spi/spansion.c
drivers/mtd/spi/stmicro.c
drivers/mtd/spi/winbond.c

index 036855b197ebbabd52646191b5233cf51e63f230..5937b612c76da42cb2f02ee6d5ad1fcc6e983442 100644 (file)
@@ -34,17 +34,6 @@ struct eon_spi_flash_params {
        const char *name;
 };
 
-/* spi_flash needs to be first so upper layers can free() it */
-struct eon_spi_flash {
-       struct spi_flash flash;
-       const struct eon_spi_flash_params *params;
-};
-
-static inline struct eon_spi_flash *to_eon_spi_flash(struct spi_flash *flash)
-{
-       return container_of(flash, struct eon_spi_flash, flash);
-}
-
 static const struct eon_spi_flash_params eon_spi_flash_table[] = {
        {
                .idcode1 = EON_ID_EN25Q128,
@@ -64,7 +53,7 @@ static int eon_erase(struct spi_flash *flash, u32 offset, size_t len)
 struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode)
 {
        const struct eon_spi_flash_params *params;
-       struct eon_spi_flash *eon;
+       struct spi_flash *flash;
        unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(eon_spi_flash_table); ++i) {
@@ -78,24 +67,23 @@ struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode)
                return NULL;
        }
 
-       eon = malloc(sizeof(*eon));
-       if (!eon) {
+       flash = malloc(sizeof(*flash));
+       if (!flash) {
                debug("SF: Failed to allocate memory\n");
                return NULL;
        }
 
-       eon->params = params;
-       eon->flash.spi = spi;
-       eon->flash.name = params->name;
+       flash->spi = spi;
+       flash->name = params->name;
 
-       eon->flash.write = spi_flash_cmd_write_multi;
-       eon->flash.erase = eon_erase;
-       eon->flash.read = spi_flash_cmd_read_fast;
-       eon->flash.page_size = params->page_size;
-       eon->flash.sector_size = params->page_size * params->pages_per_sector
+       flash->write = spi_flash_cmd_write_multi;
+       flash->erase = eon_erase;
+       flash->read = spi_flash_cmd_read_fast;
+       flash->page_size = params->page_size;
+       flash->sector_size = params->page_size * params->pages_per_sector
            * params->sectors_per_block;
-       eon->flash.size = params->page_size * params->pages_per_sector
+       flash->size = params->page_size * params->pages_per_sector
            * params->nr_sectors;
 
-       return &eon->flash;
+       return flash;
 }
index 0a56420300d48033d1380160e060c3e4062fd8e1..e6895620a351f285cb28bc7b7672ef1cf5281253 100644 (file)
@@ -58,17 +58,6 @@ struct macronix_spi_flash_params {
        const char *name;
 };
 
-struct macronix_spi_flash {
-       struct spi_flash flash;
-       const struct macronix_spi_flash_params *params;
-};
-
-static inline struct macronix_spi_flash *to_macronix_spi_flash(struct spi_flash
-                                                              *flash)
-{
-       return container_of(flash, struct macronix_spi_flash, flash);
-}
-
 static const struct macronix_spi_flash_params macronix_spi_flash_table[] = {
        {
                .idcode = 0x2015,
@@ -120,7 +109,7 @@ static int macronix_erase(struct spi_flash *flash, u32 offset, size_t len)
 struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
 {
        const struct macronix_spi_flash_params *params;
-       struct macronix_spi_flash *mcx;
+       struct spi_flash *flash;
        unsigned int i;
        u16 id = idcode[2] | idcode[1] << 8;
 
@@ -135,23 +124,22 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
                return NULL;
        }
 
-       mcx = malloc(sizeof(*mcx));
-       if (!mcx) {
+       flash = malloc(sizeof(*flash));
+       if (!flash) {
                debug("SF: Failed to allocate memory\n");
                return NULL;
        }
 
-       mcx->params = params;
-       mcx->flash.spi = spi;
-       mcx->flash.name = params->name;
+       flash->spi = spi;
+       flash->name = params->name;
 
-       mcx->flash.write = spi_flash_cmd_write_multi;
-       mcx->flash.erase = macronix_erase;
-       mcx->flash.read = spi_flash_cmd_read_fast;
-       mcx->flash.page_size = params->page_size;
-       mcx->flash.sector_size = params->page_size * params->pages_per_sector
+       flash->write = spi_flash_cmd_write_multi;
+       flash->erase = macronix_erase;
+       flash->read = spi_flash_cmd_read_fast;
+       flash->page_size = params->page_size;
+       flash->sector_size = params->page_size * params->pages_per_sector
                * params->sectors_per_block;
-       mcx->flash.size = mcx->flash.sector_size * params->nr_blocks;
+       flash->size = flash->sector_size * params->nr_blocks;
 
-       return &mcx->flash;
+       return flash;
 }
index b219b3cace3aa357cb70e92b575a26876f25ea59..28bb51a461948bc0c87e8651bad1967b2d4d62e3 100644 (file)
@@ -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;
 }
index 8106e7c9e8eff73024f167c9878f56a8efb3f2ee..9a9d3d401394518e5cc65c89d83c93663729b6dd 100644 (file)
@@ -63,18 +63,6 @@ struct stmicro_spi_flash_params {
        const char *name;
 };
 
-/* spi_flash needs to be first so upper layers can free() it */
-struct stmicro_spi_flash {
-       struct spi_flash flash;
-       const struct stmicro_spi_flash_params *params;
-};
-
-static inline struct stmicro_spi_flash *to_stmicro_spi_flash(struct spi_flash
-                                                            *flash)
-{
-       return container_of(flash, struct stmicro_spi_flash, flash);
-}
-
 static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = {
        {
                .idcode1 = STM_ID_M25P10,
@@ -142,7 +130,7 @@ static int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len)
 struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
 {
        const struct stmicro_spi_flash_params *params;
-       struct stmicro_spi_flash *stm;
+       struct spi_flash *flash;
        unsigned int i;
 
        if (idcode[0] == 0xff) {
@@ -170,22 +158,21 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
                return NULL;
        }
 
-       stm = malloc(sizeof(struct stmicro_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;
 
-       stm->flash.write = spi_flash_cmd_write_multi;
-       stm->flash.erase = stmicro_erase;
-       stm->flash.read = spi_flash_cmd_read_fast;
-       stm->flash.page_size = params->page_size;
-       stm->flash.sector_size = params->page_size * params->pages_per_sector;
-       stm->flash.size = stm->flash.sector_size * params->nr_sectors;
+       flash->write = spi_flash_cmd_write_multi;
+       flash->erase = stmicro_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 &stm->flash;
+       return flash;
 }
index 3db0cb02248ba4293fd08d6b410b74971dbed820..45bd1461eb3a68e4f46d07c8fabf1c2258eb3336 100644 (file)
@@ -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;
 }