mtd: Make UBI detection more robust
When we want to detect if a mtd device contains an UBI image then
testing the first block is not enough since it can always happen that
UBI has just erased the block before the power failed during last boot.
Since UBI only ever erases one block at a time and directly writes the
ec header to it afterwards, it shouldn't be necessary to scan the whole
device for UBI data. Scan the first 64 blocks. The first non-empty block
then must contain UBI data, if instead we find foreign data we assume
that no UBI is on that mtd device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
1 parent 6f58e5c commit 0d68468c9613d0307f1d05f4dce6e583edd3cf07
@Sascha Hauer Sascha Hauer authored on 18 Oct 2016
Showing 1 changed file
View
drivers/mtd/core.c