Skip to content

Commit 05e258c

Browse files
linuswmiquelraynal
authored andcommitted
mtd: parsers: bcm47xxpart: Fix halfblock reads
There is some code in the parser that tries to read 0x8000 bytes into a block to "read in the middle" of the block. Well that only works if the block is also 0x10000 bytes all the time, else we get these parse errors as we reach the end of the flash: spi-nor spi0.0: mx25l1606e (2048 Kbytes) mtd_read error while parsing (offset: 0x200000): -22 mtd_read error while parsing (offset: 0x201000): -22 (...) Fix the code to do what I think was intended. Cc: [email protected] Fixes: f0501e8 ("mtd: bcm47xxpart: alternative MAGIC for board_data partition") Cc: Rafał Miłecki <[email protected]> Cc: Florian Fainelli <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent ce10771 commit 05e258c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/mtd/parsers/bcm47xxpart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ static int bcm47xxpart_parse(struct mtd_info *master,
233233
}
234234

235235
/* Read middle of the block */
236-
err = mtd_read(master, offset + 0x8000, 0x4, &bytes_read,
236+
err = mtd_read(master, offset + (blocksize / 2), 0x4, &bytes_read,
237237
(uint8_t *)buf);
238238
if (err && !mtd_is_bitflip(err)) {
239239
pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
240-
offset + 0x8000, err);
240+
offset + (blocksize / 2), err);
241241
continue;
242242
}
243243

0 commit comments

Comments
 (0)