OpenWrt – Blame information for rev 2
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --- a/drivers/mtd/Kconfig |
2 | +++ b/drivers/mtd/Kconfig |
||
3 | @@ -12,6 +12,23 @@ menuconfig MTD |
||
4 | |||
5 | if MTD |
||
6 | |||
7 | +menu "OpenWrt specific MTD options" |
||
8 | + |
||
9 | +config MTD_ROOTFS_ROOT_DEV |
||
10 | + bool "Automatically set 'rootfs' partition to be root filesystem" |
||
11 | + default y |
||
12 | + |
||
13 | +config MTD_SPLIT_FIRMWARE |
||
14 | + bool "Automatically split firmware partition for kernel+rootfs" |
||
15 | + default y |
||
16 | + |
||
17 | +config MTD_SPLIT_FIRMWARE_NAME |
||
18 | + string "Firmware partition name" |
||
19 | + depends on MTD_SPLIT_FIRMWARE |
||
20 | + default "firmware" |
||
21 | + |
||
22 | +endmenu |
||
23 | + |
||
24 | config MTD_TESTS |
||
25 | tristate "MTD tests support (DANGEROUS)" |
||
26 | depends on m |
||
27 | --- a/drivers/mtd/mtdpart.c |
||
28 | +++ b/drivers/mtd/mtdpart.c |
||
29 | @@ -30,9 +30,11 @@ |
||
30 | #include <linux/mtd/mtd.h> |
||
31 | #include <linux/mtd/partitions.h> |
||
32 | #include <linux/of.h> |
||
33 | +#include <linux/magic.h> |
||
34 | #include <linux/err.h> |
||
35 | |||
36 | #include "mtdcore.h" |
||
37 | +#include "mtdsplit/mtdsplit.h" |
||
38 | |||
39 | /* Our partition linked list */ |
||
40 | static LIST_HEAD(mtd_partitions); |
||
41 | @@ -46,13 +48,14 @@ struct mtd_part { |
||
42 | struct list_head list; |
||
43 | }; |
||
44 | |||
45 | +static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part); |
||
46 | + |
||
47 | /* |
||
48 | * Given a pointer to the MTD object in the mtd_part structure, we can retrieve |
||
49 | * the pointer to that structure with this macro. |
||
50 | */ |
||
51 | #define PART(x) ((struct mtd_part *)(x)) |
||
52 | |||
53 | - |
||
54 | /* |
||
55 | * MTD methods which simply translate the effective address and pass through |
||
56 | * to the _real_ device. |
||
57 | @@ -548,8 +551,10 @@ out_register: |
||
58 | return slave; |
||
59 | } |
||
60 | |||
61 | -int mtd_add_partition(struct mtd_info *master, const char *name, |
||
62 | - long long offset, long long length) |
||
63 | + |
||
64 | +static int |
||
65 | +__mtd_add_partition(struct mtd_info *master, const char *name, |
||
66 | + long long offset, long long length, bool dup_check) |
||
67 | { |
||
68 | struct mtd_partition part; |
||
69 | struct mtd_part *p, *new; |
||
70 | @@ -581,21 +586,24 @@ int mtd_add_partition(struct mtd_info *m |
||
71 | end = offset + length; |
||
72 | |||
73 | mutex_lock(&mtd_partitions_mutex); |
||
74 | - list_for_each_entry(p, &mtd_partitions, list) |
||
75 | - if (p->master == master) { |
||
76 | - if ((start >= p->offset) && |
||
77 | - (start < (p->offset + p->mtd.size))) |
||
78 | - goto err_inv; |
||
79 | - |
||
80 | - if ((end >= p->offset) && |
||
81 | - (end < (p->offset + p->mtd.size))) |
||
82 | - goto err_inv; |
||
83 | - } |
||
84 | + if (dup_check) { |
||
85 | + list_for_each_entry(p, &mtd_partitions, list) |
||
86 | + if (p->master == master) { |
||
87 | + if ((start >= p->offset) && |
||
88 | + (start < (p->offset + p->mtd.size))) |
||
89 | + goto err_inv; |
||
90 | + |
||
91 | + if ((end >= p->offset) && |
||
92 | + (end < (p->offset + p->mtd.size))) |
||
93 | + goto err_inv; |
||
94 | + } |
||
95 | + } |
||
96 | |||
97 | list_add(&new->list, &mtd_partitions); |
||
98 | mutex_unlock(&mtd_partitions_mutex); |
||
99 | |||
100 | add_mtd_device(&new->mtd); |
||
101 | + mtd_partition_split(master, new); |
||
102 | |||
103 | return ret; |
||
104 | err_inv: |
||
105 | @@ -605,6 +613,12 @@ err_inv: |
||
106 | } |
||
107 | EXPORT_SYMBOL_GPL(mtd_add_partition); |
||
108 | |||
109 | +int mtd_add_partition(struct mtd_info *master, const char *name, |
||
110 | + long long offset, long long length) |
||
111 | +{ |
||
112 | + return __mtd_add_partition(master, name, offset, length, true); |
||
113 | +} |
||
114 | + |
||
115 | int mtd_del_partition(struct mtd_info *master, int partno) |
||
116 | { |
||
117 | struct mtd_part *slave, *next; |
||
118 | @@ -628,6 +642,35 @@ int mtd_del_partition(struct mtd_info *m |
||
119 | } |
||
120 | EXPORT_SYMBOL_GPL(mtd_del_partition); |
||
121 | |||
122 | +#ifdef CONFIG_MTD_SPLIT_FIRMWARE_NAME |
||
123 | +#define SPLIT_FIRMWARE_NAME CONFIG_MTD_SPLIT_FIRMWARE_NAME |
||
124 | +#else |
||
125 | +#define SPLIT_FIRMWARE_NAME "unused" |
||
126 | +#endif |
||
127 | + |
||
128 | +static void split_firmware(struct mtd_info *master, struct mtd_part *part) |
||
129 | +{ |
||
130 | +} |
||
131 | + |
||
132 | +void __weak arch_split_mtd_part(struct mtd_info *master, const char *name, |
||
133 | + int offset, int size) |
||
134 | +{ |
||
135 | +} |
||
136 | + |
||
137 | +static void mtd_partition_split(struct mtd_info *master, struct mtd_part *part) |
||
138 | +{ |
||
139 | + static int rootfs_found = 0; |
||
140 | + |
||
141 | + if (rootfs_found) |
||
142 | + return; |
||
143 | + |
||
144 | + if (!strcmp(part->mtd.name, SPLIT_FIRMWARE_NAME) && |
||
145 | + config_enabled(CONFIG_MTD_SPLIT_FIRMWARE)) |
||
146 | + split_firmware(master, part); |
||
147 | + |
||
148 | + arch_split_mtd_part(master, part->mtd.name, part->offset, |
||
149 | + part->mtd.size); |
||
150 | +} |
||
151 | /* |
||
152 | * This function, given a master MTD object and a partition table, creates |
||
153 | * and registers slave MTD objects which are bound to the master according to |
||
154 | @@ -657,6 +700,7 @@ int add_mtd_partitions(struct mtd_info * |
||
155 | mutex_unlock(&mtd_partitions_mutex); |
||
156 | |||
157 | add_mtd_device(&slave->mtd); |
||
158 | + mtd_partition_split(master, slave); |
||
159 | |||
160 | cur_offset = slave->offset + slave->mtd.size; |
||
161 | } |
||
162 | --- a/include/linux/mtd/partitions.h |
||
163 | +++ b/include/linux/mtd/partitions.h |
||
164 | @@ -84,5 +84,7 @@ int mtd_add_partition(struct mtd_info *m |
||
165 | long long offset, long long length); |
||
166 | int mtd_del_partition(struct mtd_info *master, int partno); |
||
167 | uint64_t mtd_get_device_size(const struct mtd_info *mtd); |
||
168 | +extern void __weak arch_split_mtd_part(struct mtd_info *master, |
||
169 | + const char *name, int offset, int size); |
||
170 | |||
171 | #endif |