mtd: Fix physmap_of to not exit upon unsuccessful partition scan
PATCH 1/1 mtd: Fix physmap_of to not exit upon unsuccessful partition scan
The patch 9a310d21196f38f6ad0ad146057548653e495c09 ("[MTD] Factor out OF partition support from the NOR driver.") introduced an problem. Now the physmap_of driver returns with error upon the first unsuccessful partition scan (parse_mtd_partitions()). This is not wanted, since even when the RedBoot/cmdlinepart partition scan is unsuccessful, the other scan's (of_mtd_parse_partitions(), parse_obsolete_partitions()) should be done nevertheless.
This patch fixes this problem.
---
Scott, could you please take a look at this patch and add you ACK if you think it is ok?
Thanks.
drivers/mtd/maps/physmap_of.c | 16 ++++------------ 1 files changed, 4 insertions(+), 12 deletions(-)
drivers/mtd/maps/physmap_of.c +4 -12
@@ -224,24 +224,16 @@ static int __devinit of_flash_probe(struct of_device *dev,/* First look for RedBoot table or partitions on the command * line, these take precedence over device tree information */ err =parse_mtd_partitions (info->mtd, part_probe_types, - &info->parts,0 ); -if (err <0 ) -return err; + &info->parts,0 );#ifdef CONFIG_MTD_OF_PARTS -if (err ==0 ) { +if (err <0 ) err =of_mtd_parse_partitions (&dev->dev, info->mtd, - dp, &info->parts); -if (err <0 ) -return err; - } + dp, &info->parts);#endif -if (err ==0 ) { +if (err <0 ) err =parse_obsolete_partitions (dev, info, dp); -if (err <0 ) -return err; - }if (err >0 )add_mtd_partitions (info->mtd, info->parts, err);
Signature · 1 line
1.5.4.1
Quoted 8 lines · Stefan Roese
The patch
9a310d21196f38f6ad0ad146057548653e495c09("[MTD] Factor out OF partition support from the NOR driver.") introduced an problem. Now thephysmap_ofdriver returns with error upon the first unsuccessful partition scan (parse_mtd_partitions()). This is not wanted, since even when the RedBoot/cmdlinepart partition scan is unsuccessful, the other scan's (of_mtd_parse_partitions(),parse_obsolete_partitions()) should be done nevertheless.
Quoted 7 lines
This patch fixes this problem.
Signed-off-by Stefan Roese <[email protected]>---
Scott, could you please take a look at this patch and add you ACK if you think it is ok?
I was under the impression -- and looking at the code seems to back that up -- that parse_mtd_partitions() returns zero if the scan was unsuccessful due to the lack of a partition table, and negative only if there's a real error.
Under what conditions are you actually seeing this fail?
-Scott
Quoted 17 lines · Scott Wood
Quoted 8 lines · Stefan Roese
The patch
9a310d21196f38f6ad0ad146057548653e495c09("[MTD] Factor out OF partition support from the NOR driver.") introduced an problem. Now thephysmap_ofdriver returns with error upon the first unsuccessful partition scan (parse_mtd_partitions()). This is not wanted, since even when the RedBoot/cmdlinepart partition scan is unsuccessful, the other scan's (of_mtd_parse_partitions(),parse_obsolete_partitions()) should be done nevertheless.Quoted 7 lines
This patch fixes this problem.
Signed-off-by Stefan Roese <[email protected]>---
Scott, could you please take a look at this patch and add you ACK if you think it is ok?
Quoted 6 lines
I was under the impression -- and looking at the code seems to back that up -- that
parse_mtd_partitions()returns zero if the scan was unsuccessful due to the lack of a partition table, and negative only if there's a real error.Under what conditions are you actually seeing this fail?
When CONFIG_MTD_REDBOOT_PARTS is not defined for example it returns with -22 (EINVAL).
Best regards,
Stefan
Quoted 4 lines · Stefan Roese
Quoted 1 line · Scott Wood
Under what conditions are you actually seeing this fail?
When
CONFIG_MTD_REDBOOT_PARTSis not defined for example it returns with -22 (EINVAL).
Ah, I see -- it seems the cmdline partition code behaves differently than the redboot code.
Your patch changes it to treat zero as success, however -- which breaks some other cases. The test should be "err <= 0", which is what parse_mtd_partiitions() itself uses in its loop.
-Scott
Quoted 11 lines · Scott Wood
Quoted 4 lines
Quoted 1 line
Under what conditions are you actually seeing this fail?
When
CONFIG_MTD_REDBOOT_PARTSis not defined for example it returns with -22 (EINVAL).Ah, I see -- it seems the cmdline partition code behaves differently than the redboot code.
Your patch changes it to treat zero as success, however -- which breaks some other cases. The test should be "err <= 0", which is what
parse_mtd_partiitions()itself uses in its loop.
OK, I'll fixup another version of this patch tomorrow.
Thanks.
Best regards,
Stefan
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Stefan" == Stefan Roese <[email protected]> writes:
Quoted 11 lines · Scott Wood
Quoted 11 lines
Quoted 4 lines
Quoted 1 line
Under what conditions are you actually seeing this fail?
When
CONFIG_MTD_REDBOOT_PARTSis not defined for example it returns with -22 (EINVAL).Ah, I see -- it seems the cmdline partition code behaves differently than the redboot code.
Your patch changes it to treat zero as success, however -- which breaks some other cases. The test should be "err <= 0", which is what
parse_mtd_partiitions()itself uses in its loop.
Stefan> OK, I'll fixup another version of this patch tomorrow.
I would prefer to fix up cmdlinepart.c instead, as missing cmdline data isn't really an error.
Quoted 1 line
From
7cc1d55f9704a9df1053aefd21fd5db98ac4c983Mon Sep 17 00:00:00 2001
From: Peter Korsgaard <[email protected]>
Date: Thu, 14 Feb 2008 13:46:13 +0100
Subject: [PATCH] cmdlinepart: Missing partition info is not an error
Return 0 partitions instead of -EINVAL on no mtdpart= argument on kernel cmdline or missing partition info for device.
--- drivers/mtd/cmdlinepart.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/mtd/cmdlinepart.c +1 -4
@@ -308,9 +308,6 @@ static int parse_cmdline_partitions(struct mtd_info *master,struct cmdline_mtd_partition *part;char *mtd_id = master->name; -if (!cmdline) -return -EINVAL ; -/* parse command line */ if (!cmdline_parsed)mtdpart_setup_real (cmdline);
@@ -341,7 +338,7 @@ static int parse_cmdline_partitions(struct mtd_info *master,return part->num_parts; } } -return -EINVAL ; +return 0 ; }
Signature · 5 lines
debian.1.5.3.7.1-dirty -- Bye, Peter Korsgaard