diff options
author | Brian Norris <computersforpeace@gmail.com> | 2015-10-11 22:03:47 +0200 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2015-10-27 02:43:48 +0100 |
commit | 5a2415b0769233194f20d3906c3ffc6a2033317c (patch) | |
tree | 355fb4bd34fa3b04832e80c7b7f3250d4f65dac5 /drivers/mtd | |
parent | mtd: fsl-quadspi: fix macro collision problems with READ/WRITE (diff) | |
download | linux-5a2415b0769233194f20d3906c3ffc6a2033317c.tar.xz linux-5a2415b0769233194f20d3906c3ffc6a2033317c.zip |
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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/mtdcore.c | 6 | ||||
-rw-r--r-- | drivers/mtd/mtdpart.c | 14 |
2 files changed, 14 insertions, 6 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 41dc501cb49a..b1eea48c501d 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -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); diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index f5279ea6dc87..f8ba153f63bf 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -755,12 +755,12 @@ int parse_mtd_partitions(struct mtd_info *master, const char *const *types, struct mtd_part_parser_data *data) { struct mtd_part_parser *parser; - int ret = 0; + int ret, err = 0; if (!types) types = default_mtd_part_types; - for ( ; ret <= 0 && *types; types++) { + for ( ; *types; types++) { pr_debug("%s: parsing partitions %s\n", master->name, *types); parser = get_partition_parser(*types); if (!parser && !request_module("%s", *types)) @@ -776,10 +776,16 @@ int parse_mtd_partitions(struct mtd_info *master, const char *const *types, if (ret > 0) { printk(KERN_NOTICE "%d %s partitions found on MTD device %s\n", ret, parser->name, master->name); - break; + return ret; } + /* + * Stash the first error we see; only report it if no parser + * succeeds + */ + if (ret < 0 && !err) + err = ret; } - return ret; + return err; } int mtd_is_partition(const struct mtd_info *mtd) |