Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40d12172 authored by Rafał Miłecki's avatar Rafał Miłecki Committed by Ralf Baechle
Browse files

MIPS: BCM47XX: Don't try guessing NVRAM size on MTD partition



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: default avatarRafał 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: default avatarRalf Baechle <ralf@linux-mips.org>
parent 6ab7c290
Loading
Loading
Loading
Loading
+14 −22
Original line number Original line Diff line number Diff line
@@ -139,20 +139,13 @@ static int nvram_init(void)
	struct mtd_info *mtd;
	struct mtd_info *mtd;
	struct nvram_header header;
	struct nvram_header header;
	size_t bytes_read;
	size_t bytes_read;
	int err, i;
	int err;


	mtd = get_mtd_device_nm("nvram");
	mtd = get_mtd_device_nm("nvram");
	if (IS_ERR(mtd))
	if (IS_ERR(mtd))
		return -ENODEV;
		return -ENODEV;


	for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
	err = mtd_read(mtd, 0, sizeof(header), &bytes_read, (uint8_t *)&header);
		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) {
	if (!err && header.magic == NVRAM_MAGIC) {
		u8 *dst = (uint8_t *)nvram_buf;
		u8 *dst = (uint8_t *)nvram_buf;
		size_t len = header.len;
		size_t len = header.len;
@@ -163,13 +156,12 @@ static int nvram_init(void)
			len = NVRAM_SPACE;
			len = NVRAM_SPACE;
		}
		}


			err = mtd_read(mtd, from, len, &bytes_read, dst);
		err = mtd_read(mtd, 0, len, &bytes_read, dst);
		if (err)
		if (err)
			return err;
			return err;


		return 0;
		return 0;
	}
	}
	}
#endif
#endif


	return -ENXIO;
	return -ENXIO;