diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2009-03-06 06:01:08 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2009-03-20 14:55:17 -0400 |
commit | 17b536cc43bcf2afcc20b4812f93a895881b5f4f (patch) | |
tree | 4f460cf224c26633159eb32ccb90e6b09a9e0658 | |
parent | bd50a0ffca0bbb9baa60ab1ef2c09cf7561e1223 (diff) |
[MTD] mtdpart: Make all partition parsers return allocated array
Currently redboot and afx parser return allocated mtd_partition array
and cmdlinepart and ar7 return persistent array.
This patch make cmdlinepart and ar7 also return allocated array, so
that all users can free it regardless of parser type.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/ar7part.c | 6 | ||||
-rw-r--r-- | drivers/mtd/cmdlinepart.c | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/drivers/mtd/ar7part.c b/drivers/mtd/ar7part.c index ecf170b55c32..6697a1ec72d0 100644 --- a/drivers/mtd/ar7part.c +++ b/drivers/mtd/ar7part.c | |||
@@ -44,8 +44,6 @@ struct ar7_bin_rec { | |||
44 | unsigned int address; | 44 | unsigned int address; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | static struct mtd_partition ar7_parts[AR7_PARTS]; | ||
48 | |||
49 | static int create_mtd_partitions(struct mtd_info *master, | 47 | static int create_mtd_partitions(struct mtd_info *master, |
50 | struct mtd_partition **pparts, | 48 | struct mtd_partition **pparts, |
51 | unsigned long origin) | 49 | unsigned long origin) |
@@ -57,7 +55,11 @@ static int create_mtd_partitions(struct mtd_info *master, | |||
57 | unsigned int root_offset = ROOT_OFFSET; | 55 | unsigned int root_offset = ROOT_OFFSET; |
58 | 56 | ||
59 | int retries = 10; | 57 | int retries = 10; |
58 | struct mtd_partition *ar7_parts; | ||
60 | 59 | ||
60 | ar7_parts = kzalloc(sizeof(*ar7_parts) * AR7_PARTS, GFP_KERNEL); | ||
61 | if (!ar7_parts) | ||
62 | return -ENOMEM; | ||
61 | ar7_parts[0].name = "loader"; | 63 | ar7_parts[0].name = "loader"; |
62 | ar7_parts[0].offset = 0; | 64 | ar7_parts[0].offset = 0; |
63 | ar7_parts[0].size = master->erasesize; | 65 | ar7_parts[0].size = master->erasesize; |
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c index 50a340388e74..5011fa73f918 100644 --- a/drivers/mtd/cmdlinepart.c +++ b/drivers/mtd/cmdlinepart.c | |||
@@ -335,7 +335,11 @@ static int parse_cmdline_partitions(struct mtd_info *master, | |||
335 | } | 335 | } |
336 | offset += part->parts[i].size; | 336 | offset += part->parts[i].size; |
337 | } | 337 | } |
338 | *pparts = part->parts; | 338 | *pparts = kmemdup(part->parts, |
339 | sizeof(*part->parts) * part->num_parts, | ||
340 | GFP_KERNEL); | ||
341 | if (!*pparts) | ||
342 | return -ENOMEM; | ||
339 | return part->num_parts; | 343 | return part->num_parts; |
340 | } | 344 | } |
341 | } | 345 | } |