Since mtd got added, replace flash->size with mtd->size.

Reviewed-by: Heiko Schocher <h...@denx.de>
Signed-off-by: Jagan Teki <jt...@openedev.com>
---
 common/cmd_sf.c          | 16 ++++++++--------
 drivers/mtd/spi/sf_ops.c | 23 +++++++++++++----------
 include/spi_flash.h      |  2 --
 3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index 42862d9..d9f1bd1 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -275,13 +275,13 @@ static int do_spi_flash_read_write(int argc, char * const 
argv[])
                return -1;
 
        if (mtd_arg_off_size(argc - 2, &argv[2], &dev, &offset, &len,
-                            &maxsize, MTD_DEV_TYPE_NOR, flash->size))
+                            &maxsize, MTD_DEV_TYPE_NOR, flash->mtd->size))
                return -1;
 
        /* Consistency checking */
-       if (offset + len > flash->size) {
-               printf("ERROR: attempting %s past flash size (%#x)\n",
-                      argv[0], flash->size);
+       if (offset + len > flash->mtd->size) {
+               printf("ERROR: attempting %s past flash size (0x%llx)\n",
+                      argv[0], flash->mtd->size);
                return 1;
        }
 
@@ -327,7 +327,7 @@ static int do_spi_flash_erase(int argc, char * const argv[])
                return -1;
 
        if (mtd_arg_off(argv[1], &dev, &offset, &len, &maxsize,
-                       MTD_DEV_TYPE_NOR, flash->size))
+                       MTD_DEV_TYPE_NOR, flash->mtd->size))
                return -1;
 
        ret = sf_parse_len_arg(argv[2], &size);
@@ -335,9 +335,9 @@ static int do_spi_flash_erase(int argc, char * const argv[])
                return -1;
 
        /* Consistency checking */
-       if (offset + size > flash->size) {
-               printf("ERROR: attempting %s past flash size (%#x)\n",
-                      argv[0], flash->size);
+       if (offset + size > flash->mtd->size) {
+               printf("ERROR: attempting %s past flash size (0x%llx)\n",
+                      argv[0], flash->mtd->size);
                return 1;
        }
 
diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
index 1356161..5a7f5d5 100644
--- a/drivers/mtd/spi/sf_ops.c
+++ b/drivers/mtd/spi/sf_ops.c
@@ -149,7 +149,7 @@ static int spi_flash_read_bar(struct spi_flash *flash, u8 
idcode0)
        u8 curr_bank = 0;
        int ret;
 
-       if (flash->size <= SPI_FLASH_16MB_BOUN)
+       if (flash->mtd->size <= SPI_FLASH_16MB_BOUN)
                goto bank_end;
 
        switch (idcode0) {
@@ -651,6 +651,7 @@ static int sst_write_bp(struct mtd_info *mtd, loff_t 
offset, size_t len,
 static void stm_get_locked_range(struct spi_flash *flash, u8 sr, loff_t *ofs,
                                 u32 *len)
 {
+       struct mtd_info *mtd = flash->mtd;
        u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
        int shift = ffs(mask) - 1;
        int pow;
@@ -661,8 +662,8 @@ static void stm_get_locked_range(struct spi_flash *flash, 
u8 sr, loff_t *ofs,
                *len = 0;
        } else {
                pow = ((sr & mask) ^ mask) >> shift;
-               *len = flash->size >> pow;
-               *ofs = flash->size - *len;
+               *len = mtd->size >> pow;
+               *ofs = mtd->size - *len;
        }
 }
 
@@ -724,6 +725,7 @@ int stm_is_locked(struct spi_flash *flash, u32 ofs, size_t 
len)
  */
 int stm_lock(struct spi_flash *flash, u32 ofs, size_t len)
 {
+       struct mtd_info *mtd = flash->mtd;
        u8 status_old, status_new;
        u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
        u8 shift = ffs(mask) - 1, pow, val;
@@ -734,12 +736,12 @@ int stm_lock(struct spi_flash *flash, u32 ofs, size_t len)
                return ret;
 
        /* SPI NOR always locks to the end */
-       if (ofs + len != flash->size) {
+       if (ofs + len != mtd->size) {
                /* Does combined region extend to end? */
-               if (!stm_is_locked_sr(flash, ofs + len, flash->size - ofs - len,
+               if (!stm_is_locked_sr(flash, ofs + len, mtd->size - ofs - len,
                                      status_old))
                        return -EINVAL;
-               len = flash->size - ofs;
+               len = mtd->size - ofs;
        }
 
        /*
@@ -751,7 +753,7 @@ int stm_lock(struct spi_flash *flash, u32 ofs, size_t len)
         *
         *   pow = ceil(log2(size / len)) = log2(size) - floor(log2(len))
         */
-       pow = ilog2(flash->size) - ilog2(len);
+       pow = ilog2(mtd->size) - ilog2(len);
        val = mask - (pow << shift);
        if (val & ~mask)
                return -EINVAL;
@@ -778,6 +780,7 @@ int stm_lock(struct spi_flash *flash, u32 ofs, size_t len)
  */
 int stm_unlock(struct spi_flash *flash, u32 ofs, size_t len)
 {
+       struct mtd_info *mtd = flash->mtd;
        uint8_t status_old, status_new;
        u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
        u8 shift = ffs(mask) - 1, pow, val;
@@ -800,8 +803,8 @@ int stm_unlock(struct spi_flash *flash, u32 ofs, size_t len)
         *
         *   pow = floor(log2(size / len)) = log2(size) - ceil(log2(len))
         */
-       pow = ilog2(flash->size) - order_base_2(flash->size - (ofs + len));
-       if (ofs + len == flash->size) {
+       pow = ilog2(mtd->size) - order_base_2(mtd->size - (ofs + len));
+       if (ofs + len == mtd->size) {
                val = 0; /* fully unlocked */
        } else {
                val = mask - (pow << shift);
@@ -908,7 +911,7 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash 
*flash)
                return 0;
        }
 
-       if (flash->size != size) {
+       if (flash->mtd->size != size) {
                debug("%s: Memory map must cover entire device\n", __func__);
                return -1;
        }
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 2e81a14..0fee203 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -44,7 +44,6 @@ struct spi_slave;
  * @dual_flash:                Indicates dual flash memories - dual stacked, 
parallel
  * @shift:             Flash shift useful in dual parallel
  * @flags:             Indication of spi flash flags
- * @size:              Total flash size
  * @page_size:         Write (page) size
  * @sector_size:       Sector size
  * @erase_size:                Erase size
@@ -73,7 +72,6 @@ struct spi_flash {
        u8 shift;
        u16 flags;
 
-       u32 size;
        u32 page_size;
        u32 sector_size;
        u32 erase_size;
-- 
1.9.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to