diff options
author | Valentine Barshak <vbarshak@ru.mvista.com> | 2007-10-29 16:29:02 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2007-10-30 08:54:39 -0400 |
commit | 4edaf56e0f8a6f71e3361bf74e3dc835811761e6 (patch) | |
tree | a0ba7f93a4d6f787462ba95debe0353b77277151 /drivers/mtd/maps | |
parent | a25b7fee537ab4dbc6eb301bd455ee8d01b707f6 (diff) |
MTD: small physmap_of partition parsing fixes
Use of_get_next_child for proper ref counting as suggested by Stephen Rothwell
and remove add_mtd_partitions from parse_partitions to avoid duplicate
mtd device registration for RedBoot partitions.
Signed-off-by: Valentine Barshak <vbarshak@ru.mvista.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Heckled-for-on-IRC-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/maps')
-rw-r--r-- | drivers/mtd/maps/physmap_of.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c index aeed9ea79714..d4bcd3f8c57c 100644 --- a/drivers/mtd/maps/physmap_of.c +++ b/drivers/mtd/maps/physmap_of.c | |||
@@ -94,14 +94,13 @@ static int __devinit parse_partitions(struct of_flash *info, | |||
94 | * line, these take precedence over device tree information */ | 94 | * line, these take precedence over device tree information */ |
95 | nr_parts = parse_mtd_partitions(info->mtd, part_probe_types, | 95 | nr_parts = parse_mtd_partitions(info->mtd, part_probe_types, |
96 | &info->parts, 0); | 96 | &info->parts, 0); |
97 | if (nr_parts > 0) { | 97 | if (nr_parts > 0) |
98 | add_mtd_partitions(info->mtd, info->parts, nr_parts); | 98 | return nr_parts; |
99 | return 0; | ||
100 | } | ||
101 | 99 | ||
102 | /* First count the subnodes */ | 100 | /* First count the subnodes */ |
103 | nr_parts = 0; | 101 | nr_parts = 0; |
104 | for (pp = dp->child; pp; pp = pp->sibling) | 102 | for (pp = of_get_next_child(dp, NULL); pp; |
103 | pp = of_get_next_child(dp, pp)) | ||
105 | nr_parts++; | 104 | nr_parts++; |
106 | 105 | ||
107 | if (nr_parts == 0) | 106 | if (nr_parts == 0) |
@@ -112,12 +111,14 @@ static int __devinit parse_partitions(struct of_flash *info, | |||
112 | if (!info->parts) | 111 | if (!info->parts) |
113 | return -ENOMEM; | 112 | return -ENOMEM; |
114 | 113 | ||
115 | for (pp = dp->child, i = 0; pp; pp = pp->sibling, i++) { | 114 | for (pp = of_get_next_child(dp, NULL), i = 0; pp; |
115 | pp = of_get_next_child(dp, pp), i++) { | ||
116 | const u32 *reg; | 116 | const u32 *reg; |
117 | int len; | 117 | int len; |
118 | 118 | ||
119 | reg = of_get_property(pp, "reg", &len); | 119 | reg = of_get_property(pp, "reg", &len); |
120 | if (!reg || (len != 2*sizeof(u32))) { | 120 | if (!reg || (len != 2*sizeof(u32))) { |
121 | of_node_put(pp); | ||
121 | dev_err(&dev->dev, "Invalid 'reg' on %s\n", | 122 | dev_err(&dev->dev, "Invalid 'reg' on %s\n", |
122 | dp->full_name); | 123 | dp->full_name); |
123 | kfree(info->parts); | 124 | kfree(info->parts); |