Include ohci ehci and a better copyright date and description for the cellvision...
[openwrt.git] / target / linux / generic-2.6 / patches / 060-rootfs_split.patch
1 diff -urN linux-2.6.21.1.old/drivers/mtd/Kconfig linux-2.6.21.1.dev/drivers/mtd/Kconfig
2 --- linux-2.6.21.1.old/drivers/mtd/Kconfig 2007-04-27 23:49:26.000000000 +0200
3 +++ linux-2.6.21.1.dev/drivers/mtd/Kconfig 2007-05-26 19:58:42.320520952 +0200
4 @@ -49,6 +49,11 @@
5 devices. Partitioning on NFTL 'devices' is a different - that's the
6 'normal' form of partitioning used on a block device.
7
8 +config MTD_SPLIT_ROOTFS
9 + bool "Automatically split rootfs partition for squashfs"
10 + depends on MTD_PARTITIONS
11 + default y
12 +
13 config MTD_REDBOOT_PARTS
14 tristate "RedBoot partition table parsing"
15 depends on MTD_PARTITIONS
16 diff -urN linux-2.6.21.1.old/drivers/mtd/mtdpart.c linux-2.6.21.1.dev/drivers/mtd/mtdpart.c
17 --- linux-2.6.21.1.old/drivers/mtd/mtdpart.c 2007-04-27 23:49:26.000000000 +0200
18 +++ linux-2.6.21.1.dev/drivers/mtd/mtdpart.c 2007-05-26 19:58:42.331519280 +0200
19 @@ -20,6 +20,8 @@
20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/partitions.h>
22 #include <linux/mtd/compatmac.h>
23 +#include <linux/squashfs_fs.h>
24 +#include <linux/root_dev.h>
25
26 /* Our partition linked list */
27 static LIST_HEAD(mtd_partitions);
28 @@ -308,6 +310,172 @@
29 return 0;
30 }
31
32 +static u_int32_t cur_offset = 0;
33 +static int add_mtd_partition(struct mtd_info *master, const struct mtd_partition *part, int i)
34 +{
35 + struct mtd_part *slave;
36 +
37 + /* allocate the partition structure */
38 + slave = kzalloc (sizeof(*slave), GFP_KERNEL);
39 + if (!slave) {
40 + printk ("memory allocation error while creating partitions for \"%s\"\n",
41 + master->name);
42 + del_mtd_partitions(master);
43 + return -ENOMEM;
44 + }
45 + list_add(&slave->list, &mtd_partitions);
46 +
47 + /* set up the MTD object for this partition */
48 + slave->mtd.type = master->type;
49 + slave->mtd.flags = master->flags & ~part->mask_flags;
50 + slave->mtd.size = part->size;
51 + slave->mtd.writesize = master->writesize;
52 + slave->mtd.oobsize = master->oobsize;
53 + slave->mtd.oobavail = master->oobavail;
54 + slave->mtd.subpage_sft = master->subpage_sft;
55 +
56 + slave->mtd.name = part->name;
57 + slave->mtd.bank_size = master->bank_size;
58 + slave->mtd.owner = master->owner;
59 +
60 + slave->mtd.read = part_read;
61 + slave->mtd.write = part_write;
62 +
63 + if(master->point && master->unpoint){
64 + slave->mtd.point = part_point;
65 + slave->mtd.unpoint = part_unpoint;
66 + }
67 +
68 + if (master->read_oob)
69 + slave->mtd.read_oob = part_read_oob;
70 + if (master->write_oob)
71 + slave->mtd.write_oob = part_write_oob;
72 + if(master->read_user_prot_reg)
73 + slave->mtd.read_user_prot_reg = part_read_user_prot_reg;
74 + if(master->read_fact_prot_reg)
75 + slave->mtd.read_fact_prot_reg = part_read_fact_prot_reg;
76 + if(master->write_user_prot_reg)
77 + slave->mtd.write_user_prot_reg = part_write_user_prot_reg;
78 + if(master->lock_user_prot_reg)
79 + slave->mtd.lock_user_prot_reg = part_lock_user_prot_reg;
80 + if(master->get_user_prot_info)
81 + slave->mtd.get_user_prot_info = part_get_user_prot_info;
82 + if(master->get_fact_prot_info)
83 + slave->mtd.get_fact_prot_info = part_get_fact_prot_info;
84 + if (master->sync)
85 + slave->mtd.sync = part_sync;
86 + if (!i && master->suspend && master->resume) {
87 + slave->mtd.suspend = part_suspend;
88 + slave->mtd.resume = part_resume;
89 + }
90 + if (master->writev)
91 + slave->mtd.writev = part_writev;
92 + if (master->lock)
93 + slave->mtd.lock = part_lock;
94 + if (master->unlock)
95 + slave->mtd.unlock = part_unlock;
96 + if (master->block_isbad)
97 + slave->mtd.block_isbad = part_block_isbad;
98 + if (master->block_markbad)
99 + slave->mtd.block_markbad = part_block_markbad;
100 + slave->mtd.erase = part_erase;
101 + slave->master = master;
102 + slave->offset = part->offset;
103 + slave->index = i;
104 +
105 + if (slave->offset == MTDPART_OFS_APPEND)
106 + slave->offset = cur_offset;
107 + if (slave->offset == MTDPART_OFS_NXTBLK) {
108 + slave->offset = cur_offset;
109 + if ((cur_offset % master->erasesize) != 0) {
110 + /* Round up to next erasesize */
111 + slave->offset = ((cur_offset / master->erasesize) + 1) * master->erasesize;
112 + printk(KERN_NOTICE "Moving partition %d: "
113 + "0x%08x -> 0x%08x\n", i,
114 + cur_offset, slave->offset);
115 + }
116 + }
117 + if (slave->mtd.size == MTDPART_SIZ_FULL)
118 + slave->mtd.size = master->size - slave->offset;
119 + cur_offset = slave->offset + slave->mtd.size;
120 +
121 + printk (KERN_NOTICE "0x%08x-0x%08x : \"%s\"\n", slave->offset,
122 + slave->offset + slave->mtd.size, slave->mtd.name);
123 +
124 + /* let's do some sanity checks */
125 + if (slave->offset >= master->size) {
126 + /* let's register it anyway to preserve ordering */
127 + slave->offset = 0;
128 + slave->mtd.size = 0;
129 + printk ("mtd: partition \"%s\" is out of reach -- disabled\n",
130 + part->name);
131 + }
132 + if (slave->offset + slave->mtd.size > master->size) {
133 + slave->mtd.size = master->size - slave->offset;
134 + printk ("mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#x\n",
135 + part->name, master->name, slave->mtd.size);
136 + }
137 + if (master->numeraseregions>1) {
138 + /* Deal with variable erase size stuff */
139 + int i;
140 + struct mtd_erase_region_info *regions = master->eraseregions;
141 +
142 + /* Find the first erase regions which is part of this partition. */
143 + for (i=0; i < master->numeraseregions && slave->offset >= regions[i].offset; i++)
144 + ;
145 +
146 + for (i--; i < master->numeraseregions && slave->offset + slave->mtd.size > regions[i].offset; i++) {
147 + if (slave->mtd.erasesize < regions[i].erasesize) {
148 + slave->mtd.erasesize = regions[i].erasesize;
149 + }
150 + }
151 + } else {
152 + /* Single erase size */
153 + slave->mtd.erasesize = master->erasesize;
154 + }
155 +
156 + if ((slave->mtd.flags & MTD_WRITEABLE) &&
157 + (slave->offset % slave->mtd.erasesize)) {
158 + /* Doesn't start on a boundary of major erase size */
159 + /* FIXME: Let it be writable if it is on a boundary of _minor_ erase size though */
160 + slave->mtd.flags &= ~MTD_WRITEABLE;
161 + printk ("mtd: partition \"%s\" doesn't start on an erase block boundary -- force read-only\n",
162 + part->name);
163 + }
164 + if ((slave->mtd.flags & MTD_WRITEABLE) &&
165 + (slave->mtd.size % slave->mtd.erasesize)) {
166 + slave->mtd.flags &= ~MTD_WRITEABLE;
167 + printk ("mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n",
168 + part->name);
169 + }
170 +
171 + slave->mtd.ecclayout = master->ecclayout;
172 + if (master->block_isbad) {
173 + uint32_t offs = 0;
174 +
175 + while(offs < slave->mtd.size) {
176 + if (master->block_isbad(master,
177 + offs + slave->offset))
178 + slave->mtd.ecc_stats.badblocks++;
179 + offs += slave->mtd.erasesize;
180 + }
181 + }
182 +
183 + if(part->mtdp)
184 + { /* store the object pointer (caller may or may not register it */
185 + *part->mtdp = &slave->mtd;
186 + slave->registered = 0;
187 + }
188 + else
189 + {
190 + /* register our partition */
191 + add_mtd_device(&slave->mtd);
192 + slave->registered = 1;
193 + }
194 +
195 + return 0;
196 +}
197 +
198 /*
199 * This function, given a master MTD object and a partition table, creates
200 * and registers slave MTD objects which are bound to the master according to
201 @@ -319,170 +487,53 @@
202 const struct mtd_partition *parts,
203 int nbparts)
204 {
205 - struct mtd_part *slave;
206 - u_int32_t cur_offset = 0;
207 - int i;
208 + struct mtd_partition *part;
209 + int i, ret = 0;
210
211 printk (KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
212
213 for (i = 0; i < nbparts; i++) {
214 + part = (struct mtd_partition *) &parts[i];
215 + ret = add_mtd_partition(master, part, i);
216 + if (ret)
217 + return ret;
218 + if (strcmp(part->name, "rootfs") == 0) {
219 +#ifdef CONFIG_MTD_SPLIT_ROOTFS
220 + int len;
221 + char buf[512];
222 + struct squashfs_super_block *sb = (struct squashfs_super_block *) buf;
223 +#define ROOTFS_SPLIT_NAME "rootfs_data"
224 + if ((master->read(master, part->offset, sizeof(struct squashfs_super_block), &len, buf) == 0) &&
225 + (len == sizeof(struct squashfs_super_block)) &&
226 + (*((u32 *) buf) == SQUASHFS_MAGIC) &&
227 + (sb->bytes_used > 0)) {
228 +
229 +
230 + part = kmalloc(sizeof(struct mtd_partition), GFP_KERNEL);
231 + memcpy(part, &parts[i], sizeof(struct mtd_partition));
232 +
233 + part->name = kmalloc(sizeof(ROOTFS_SPLIT_NAME) + 1, GFP_KERNEL);
234 + strcpy(part->name, ROOTFS_SPLIT_NAME);
235 +
236 + len = (u32) sb->bytes_used;
237 + len += (part->offset & 0x000fffff);
238 + len += (master->erasesize - 1);
239 + len &= ~(master->erasesize - 1);
240 + len -= (part->offset & 0x000fffff);
241 + part->offset += len;
242 + part->size -= len;
243 +
244 + if (master->erasesize <= part->size)
245 + ret = add_mtd_partition(master, part, i + 1);
246 + else
247 + kfree(part->name);
248 + if (ret)
249 + return ret;
250
251 - /* allocate the partition structure */
252 - slave = kzalloc (sizeof(*slave), GFP_KERNEL);
253 - if (!slave) {
254 - printk ("memory allocation error while creating partitions for \"%s\"\n",
255 - master->name);
256 - del_mtd_partitions(master);
257 - return -ENOMEM;
258 - }
259 - list_add(&slave->list, &mtd_partitions);
260 -
261 - /* set up the MTD object for this partition */
262 - slave->mtd.type = master->type;
263 - slave->mtd.flags = master->flags & ~parts[i].mask_flags;
264 - slave->mtd.size = parts[i].size;
265 - slave->mtd.writesize = master->writesize;
266 - slave->mtd.oobsize = master->oobsize;
267 - slave->mtd.oobavail = master->oobavail;
268 - slave->mtd.subpage_sft = master->subpage_sft;
269 -
270 - slave->mtd.name = parts[i].name;
271 - slave->mtd.bank_size = master->bank_size;
272 - slave->mtd.owner = master->owner;
273 -
274 - slave->mtd.read = part_read;
275 - slave->mtd.write = part_write;
276 -
277 - if(master->point && master->unpoint){
278 - slave->mtd.point = part_point;
279 - slave->mtd.unpoint = part_unpoint;
280 - }
281 -
282 - if (master->read_oob)
283 - slave->mtd.read_oob = part_read_oob;
284 - if (master->write_oob)
285 - slave->mtd.write_oob = part_write_oob;
286 - if(master->read_user_prot_reg)
287 - slave->mtd.read_user_prot_reg = part_read_user_prot_reg;
288 - if(master->read_fact_prot_reg)
289 - slave->mtd.read_fact_prot_reg = part_read_fact_prot_reg;
290 - if(master->write_user_prot_reg)
291 - slave->mtd.write_user_prot_reg = part_write_user_prot_reg;
292 - if(master->lock_user_prot_reg)
293 - slave->mtd.lock_user_prot_reg = part_lock_user_prot_reg;
294 - if(master->get_user_prot_info)
295 - slave->mtd.get_user_prot_info = part_get_user_prot_info;
296 - if(master->get_fact_prot_info)
297 - slave->mtd.get_fact_prot_info = part_get_fact_prot_info;
298 - if (master->sync)
299 - slave->mtd.sync = part_sync;
300 - if (!i && master->suspend && master->resume) {
301 - slave->mtd.suspend = part_suspend;
302 - slave->mtd.resume = part_resume;
303 - }
304 - if (master->writev)
305 - slave->mtd.writev = part_writev;
306 - if (master->lock)
307 - slave->mtd.lock = part_lock;
308 - if (master->unlock)
309 - slave->mtd.unlock = part_unlock;
310 - if (master->block_isbad)
311 - slave->mtd.block_isbad = part_block_isbad;
312 - if (master->block_markbad)
313 - slave->mtd.block_markbad = part_block_markbad;
314 - slave->mtd.erase = part_erase;
315 - slave->master = master;
316 - slave->offset = parts[i].offset;
317 - slave->index = i;
318 -
319 - if (slave->offset == MTDPART_OFS_APPEND)
320 - slave->offset = cur_offset;
321 - if (slave->offset == MTDPART_OFS_NXTBLK) {
322 - slave->offset = cur_offset;
323 - if ((cur_offset % master->erasesize) != 0) {
324 - /* Round up to next erasesize */
325 - slave->offset = ((cur_offset / master->erasesize) + 1) * master->erasesize;
326 - printk(KERN_NOTICE "Moving partition %d: "
327 - "0x%08x -> 0x%08x\n", i,
328 - cur_offset, slave->offset);
329 + kfree(part);
330 }
331 - }
332 - if (slave->mtd.size == MTDPART_SIZ_FULL)
333 - slave->mtd.size = master->size - slave->offset;
334 - cur_offset = slave->offset + slave->mtd.size;
335 -
336 - printk (KERN_NOTICE "0x%08x-0x%08x : \"%s\"\n", slave->offset,
337 - slave->offset + slave->mtd.size, slave->mtd.name);
338 -
339 - /* let's do some sanity checks */
340 - if (slave->offset >= master->size) {
341 - /* let's register it anyway to preserve ordering */
342 - slave->offset = 0;
343 - slave->mtd.size = 0;
344 - printk ("mtd: partition \"%s\" is out of reach -- disabled\n",
345 - parts[i].name);
346 - }
347 - if (slave->offset + slave->mtd.size > master->size) {
348 - slave->mtd.size = master->size - slave->offset;
349 - printk ("mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#x\n",
350 - parts[i].name, master->name, slave->mtd.size);
351 - }
352 - if (master->numeraseregions>1) {
353 - /* Deal with variable erase size stuff */
354 - int i;
355 - struct mtd_erase_region_info *regions = master->eraseregions;
356 -
357 - /* Find the first erase regions which is part of this partition. */
358 - for (i=0; i < master->numeraseregions && slave->offset >= regions[i].offset; i++)
359 - ;
360 -
361 - for (i--; i < master->numeraseregions && slave->offset + slave->mtd.size > regions[i].offset; i++) {
362 - if (slave->mtd.erasesize < regions[i].erasesize) {
363 - slave->mtd.erasesize = regions[i].erasesize;
364 - }
365 - }
366 - } else {
367 - /* Single erase size */
368 - slave->mtd.erasesize = master->erasesize;
369 - }
370 -
371 - if ((slave->mtd.flags & MTD_WRITEABLE) &&
372 - (slave->offset % slave->mtd.erasesize)) {
373 - /* Doesn't start on a boundary of major erase size */
374 - /* FIXME: Let it be writable if it is on a boundary of _minor_ erase size though */
375 - slave->mtd.flags &= ~MTD_WRITEABLE;
376 - printk ("mtd: partition \"%s\" doesn't start on an erase block boundary -- force read-only\n",
377 - parts[i].name);
378 - }
379 - if ((slave->mtd.flags & MTD_WRITEABLE) &&
380 - (slave->mtd.size % slave->mtd.erasesize)) {
381 - slave->mtd.flags &= ~MTD_WRITEABLE;
382 - printk ("mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n",
383 - parts[i].name);
384 - }
385 -
386 - slave->mtd.ecclayout = master->ecclayout;
387 - if (master->block_isbad) {
388 - uint32_t offs = 0;
389 -
390 - while(offs < slave->mtd.size) {
391 - if (master->block_isbad(master,
392 - offs + slave->offset))
393 - slave->mtd.ecc_stats.badblocks++;
394 - offs += slave->mtd.erasesize;
395 - }
396 - }
397 -
398 - if(parts[i].mtdp)
399 - { /* store the object pointer (caller may or may not register it */
400 - *parts[i].mtdp = &slave->mtd;
401 - slave->registered = 0;
402 - }
403 - else
404 - {
405 - /* register our partition */
406 - add_mtd_device(&slave->mtd);
407 - slave->registered = 1;
408 +#endif /* CONFIG_MTD_SPLIT_ROOTFS */
409 + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, i);
410 }
411 }
412
This page took 0.058986 seconds and 5 git commands to generate.