OpenWrt – Diff between revs 2 and 3

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 2 Rev 3
Line 7... Line 7...
7 include/linux/mtd/partitions.h | 11 ++++++++ 7 include/linux/mtd/partitions.h | 11 ++++++++
8 2 files changed, 67 insertions(+) 8 2 files changed, 67 insertions(+)
Line 9... Line 9...
9   9  
10 --- a/drivers/mtd/mtdpart.c 10 --- a/drivers/mtd/mtdpart.c
11 +++ b/drivers/mtd/mtdpart.c -  
12 @@ -56,6 +56,10 @@ struct mtd_part { -  
13 }; -  
14 -  
15 static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part); -  
16 +static int parse_mtd_partitions_by_type(struct mtd_info *master, -  
17 + enum mtd_parser_type type, -  
18 + const struct mtd_partition **pparts, -  
19 + struct mtd_part_parser_data *data); -  
20 -  
21 /* -  
22 * Given a pointer to the MTD object in the mtd_part structure, we can retrieve -  
23 @@ -751,6 +755,36 @@ int mtd_del_partition(struct mtd_info *m -  
24 } -  
25 EXPORT_SYMBOL_GPL(mtd_del_partition); -  
26 -  
27 +static int -  
28 +run_parsers_by_type(struct mtd_part *slave, enum mtd_parser_type type) -  
29 +{ -  
30 + struct mtd_partition *parts; -  
31 + int nr_parts; -  
32 + int i; -  
33 + -  
34 + nr_parts = parse_mtd_partitions_by_type(&slave->mtd, type, (const struct mtd_partition **)&parts, -  
35 + NULL); -  
36 + if (nr_parts <= 0) -  
37 + return nr_parts; -  
38 + -  
39 + if (WARN_ON(!parts)) -  
40 + return 0; -  
41 + -  
42 + for (i = 0; i < nr_parts; i++) { -  
43 + /* adjust partition offsets */ -  
44 + parts[i].offset += slave->offset; -  
45 + -  
46 + mtd_add_partition(slave->parent, -  
47 + parts[i].name, -  
48 + parts[i].offset, -  
49 + parts[i].size); -  
50 + } -  
51 + -  
52 + kfree(parts); -  
53 + -  
54 + return nr_parts; -  
55 +} -  
56 + -  
57 #ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME -  
58 #define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME -  
59 #else 11 +++ b/drivers/mtd/mtdpart.c
60 @@ -1122,6 +1156,61 @@ void mtd_part_parser_cleanup(struct mtd_ 12 @@ -1113,6 +1113,62 @@ void mtd_part_parser_cleanup(struct mtd_
61 } 13 }
Line 62... Line 14...
62 } 14 }
63 15
Line 83... Line 35...
83 + spin_unlock(&part_parser_lock); 35 + spin_unlock(&part_parser_lock);
84 + 36 +
85 + return ret; 37 + return ret;
86 +} 38 +}
87 + 39 +
88 +static int parse_mtd_partitions_by_type(struct mtd_info *master, 40 +int parse_mtd_partitions_by_type(struct mtd_info *master,
89 + enum mtd_parser_type type, 41 + enum mtd_parser_type type,
90 + const struct mtd_partition **pparts, 42 + const struct mtd_partition **pparts,
91 + struct mtd_part_parser_data *data) 43 + struct mtd_part_parser_data *data)
92 +{ 44 +{
93 + struct mtd_part_parser *prev = NULL; 45 + struct mtd_part_parser *prev = NULL;
94 + int ret = 0; 46 + int ret = 0;
95 + 47 +
96 + while (1) { 48 + while (1) {
Line 113... Line 65...
113 + prev = parser; 65 + prev = parser;
114 + } 66 + }
115 + 67 +
116 + return ret; 68 + return ret;
117 +} 69 +}
-   70 +EXPORT_SYMBOL_GPL(parse_mtd_partitions_by_type);
118 + 71 +
119 int mtd_is_partition(const struct mtd_info *mtd) 72 int mtd_is_partition(const struct mtd_info *mtd)
120 { 73 {
121 struct mtd_part *part; 74 struct mtd_part *part;
122 --- a/include/linux/mtd/partitions.h 75 --- a/include/linux/mtd/partitions.h
123 +++ b/include/linux/mtd/partitions.h 76 +++ b/include/linux/mtd/partitions.h
124 @@ -73,6 +73,10 @@ struct mtd_part_parser_data { 77 @@ -68,11 +68,14 @@ struct mtd_part_parser_data {
-   78 unsigned long origin;
-   79 };
-   80
-   81 -
-   82 /*
125 * Functions dealing with the various ways of partitioning the space 83 * Functions dealing with the various ways of partitioning the space
126 */ 84 */
Line 127... Line 85...
127 85
128 +enum mtd_parser_type { 86 +enum mtd_parser_type {
129 + MTD_PARSER_TYPE_DEVICE = 0, 87 + MTD_PARSER_TYPE_DEVICE = 0,
130 +}; 88 +};
131 + 89 +
132 struct mtd_part_parser { 90 struct mtd_part_parser {
133 struct list_head list; 91 struct list_head list;
134 struct module *owner; 92 struct module *owner;
135 @@ -81,6 +85,7 @@ struct mtd_part_parser { 93 @@ -81,6 +84,7 @@ struct mtd_part_parser {
136 int (*parse_fn)(struct mtd_info *, const struct mtd_partition **, 94 int (*parse_fn)(struct mtd_info *, const struct mtd_partition **,
137 struct mtd_part_parser_data *); 95 struct mtd_part_parser_data *);
138 void (*cleanup)(const struct mtd_partition *pparts, int nr_parts); 96 void (*cleanup)(const struct mtd_partition *pparts, int nr_parts);
139 + enum mtd_parser_type type; 97 + enum mtd_parser_type type;
Line 140... Line 98...
140 }; 98 };
-   99
-   100 /* Container for passing around a set of parsed partitions */
-   101 @@ -113,4 +117,9 @@ uint64_t mtd_get_device_size(const struc
-   102 extern void __weak arch_split_mtd_part(struct mtd_info *master,
-   103 const char *name, int offset, int size);
-   104
-   105 +int parse_mtd_partitions_by_type(struct mtd_info *master,
-   106 + enum mtd_parser_type type,
-   107 + const struct mtd_partition **pparts,
-   108 + struct mtd_part_parser_data *data);