diff options
Diffstat (limited to 'drivers/mtd/maps/physmap.c')
-rw-r--r-- | drivers/mtd/maps/physmap.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c index 87743661d48e..229718222db7 100644 --- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c | |||
@@ -29,6 +29,7 @@ struct physmap_flash_info { | |||
29 | struct map_info map[MAX_RESOURCES]; | 29 | struct map_info map[MAX_RESOURCES]; |
30 | #ifdef CONFIG_MTD_PARTITIONS | 30 | #ifdef CONFIG_MTD_PARTITIONS |
31 | int nr_parts; | 31 | int nr_parts; |
32 | struct mtd_partition *parts; | ||
32 | #endif | 33 | #endif |
33 | }; | 34 | }; |
34 | 35 | ||
@@ -45,25 +46,29 @@ static int physmap_flash_remove(struct platform_device *dev) | |||
45 | 46 | ||
46 | physmap_data = dev->dev.platform_data; | 47 | physmap_data = dev->dev.platform_data; |
47 | 48 | ||
48 | #ifdef CONFIG_MTD_CONCAT | 49 | if (info->cmtd) { |
49 | if (info->cmtd != info->mtd[0]) { | 50 | #ifdef CONFIG_MTD_PARTITIONS |
51 | if (info->nr_parts || physmap_data->nr_parts) | ||
52 | del_mtd_partitions(info->cmtd); | ||
53 | else | ||
54 | del_mtd_device(info->cmtd); | ||
55 | #else | ||
50 | del_mtd_device(info->cmtd); | 56 | del_mtd_device(info->cmtd); |
51 | mtd_concat_destroy(info->cmtd); | 57 | #endif |
52 | } | 58 | } |
59 | #ifdef CONFIG_MTD_PARTITIONS | ||
60 | if (info->nr_parts) | ||
61 | kfree(info->parts); | ||
53 | #endif | 62 | #endif |
54 | 63 | ||
55 | for (i = 0; i < MAX_RESOURCES; i++) { | 64 | #ifdef CONFIG_MTD_CONCAT |
56 | if (info->mtd[i] != NULL) { | 65 | if (info->cmtd != info->mtd[0]) |
57 | #ifdef CONFIG_MTD_PARTITIONS | 66 | mtd_concat_destroy(info->cmtd); |
58 | if (info->nr_parts || physmap_data->nr_parts) | ||
59 | del_mtd_partitions(info->mtd[i]); | ||
60 | else | ||
61 | del_mtd_device(info->mtd[i]); | ||
62 | #else | ||
63 | del_mtd_device(info->mtd[i]); | ||
64 | #endif | 67 | #endif |
68 | |||
69 | for (i = 0; i < MAX_RESOURCES; i++) { | ||
70 | if (info->mtd[i] != NULL) | ||
65 | map_destroy(info->mtd[i]); | 71 | map_destroy(info->mtd[i]); |
66 | } | ||
67 | } | 72 | } |
68 | return 0; | 73 | return 0; |
69 | } | 74 | } |
@@ -86,9 +91,6 @@ static int physmap_flash_probe(struct platform_device *dev) | |||
86 | int err = 0; | 91 | int err = 0; |
87 | int i; | 92 | int i; |
88 | int devices_found = 0; | 93 | int devices_found = 0; |
89 | #ifdef CONFIG_MTD_PARTITIONS | ||
90 | struct mtd_partition *parts; | ||
91 | #endif | ||
92 | 94 | ||
93 | physmap_data = dev->dev.platform_data; | 95 | physmap_data = dev->dev.platform_data; |
94 | if (physmap_data == NULL) | 96 | if (physmap_data == NULL) |
@@ -167,10 +169,11 @@ static int physmap_flash_probe(struct platform_device *dev) | |||
167 | goto err_out; | 169 | goto err_out; |
168 | 170 | ||
169 | #ifdef CONFIG_MTD_PARTITIONS | 171 | #ifdef CONFIG_MTD_PARTITIONS |
170 | err = parse_mtd_partitions(info->cmtd, part_probe_types, &parts, 0); | 172 | err = parse_mtd_partitions(info->cmtd, part_probe_types, |
173 | &info->parts, 0); | ||
171 | if (err > 0) { | 174 | if (err > 0) { |
172 | add_mtd_partitions(info->cmtd, parts, err); | 175 | add_mtd_partitions(info->cmtd, info->parts, err); |
173 | kfree(parts); | 176 | info->nr_parts = err; |
174 | return 0; | 177 | return 0; |
175 | } | 178 | } |
176 | 179 | ||