mtd: ofpart: Check availability of reg property instead of name property

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sat Sep 19 17:59:04 EDT 2009


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=ebd5a74db74ee2db833d43ea35108a4be9cab42f
Commit:     ebd5a74db74ee2db833d43ea35108a4be9cab42f
Parent:     9289d4ef065a6c62db6bf13d624307f61e57dbbb
Author:     Benjamin Krill <ben at codiert.org>
AuthorDate: Tue Aug 25 15:52:41 2009 +0200
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Sat Sep 19 14:14:48 2009 -0700

    mtd: ofpart: Check availability of reg property instead of name property
    
    The previous implementation breaks the dts binding "mtd-physmap.txt". This
    implementation fixes the issue by checking the availability of the reg
    property instead of the name property.
    
    Cc: stable at kernel.org
    Signed-off-by: Benjamin Krill <ben at codiert.org>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/ofpart.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index 3e164f0..62d6a78 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -46,21 +46,12 @@ int __devinit of_mtd_parse_partitions(struct device *dev,
 		const u32 *reg;
 		int len;
 
-		/* check if this is a partition node */
-		partname = of_get_property(pp, "name", &len);
-		if (strcmp(partname, "partition") != 0) {
+		reg = of_get_property(pp, "reg", &len);
+		if (!reg) {
 			nr_parts--;
 			continue;
 		}
 
-		reg = of_get_property(pp, "reg", &len);
-		if (!reg || (len != 2 * sizeof(u32))) {
-			of_node_put(pp);
-			dev_err(dev, "Invalid 'reg' on %s\n", node->full_name);
-			kfree(*pparts);
-			*pparts = NULL;
-			return -EINVAL;
-		}
 		(*pparts)[i].offset = reg[0];
 		(*pparts)[i].size = reg[1];
 
@@ -75,6 +66,14 @@ int __devinit of_mtd_parse_partitions(struct device *dev,
 		i++;
 	}
 
+	if (!i) {
+		of_node_put(pp);
+		dev_err(dev, "No valid partition found on %s\n", node->full_name);
+		kfree(*pparts);
+		*pparts = NULL;
+		return -EINVAL;
+	}
+
 	return nr_parts;
 }
 EXPORT_SYMBOL(of_mtd_parse_partitions);



More information about the linux-mtd-cvs mailing list