1 From 40d12172c8a5c2f3fc39642fc564b053575cd000 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Wed, 1 Apr 2015 08:23:05 +0200
4 Subject: [PATCH] MIPS: BCM47XX: Don't try guessing NVRAM size on MTD partition
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 When dealing with whole flash content (bcm47xx_nvram_init_from_mem) we
10 need to find NVRAM start trying various partition sizes (nvram_sizes).
11 This is not needed when using MTD as we have direct partition access.
13 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
14 Cc: linux-mips@linux-mips.org
15 Cc: Hauke Mehrtens <hauke@hauke-m.de>
16 Patchwork: https://patchwork.linux-mips.org/patch/9652/
17 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
19 arch/mips/bcm47xx/nvram.c | 36 ++++++++++++++----------------------
20 1 file changed, 14 insertions(+), 22 deletions(-)
22 --- a/arch/mips/bcm47xx/nvram.c
23 +++ b/arch/mips/bcm47xx/nvram.c
24 @@ -139,36 +139,28 @@ static int nvram_init(void)
26 struct nvram_header header;
31 mtd = get_mtd_device_nm("nvram");
35 - for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
36 - loff_t from = mtd->size - nvram_sizes[i];
40 + err = mtd_read(mtd, 0, sizeof(header), &bytes_read, (uint8_t *)&header);
41 + if (!err && header.magic == NVRAM_MAGIC) {
42 + u8 *dst = (uint8_t *)nvram_buf;
43 + size_t len = header.len;
45 + if (header.len > NVRAM_SPACE) {
46 + pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
47 + header.len, NVRAM_SPACE);
51 - err = mtd_read(mtd, from, sizeof(header), &bytes_read,
52 - (uint8_t *)&header);
53 - if (!err && header.magic == NVRAM_MAGIC) {
54 - u8 *dst = (uint8_t *)nvram_buf;
55 - size_t len = header.len;
57 - if (header.len > NVRAM_SPACE) {
58 - pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
59 - header.len, NVRAM_SPACE);
63 - err = mtd_read(mtd, from, len, &bytes_read, dst);
66 + err = mtd_read(mtd, 0, len, &bytes_read, dst);