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 diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
23 index 2ac7482..ba632ff 100644
24 --- a/arch/mips/bcm47xx/nvram.c
25 +++ b/arch/mips/bcm47xx/nvram.c
26 @@ -139,36 +139,28 @@ static int nvram_init(void)
28 struct nvram_header header;
33 mtd = get_mtd_device_nm("nvram");
37 - for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
38 - loff_t from = mtd->size - nvram_sizes[i];
43 - err = mtd_read(mtd, from, sizeof(header), &bytes_read,
44 - (uint8_t *)&header);
45 - if (!err && header.magic == NVRAM_MAGIC) {
46 - u8 *dst = (uint8_t *)nvram_buf;
47 - size_t len = header.len;
48 + err = mtd_read(mtd, 0, sizeof(header), &bytes_read, (uint8_t *)&header);
49 + if (!err && header.magic == NVRAM_MAGIC) {
50 + u8 *dst = (uint8_t *)nvram_buf;
51 + size_t len = header.len;
53 - if (header.len > NVRAM_SPACE) {
54 - pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
55 - header.len, NVRAM_SPACE);
58 + if (header.len > NVRAM_SPACE) {
59 + pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
60 + header.len, NVRAM_SPACE);
64 - err = mtd_read(mtd, from, len, &bytes_read, dst);
67 + err = mtd_read(mtd, 0, len, &bytes_read, dst);