summaryrefslogtreecommitdiff
path: root/drivers/mtd/parsers/ofpart_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/parsers/ofpart_core.c')
-rw-r--r--drivers/mtd/parsers/ofpart_core.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/mtd/parsers/ofpart_core.c b/drivers/mtd/parsers/ofpart_core.c
index abfa68798918..599adb69eba6 100644
--- a/drivers/mtd/parsers/ofpart_core.c
+++ b/drivers/mtd/parsers/ofpart_core.c
@@ -23,13 +23,17 @@ struct fixed_partitions_quirks {
int (*post_parse)(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts);
};
+#ifdef CONFIG_MTD_OF_PARTS_BCM4908
static struct fixed_partitions_quirks bcm4908_partitions_quirks = {
.post_parse = bcm4908_partitions_post_parse,
};
+#endif
+#ifdef CONFIG_MTD_OF_PARTS_LINKSYS_NS
static struct fixed_partitions_quirks linksys_ns_partitions_quirks = {
.post_parse = linksys_ns_partitions_post_parse,
};
+#endif
static const struct of_device_id parse_ofpart_match_table[];
@@ -77,6 +81,7 @@ static int parse_fixed_partitions(struct mtd_info *master,
of_id = of_match_node(parse_ofpart_match_table, ofpart_node);
if (dedicated && !of_id) {
/* The 'partitions' subnode might be used by another parser */
+ of_node_put(ofpart_node);
return 0;
}
@@ -91,12 +96,18 @@ static int parse_fixed_partitions(struct mtd_info *master,
nr_parts++;
}
- if (nr_parts == 0)
+ if (nr_parts == 0) {
+ if (dedicated)
+ of_node_put(ofpart_node);
return 0;
+ }
parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL);
- if (!parts)
+ if (!parts) {
+ if (dedicated)
+ of_node_put(ofpart_node);
return -ENOMEM;
+ }
i = 0;
for_each_child_of_node(ofpart_node, pp) {
@@ -175,6 +186,9 @@ static int parse_fixed_partitions(struct mtd_info *master,
if (quirks && quirks->post_parse)
quirks->post_parse(master, parts, nr_parts);
+ if (dedicated)
+ of_node_put(ofpart_node);
+
*pparts = parts;
return nr_parts;
@@ -183,6 +197,8 @@ ofpart_fail:
master->name, pp, mtd_node);
ret = -EINVAL;
ofpart_none:
+ if (dedicated)
+ of_node_put(ofpart_node);
of_node_put(pp);
kfree(parts);
return ret;
@@ -192,8 +208,12 @@ static const struct of_device_id parse_ofpart_match_table[] = {
/* Generic */
{ .compatible = "fixed-partitions" },
/* Customized */
+#ifdef CONFIG_MTD_OF_PARTS_BCM4908
{ .compatible = "brcm,bcm4908-partitions", .data = &bcm4908_partitions_quirks, },
+#endif
+#ifdef CONFIG_MTD_OF_PARTS_LINKSYS_NS
{ .compatible = "linksys,ns-partitions", .data = &linksys_ns_partitions_quirks, },
+#endif
{},
};
MODULE_DEVICE_TABLE(of, parse_ofpart_match_table);