MTD: fix partition scan control logic in physmap_of and fsl_elbc_nand
Subsystems (2)
PATCH 1/1 MTD: fix partition scan control logic in physmap_of and fsl_elbc_nand
The generic rule for partition scan is to try all supported partition types before an usable partition table is found. However the original code returns unsuccessful when there is an error in any of the partition types.
---
I later found that Stefan has proposed a similar patch for physmap_of and Peter proposed another patch to fix cmdlinepart instead. I'd say that even after cmdlinepart patch is applied the scan control logic still needs to be fixed.
drivers/mtd/maps/physmap_of.c | 12 ++---------- drivers/mtd/nand/fsl_elbc_nand.c | 7 +------ 2 files changed, 3 insertions(+), 16 deletions(-)
drivers/mtd/maps/physmap_of.c +2 -10
@@ -225,23 +225,15 @@ static int __devinit of_flash_probe(struct of_device *dev,* 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;#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; - }#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);
drivers/mtd/nand/fsl_elbc_nand.c +1 -6
@@ -1054,16 +1054,11 @@ static int fsl_elbc_chip_probe(struct fsl_elbc_ctrl *ctrl,/* First look for RedBoot table or partitions on the command * line, these take precedence over device tree information */ ret =parse_mtd_partitions (&priv->mtd, part_probe_types, &parts,0 ); -if (ret <0 ) - goto err;#ifdef CONFIG_MTD_OF_PARTS -if (ret ==0 ) { +if (ret <=0 ) ret =of_mtd_parse_partitions (priv->dev, &priv->mtd, node, &parts); -if (ret <0 ) - goto err; - }#endif if (ret >0 )
Signature · 1 line
1.5.4.rc4
Quoted 5 lines · Li Yang
The generic rule for partition scan is to try all supported partition types before an usable partition table is found. However the original code returns unsuccessful when there is an error in any of the partition types.
Quoted 8 lines
Signed-off-by Li Yang <[email protected]>Cc Stefan Roese <[email protected]>Cc Peter Korsgaard <[email protected]>---
I later found that Stefan has proposed a similar patch forphysmap_ofand Peter proposed another patch to fix cmdlinepart instead. I'd say that even after cmdlinepart patch is applied the scan control logic still needs to be fixed.
I'm not convinced. I think the partition code should return an error if it hits a hard error, like a failure to read from the device. And return zero when it doesn't find anything.
Signature · 1 line
dwmw2
RE: [PATCH] MTD: fix partition scan control logic in physmap_ofand fsl_elbc_nand
Quoted 23 lines
-----Original Message-----
From: David Woodhouse [mailto:[email protected]]
Sent: Wednesday, April 23, 2008 2:49 AM
To: Li Yang
Cc: [email protected]; Stefan Roese; [email protected]
Subject: Re: [PATCH] MTD: fix partition scan control logic inphysmap_ofandfsl_elbc_nandQuoted 1 line · Li Yang
The generic rule for partition scan is to try all supported
partition
Quoted 2 lines
types before an usable partition table is found. However the original code returns unsuccessful when there
is an error
Quoted 7 lines
in any of the partition types.
Signed-off-by Li Yang <[email protected]>Cc Stefan Roese <[email protected]>Cc Peter Korsgaard <[email protected]>---
I later found that Stefan has proposed a similar patch for
physmap_of
Quoted 8 lines
Quoted 2 lines
and Peter proposed another patch to fix cmdlinepart instead. I'd say that even after cmdlinepart patch is applied the
scan control
Quoted 1 line
logic still needs to be fixed.
I'm not convinced. I think the partition code should return an error if it hits a hard error, like a failure to read from the device. And return zero when it doesn't find anything.
The error can also be soft error like a typo in the cmdline or device tree. I could be better to try other ways to see if we can find a sane partition table than just to fail.
- Leo
Re: [PATCH] MTD: fix partition scan control logic in physmap_ofand fsl_elbc_nand
Quoted 3 lines · Li Yang
The error can also be soft error like a typo in the cmdline or device tree. I could be better to try other ways to see if we can find a sane partition table than just to fail.
If cmdline partition information exists, typo or not, then obviously there was intent for the cmdline to be used. It's better to let the user know there's a problem than silently fall back to some other, likely wrong partition information.
-Scott