diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2015-04-01 02:23:05 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2015-04-02 07:54:20 -0400 |
commit | 40d12172c8a5c2f3fc39642fc564b053575cd000 (patch) | |
tree | 0f9dfe065a31b8e788118f1733dbfb0ad10d7ea9 /arch/mips/bcm47xx/nvram.c | |
parent | 6ab7c29099390b3d23c97f14498fd26a5ef6b22b (diff) |
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: 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>
Diffstat (limited to 'arch/mips/bcm47xx/nvram.c')
-rw-r--r-- | arch/mips/bcm47xx/nvram.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c index 2ac74825397c..ba632ff08a13 100644 --- a/arch/mips/bcm47xx/nvram.c +++ b/arch/mips/bcm47xx/nvram.c | |||
@@ -139,36 +139,28 @@ static int nvram_init(void) | |||
139 | struct mtd_info *mtd; | 139 | struct mtd_info *mtd; |
140 | struct nvram_header header; | 140 | struct nvram_header header; |
141 | size_t bytes_read; | 141 | size_t bytes_read; |
142 | int err, i; | 142 | int err; |
143 | 143 | ||
144 | mtd = get_mtd_device_nm("nvram"); | 144 | mtd = get_mtd_device_nm("nvram"); |
145 | if (IS_ERR(mtd)) | 145 | if (IS_ERR(mtd)) |
146 | return -ENODEV; | 146 | return -ENODEV; |
147 | 147 | ||
148 | for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) { | 148 | err = mtd_read(mtd, 0, sizeof(header), &bytes_read, (uint8_t *)&header); |
149 | loff_t from = mtd->size - nvram_sizes[i]; | 149 | if (!err && header.magic == NVRAM_MAGIC) { |
150 | 150 | u8 *dst = (uint8_t *)nvram_buf; | |
151 | if (from < 0) | 151 | size_t len = header.len; |
152 | continue; | ||
153 | |||
154 | err = mtd_read(mtd, from, sizeof(header), &bytes_read, | ||
155 | (uint8_t *)&header); | ||
156 | if (!err && header.magic == NVRAM_MAGIC) { | ||
157 | u8 *dst = (uint8_t *)nvram_buf; | ||
158 | size_t len = header.len; | ||
159 | 152 | ||
160 | if (header.len > NVRAM_SPACE) { | 153 | if (header.len > NVRAM_SPACE) { |
161 | pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n", | 154 | pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n", |
162 | header.len, NVRAM_SPACE); | 155 | header.len, NVRAM_SPACE); |
163 | len = NVRAM_SPACE; | 156 | len = NVRAM_SPACE; |
164 | } | 157 | } |
165 | 158 | ||
166 | err = mtd_read(mtd, from, len, &bytes_read, dst); | 159 | err = mtd_read(mtd, 0, len, &bytes_read, dst); |
167 | if (err) | 160 | if (err) |
168 | return err; | 161 | return err; |
169 | 162 | ||
170 | return 0; | 163 | return 0; |
171 | } | ||
172 | } | 164 | } |
173 | #endif | 165 | #endif |
174 | 166 | ||