mtd: mtdpart: Do not fail mtd probe when parsing partitions fails

Due to wrong assumption in ofpart ofpart fails on Exynos on SPI chips
with no partitions because the subnode containing controller data
confuses the ofpart parser.

Thus compiling in ofpart support automatically fails probing any SPI NOR
flash without partitions on Exynos.

Compiling in a partitioning scheme should not cause probe of otherwise
valid device to fail.

Instead, let's do the following:
 * try parsers until one succeeds
 * if no parser succeeds, report the first error we saw
 * even in the failure case, allow MTD to probe, with fallback
   partitions or no partitions at all -- the master device will still be
   registered

Issue report and comments initially by Michal Suchanek.

Reported-by: Michal Suchanek <hramrach@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
This commit is contained in:
Brian Norris
2015-10-11 13:03:47 -07:00
parent 04850c4d86
commit 5a2415b076
2 changed files with 14 additions and 6 deletions

View File

@@ -598,8 +598,10 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
}
/* Didn't come up with either parsed OR fallback partitions */
if (ret < 0) {
pr_info("mtd: failed to find partitions\n");
goto out;
pr_info("mtd: failed to find partitions; one or more parsers reports errors (%d)\n",
ret);
/* Don't abort on errors; we can still use unpartitioned MTD */
ret = 0;
}
ret = mtd_add_device_partitions(mtd, real_parts, ret);