MIPS: BCM47XX: Don't try guessing NVRAM size on MTD partition
authorRafał Miłecki <zajec5@gmail.com>
Wed, 1 Apr 2015 06:23:05 +0000 (08:23 +0200)
committerRalf Baechle <ralf@linux-mips.org>
Thu, 2 Apr 2015 11:54:20 +0000 (13:54 +0200)
When dealing with whole flash content (bcm47xx_nvram_init_from_mem) we
need to find NVRAM start trying various partition sizes (nvram_sizes).
This is not needed when using MTD as we have direct partition access.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Patchwork: https://patchwork.linux-mips.org/patch/9652/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/bcm47xx/nvram.c

index 2ac74825397c2b9780d4b7a0e369f52adad2239a..ba632ff08a13c58838d734a4f5aadce860dffe3c 100644 (file)
@@ -139,36 +139,28 @@ static int nvram_init(void)
        struct mtd_info *mtd;
        struct nvram_header header;
        size_t bytes_read;
-       int err, i;
+       int err;
 
        mtd = get_mtd_device_nm("nvram");
        if (IS_ERR(mtd))
                return -ENODEV;
 
-       for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
-               loff_t from = mtd->size - nvram_sizes[i];
-
-               if (from < 0)
-                       continue;
-
-               err = mtd_read(mtd, from, sizeof(header), &bytes_read,
-                              (uint8_t *)&header);
-               if (!err && header.magic == NVRAM_MAGIC) {
-                       u8 *dst = (uint8_t *)nvram_buf;
-                       size_t len = header.len;
+       err = mtd_read(mtd, 0, sizeof(header), &bytes_read, (uint8_t *)&header);
+       if (!err && header.magic == NVRAM_MAGIC) {
+               u8 *dst = (uint8_t *)nvram_buf;
+               size_t len = header.len;
 
-                       if (header.len > NVRAM_SPACE) {
-                               pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
-                                      header.len, NVRAM_SPACE);
-                               len = NVRAM_SPACE;
-                       }
+               if (header.len > NVRAM_SPACE) {
+                       pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
+                               header.len, NVRAM_SPACE);
+                       len = NVRAM_SPACE;
+               }
 
-                       err = mtd_read(mtd, from, len, &bytes_read, dst);
-                       if (err)
-                               return err;
+               err = mtd_read(mtd, 0, len, &bytes_read, dst);
+               if (err)
+                       return err;
 
-                       return 0;
-               }
+               return 0;
        }
 #endif