[target/xburst] remove set but unused variable which leads into compiling errors...
[openwrt.git] / target / linux / brcm47xx / patches-3.2 / 025-mtd-bcm47xx-add-bcm47xx-part-parser.patch
1 From d50d2d8e3ab5446f791deff0cb78820989ed93e7 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sun, 17 Jul 2011 14:54:11 +0200
4 Subject: [PATCH 06/19] mtd: bcm47xx: add bcm47xx part parser
5
6
7 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
8 ---
9 drivers/mtd/Kconfig | 7 +
10 drivers/mtd/Makefile | 1 +
11 drivers/mtd/bcm47xxpart.c | 542 +++++++++++++++++++++++++++++++++++++++++++++
12 3 files changed, 550 insertions(+), 0 deletions(-)
13 create mode 100644 drivers/mtd/bcm47xxpart.c
14
15 --- a/drivers/mtd/Kconfig
16 +++ b/drivers/mtd/Kconfig
17 @@ -164,6 +164,13 @@ config MTD_MYLOADER_PARTS
18 You will still need the parsing functions to be called by the driver
19 for your particular device. It won't happen automatically.
20
21 +config MTD_BCM47XX_PARTS
22 + tristate "BCM47XX partitioning support"
23 + default y
24 + depends on BCM47XX
25 + ---help---
26 + bcm47XX partitioning support
27 +
28 comment "User Modules And Translation Layers"
29
30 config MTD_CHAR
31 --- a/drivers/mtd/Makefile
32 +++ b/drivers/mtd/Makefile
33 @@ -12,6 +12,7 @@ obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdli
34 obj-$(CONFIG_MTD_AFS_PARTS) += afs.o
35 obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o
36 obj-$(CONFIG_MTD_MYLOADER_PARTS) += myloader.o
37 +obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o
38
39 # 'Users' - code which presents functionality to userspace.
40 obj-$(CONFIG_MTD_CHAR) += mtdchar.o
41 --- /dev/null
42 +++ b/drivers/mtd/bcm47xxpart.c
43 @@ -0,0 +1,542 @@
44 +/*
45 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
46 + * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
47 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
48 + *
49 + * original functions for finding root filesystem from Mike Baker
50 + *
51 + * This program is free software; you can redistribute it and/or modify it
52 + * under the terms of the GNU General Public License as published by the
53 + * Free Software Foundation; either version 2 of the License, or (at your
54 + * option) any later version.
55 + *
56 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
57 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
58 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
59 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
60 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
62 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
63 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
64 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
65 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 + *
67 + * You should have received a copy of the GNU General Public License along
68 + * with this program; if not, write to the Free Software Foundation, Inc.,
69 + * 675 Mass Ave, Cambridge, MA 02139, USA.
70 + *
71 + * Copyright 2001-2003, Broadcom Corporation
72 + * All Rights Reserved.
73 + *
74 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
75 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
76 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
77 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
78 + *
79 + * Flash mapping for BCM947XX boards
80 + */
81 +
82 +#define pr_fmt(fmt) "bcm47xx_part: " fmt
83 +#include <linux/init.h>
84 +#include <linux/module.h>
85 +#include <linux/types.h>
86 +#include <linux/kernel.h>
87 +#include <linux/sched.h>
88 +#include <linux/wait.h>
89 +#include <linux/mtd/mtd.h>
90 +#include <linux/mtd/partitions.h>
91 +#include <linux/crc32.h>
92 +#include <linux/io.h>
93 +#include <asm/mach-bcm47xx/nvram.h>
94 +#include <asm/mach-bcm47xx/bcm47xx.h>
95 +#include <asm/fw/cfe/cfe_api.h>
96 +
97 +
98 +#define TRX_MAGIC 0x30524448 /* "HDR0" */
99 +#define TRX_VERSION 1
100 +#define TRX_MAX_LEN 0x3A0000
101 +#define TRX_NO_HEADER 1 /* Do not write TRX header */
102 +#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */
103 +#define TRX_MAX_OFFSET 3
104 +
105 +struct trx_header {
106 + u32 magic; /* "HDR0" */
107 + u32 len; /* Length of file including header */
108 + u32 crc32; /* 32-bit CRC from flag_version to end of file */
109 + u32 flag_version; /* 0:15 flags, 16:31 version */
110 + u32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
111 +};
112 +
113 +/* for Edimax Print servers which use an additional header
114 + * then the firmware on flash looks like :
115 + * EDIMAX HEADER | TRX HEADER
116 + * As this header is 12 bytes long we have to handle it
117 + * and skip it to find the TRX header
118 + */
119 +#define EDIMAX_PS_HEADER_MAGIC 0x36315350 /* "PS16" */
120 +#define EDIMAX_PS_HEADER_LEN 0xc /* 12 bytes long for edimax header */
121 +
122 +#define NVRAM_SPACE 0x8000
123 +
124 +#define ROUTER_NETGEAR_WGR614L 1
125 +#define ROUTER_NETGEAR_WNR834B 2
126 +#define ROUTER_NETGEAR_WNDR3300 3
127 +#define ROUTER_NETGEAR_WNR3500L 4
128 +#define ROUTER_SIMPLETECH_SIMPLESHARE 5
129 +#define ROUTER_NETGEAR_WNDR3400 6
130 +
131 +static int
132 +find_cfe_size(struct mtd_info *mtd)
133 +{
134 + struct trx_header *trx;
135 + unsigned char buf[512];
136 + int off;
137 + size_t len;
138 + int blocksize;
139 +
140 + trx = (struct trx_header *) buf;
141 +
142 + blocksize = mtd->erasesize;
143 + if (blocksize < 0x10000)
144 + blocksize = 0x10000;
145 +
146 + for (off = (128*1024); off < mtd->size; off += blocksize) {
147 + memset(buf, 0xe5, sizeof(buf));
148 +
149 + /*
150 + * Read into buffer
151 + */
152 + if (mtd->read(mtd, off, sizeof(buf), &len, buf) ||
153 + len != sizeof(buf))
154 + continue;
155 +
156 + if (le32_to_cpu(trx->magic) == EDIMAX_PS_HEADER_MAGIC) {
157 + if (mtd->read(mtd, off + EDIMAX_PS_HEADER_LEN,
158 + sizeof(buf), &len, buf) || len != sizeof(buf)) {
159 + continue;
160 + } else {
161 + pr_notice("Found edimax header\n");
162 + }
163 + }
164 +
165 + /* found a TRX header */
166 + if (le32_to_cpu(trx->magic) == TRX_MAGIC)
167 + goto found;
168 + }
169 +
170 + pr_notice("%s: Couldn't find bootloader size\n", mtd->name);
171 + return -1;
172 +
173 + found:
174 + pr_notice("bootloader size: %d\n", off);
175 + return off;
176 +
177 +}
178 +
179 +/*
180 + * Copied from mtdblock.c
181 + *
182 + * Cache stuff...
183 + *
184 + * Since typical flash erasable sectors are much larger than what Linux's
185 + * buffer cache can handle, we must implement read-modify-write on flash
186 + * sectors for each block write requests. To avoid over-erasing flash sectors
187 + * and to speed things up, we locally cache a whole flash sector while it is
188 + * being written to until a different sector is required.
189 + */
190 +
191 +static void erase_callback(struct erase_info *done)
192 +{
193 + wait_queue_head_t *wait_q = (wait_queue_head_t *)done->priv;
194 + wake_up(wait_q);
195 +}
196 +
197 +static int erase_write(struct mtd_info *mtd, unsigned long pos,
198 + int len, const char *buf)
199 +{
200 + struct erase_info erase;
201 + DECLARE_WAITQUEUE(wait, current);
202 + wait_queue_head_t wait_q;
203 + size_t retlen;
204 + int ret;
205 +
206 + /*
207 + * First, let's erase the flash block.
208 + */
209 +
210 + init_waitqueue_head(&wait_q);
211 + erase.mtd = mtd;
212 + erase.callback = erase_callback;
213 + erase.addr = pos;
214 + erase.len = len;
215 + erase.priv = (u_long)&wait_q;
216 +
217 + set_current_state(TASK_INTERRUPTIBLE);
218 + add_wait_queue(&wait_q, &wait);
219 +
220 + ret = mtd->erase(mtd, &erase);
221 + if (ret) {
222 + set_current_state(TASK_RUNNING);
223 + remove_wait_queue(&wait_q, &wait);
224 + pr_warn("erase of region [0x%lx, 0x%x] on \"%s\" failed\n",
225 + pos, len, mtd->name);
226 + return ret;
227 + }
228 +
229 + schedule(); /* Wait for erase to finish. */
230 + remove_wait_queue(&wait_q, &wait);
231 +
232 + /*
233 + * Next, write data to flash.
234 + */
235 +
236 + ret = mtd->write(mtd, pos, len, &retlen, buf);
237 + if (ret)
238 + return ret;
239 + if (retlen != len)
240 + return -EIO;
241 + return 0;
242 +}
243 +
244 +
245 +static int
246 +find_dual_image_off(struct mtd_info *mtd)
247 +{
248 + struct trx_header trx;
249 + int off, blocksize;
250 + size_t len;
251 +
252 + blocksize = mtd->erasesize;
253 + if (blocksize < 0x10000)
254 + blocksize = 0x10000;
255 +
256 + for (off = (128*1024); off < mtd->size; off += blocksize) {
257 + memset(&trx, 0xe5, sizeof(trx));
258 + /*
259 + * Read into buffer
260 + */
261 + if (mtd->read(mtd, off, sizeof(trx), &len, (char *) &trx) ||
262 + len != sizeof(trx))
263 + continue;
264 + /* found last TRX header */
265 + if (le32_to_cpu(trx.magic) == TRX_MAGIC) {
266 + if (le32_to_cpu(trx.flag_version >> 16) == 2) {
267 + pr_notice("dual image TRX header found\n");
268 + return mtd->size / 2;
269 + } else {
270 + return 0;
271 + }
272 + }
273 + }
274 + return 0;
275 +}
276 +
277 +
278 +static int
279 +find_root(struct mtd_info *mtd, struct mtd_partition *part)
280 +{
281 + struct trx_header trx, *trx2;
282 + unsigned char buf[512], *block;
283 + int off, blocksize, trxoff = 0;
284 + u32 i, crc = ~0;
285 + size_t len;
286 + bool edimax = false;
287 +
288 + blocksize = mtd->erasesize;
289 + if (blocksize < 0x10000)
290 + blocksize = 0x10000;
291 +
292 + for (off = (128*1024); off < mtd->size; off += blocksize) {
293 + memset(&trx, 0xe5, sizeof(trx));
294 +
295 + /*
296 + * Read into buffer
297 + */
298 + if (mtd->read(mtd, off, sizeof(trx), &len, (char *) &trx) ||
299 + len != sizeof(trx))
300 + continue;
301 +
302 + /* found an edimax header */
303 + if (le32_to_cpu(trx.magic) == EDIMAX_PS_HEADER_MAGIC) {
304 + /* read the correct trx header */
305 + if (mtd->read(mtd, off + EDIMAX_PS_HEADER_LEN,
306 + sizeof(trx), &len, (char *) &trx) ||
307 + len != sizeof(trx)) {
308 + continue;
309 + } else {
310 + pr_notice("Found an edimax ps header\n");
311 + edimax = true;
312 + }
313 + }
314 +
315 + /* found a TRX header */
316 + if (le32_to_cpu(trx.magic) == TRX_MAGIC) {
317 + part->offset = le32_to_cpu(trx.offsets[2]) ? :
318 + le32_to_cpu(trx.offsets[1]);
319 + part->size = le32_to_cpu(trx.len);
320 +
321 + part->size -= part->offset;
322 + part->offset += off;
323 + if (edimax) {
324 + off += EDIMAX_PS_HEADER_LEN;
325 + trxoff = EDIMAX_PS_HEADER_LEN;
326 + }
327 +
328 + goto found;
329 + }
330 + }
331 +
332 + pr_warn("%s: Couldn't find root filesystem\n",
333 + mtd->name);
334 + return -1;
335 +
336 + found:
337 + pr_notice("TRX offset : %x\n", trxoff);
338 + if (part->size == 0)
339 + return 0;
340 +
341 + if (mtd->read(mtd, part->offset, sizeof(buf), &len, buf) || len != sizeof(buf))
342 + return 0;
343 +
344 + /* Move the fs outside of the trx */
345 + part->size = 0;
346 +
347 + if (trx.len != part->offset + part->size - off) {
348 + /* Update the trx offsets and length */
349 + trx.len = part->offset + part->size - off;
350 +
351 + /* Update the trx crc32 */
352 + for (i = (u32) &(((struct trx_header *)NULL)->flag_version); i <= trx.len; i += sizeof(buf)) {
353 + if (mtd->read(mtd, off + i, sizeof(buf), &len, buf) || len != sizeof(buf))
354 + return 0;
355 + crc = crc32_le(crc, buf, min(sizeof(buf), trx.len - i));
356 + }
357 + trx.crc32 = crc;
358 +
359 + /* read first eraseblock from the trx */
360 + block = kmalloc(mtd->erasesize, GFP_KERNEL);
361 + trx2 = (struct trx_header *) block;
362 + if (mtd->read(mtd, off - trxoff, mtd->erasesize, &len, block) || len != mtd->erasesize) {
363 + pr_err("Error accessing the first trx eraseblock\n");
364 + return 0;
365 + }
366 +
367 + pr_notice("Updating TRX offsets and length:\n");
368 + pr_notice("old trx = [0x%08x, 0x%08x, 0x%08x], len=0x%08x crc32=0x%08x\n", trx2->offsets[0], trx2->offsets[1], trx2->offsets[2], trx2->len, trx2->crc32);
369 + pr_notice("new trx = [0x%08x, 0x%08x, 0x%08x], len=0x%08x crc32=0x%08x\n", trx.offsets[0], trx.offsets[1], trx.offsets[2], trx.len, trx.crc32);
370 +
371 + /* Write updated trx header to the flash */
372 + memcpy(block + trxoff, &trx, sizeof(trx));
373 + if (mtd->unlock)
374 + mtd->unlock(mtd, off - trxoff, mtd->erasesize);
375 + erase_write(mtd, off - trxoff, mtd->erasesize, block);
376 + if (mtd->sync)
377 + mtd->sync(mtd);
378 + kfree(block);
379 + pr_notice("Done\n");
380 + }
381 +
382 + return part->size;
383 +}
384 +
385 +static int get_router(void)
386 +{
387 + char buf[20];
388 + u32 boardnum = 0;
389 + u16 boardtype = 0;
390 + u16 boardrev = 0;
391 + u32 boardflags = 0;
392 + u16 sdram_init = 0;
393 + u16 cardbus = 0;
394 + u16 strev = 0;
395 +
396 + if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
397 + boardnum = simple_strtoul(buf, NULL, 0);
398 + if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
399 + boardtype = simple_strtoul(buf, NULL, 0);
400 + if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
401 + boardrev = simple_strtoul(buf, NULL, 0);
402 + if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0)
403 + boardflags = simple_strtoul(buf, NULL, 0);
404 + if (nvram_getenv("sdram_init", buf, sizeof(buf)) >= 0)
405 + sdram_init = simple_strtoul(buf, NULL, 0);
406 + if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
407 + cardbus = simple_strtoul(buf, NULL, 0);
408 + if (nvram_getenv("st_rev", buf, sizeof(buf)) >= 0)
409 + strev = simple_strtoul(buf, NULL, 0);
410 +
411 + if ((boardnum == 8 || boardnum == 01)
412 + && boardtype == 0x0472 && cardbus == 1) {
413 + /* Netgear WNR834B, Netgear WNR834Bv2 */
414 + return ROUTER_NETGEAR_WNR834B;
415 + }
416 +
417 + if (boardnum == 01 && boardtype == 0x0472 && boardrev == 0x23) {
418 + /* Netgear WNDR-3300 */
419 + return ROUTER_NETGEAR_WNDR3300;
420 + }
421 +
422 + if ((boardnum == 83258 || boardnum == 01)
423 + && boardtype == 0x048e
424 + && (boardrev == 0x11 || boardrev == 0x10)
425 + && boardflags == 0x750
426 + && sdram_init == 0x000A) {
427 + /* Netgear WGR614v8/L/WW 16MB ram, cfe v1.3 or v1.5 */
428 + return ROUTER_NETGEAR_WGR614L;
429 + }
430 +
431 + if ((boardnum == 1 || boardnum == 3500)
432 + && boardtype == 0x04CF
433 + && (boardrev == 0x1213 || boardrev == 02)) {
434 + /* Netgear WNR3500v2/U/L */
435 + return ROUTER_NETGEAR_WNR3500L;
436 + }
437 +
438 + if (boardnum == 1 && boardtype == 0xb4cf && boardrev == 0x1100) {
439 + /* Netgear WNDR3400 */
440 + return ROUTER_NETGEAR_WNDR3400;
441 + }
442 +
443 + if (boardtype == 0x042f
444 + && boardrev == 0x10
445 + && boardflags == 0
446 + && strev == 0x11) {
447 + /* Simpletech Simpleshare */
448 + return ROUTER_SIMPLETECH_SIMPLESHARE;
449 + }
450 +
451 + return 0;
452 +}
453 +
454 +static int parse_bcm47xx_partitions(struct mtd_info *mtd,
455 + struct mtd_partition **pparts,
456 + struct mtd_part_parser_data *data)
457 +{
458 + int cfe_size;
459 + int dual_image_offset = 0;
460 + /* e.g Netgear 0x003e0000-0x003f0000 : "board_data", we exclude this
461 + * part from our mapping to prevent overwriting len/checksum on e.g.
462 + * Netgear WGR614v8/L/WW
463 + */
464 + int custom_data_size = 0;
465 + struct mtd_partition *bcm47xx_parts;
466 +
467 + cfe_size = find_cfe_size(mtd);
468 + if (cfe_size < 0)
469 + return 0;
470 +
471 + bcm47xx_parts = kzalloc(sizeof(struct mtd_partition) * 6, GFP_KERNEL);
472 +
473 + bcm47xx_parts[0].name = "cfe";
474 + bcm47xx_parts[1].name = "linux";
475 + bcm47xx_parts[2].name = "rootfs";
476 + bcm47xx_parts[3].name = "nvram";
477 +
478 + /* boot loader */
479 + bcm47xx_parts[0].mask_flags = MTD_WRITEABLE;
480 + bcm47xx_parts[0].offset = 0;
481 + bcm47xx_parts[0].size = cfe_size;
482 +
483 + /* nvram */
484 + if (cfe_size != 384 * 1024) {
485 +
486 + switch (get_router()) {
487 + case ROUTER_NETGEAR_WGR614L:
488 + case ROUTER_NETGEAR_WNR834B:
489 + case ROUTER_NETGEAR_WNDR3300:
490 + case ROUTER_NETGEAR_WNR3500L:
491 + case ROUTER_NETGEAR_WNDR3400:
492 + /* Netgear: checksum is @ 0x003AFFF8 for 4M flash or checksum
493 + * is @ 0x007AFFF8 for 8M flash
494 + */
495 + custom_data_size = mtd->erasesize;
496 +
497 + bcm47xx_parts[3].offset = mtd->size - roundup(NVRAM_SPACE, mtd->erasesize);
498 + bcm47xx_parts[3].size = roundup(NVRAM_SPACE, mtd->erasesize);
499 +
500 + /* Place CFE board_data into a partition */
501 + bcm47xx_parts[4].name = "board_data";
502 + bcm47xx_parts[4].offset = bcm47xx_parts[3].offset - custom_data_size;
503 + bcm47xx_parts[4].size = custom_data_size;
504 + break;
505 +
506 + case ROUTER_SIMPLETECH_SIMPLESHARE:
507 + /* Fixup Simpletech Simple share nvram */
508 +
509 + pr_notice("Setting up simpletech nvram\n");
510 + custom_data_size = mtd->erasesize;
511 +
512 + bcm47xx_parts[3].offset = mtd->size - roundup(NVRAM_SPACE, mtd->erasesize) * 2;
513 + bcm47xx_parts[3].size = roundup(NVRAM_SPACE, mtd->erasesize);
514 +
515 + /* Place backup nvram into a partition */
516 + bcm47xx_parts[4].name = "nvram_copy";
517 + bcm47xx_parts[4].offset = mtd->size - roundup(NVRAM_SPACE, mtd->erasesize);
518 + bcm47xx_parts[4].size = roundup(NVRAM_SPACE, mtd->erasesize);
519 + break;
520 +
521 + default:
522 + bcm47xx_parts[3].offset = mtd->size - roundup(NVRAM_SPACE, mtd->erasesize);
523 + bcm47xx_parts[3].size = roundup(NVRAM_SPACE, mtd->erasesize);
524 + }
525 +
526 + } else {
527 + /* nvram (old 128kb config partition on netgear wgt634u) */
528 + bcm47xx_parts[3].offset = bcm47xx_parts[0].size;
529 + bcm47xx_parts[3].size = roundup(NVRAM_SPACE, mtd->erasesize);
530 + }
531 +
532 + /* dual image offset*/
533 + pr_notice("Looking for dual image\n");
534 + dual_image_offset = find_dual_image_off(mtd);
535 + /* linux (kernel and rootfs) */
536 + if (cfe_size != 384 * 1024) {
537 + if (get_router() == ROUTER_SIMPLETECH_SIMPLESHARE) {
538 + bcm47xx_parts[1].offset = bcm47xx_parts[0].size;
539 + bcm47xx_parts[1].size = bcm47xx_parts[4].offset - dual_image_offset -
540 + bcm47xx_parts[1].offset - custom_data_size;
541 + } else {
542 + bcm47xx_parts[1].offset = bcm47xx_parts[0].size;
543 + bcm47xx_parts[1].size = bcm47xx_parts[3].offset - dual_image_offset -
544 + bcm47xx_parts[1].offset - custom_data_size;
545 + }
546 + } else {
547 + /* do not count the elf loader, which is on one block */
548 + bcm47xx_parts[1].offset = bcm47xx_parts[0].size +
549 + bcm47xx_parts[3].size + mtd->erasesize;
550 + bcm47xx_parts[1].size = mtd->size -
551 + bcm47xx_parts[0].size -
552 + (2*bcm47xx_parts[3].size) -
553 + mtd->erasesize - custom_data_size;
554 + }
555 +
556 + /* find and size rootfs */
557 + find_root(mtd, &bcm47xx_parts[2]);
558 + bcm47xx_parts[2].size = mtd->size - dual_image_offset -
559 + bcm47xx_parts[2].offset -
560 + bcm47xx_parts[3].size - custom_data_size;
561 + *pparts = bcm47xx_parts;
562 + return bcm47xx_parts[4].name == NULL ? 4 : 5;
563 +}
564 +
565 +static struct mtd_part_parser bcm47xx_parser = {
566 + .owner = THIS_MODULE,
567 + .parse_fn = parse_bcm47xx_partitions,
568 + .name = "bcm47xx",
569 +};
570 +
571 +static int __init bcm47xx_parser_init(void)
572 +{
573 + return register_mtd_parser(&bcm47xx_parser);
574 +}
575 +
576 +static void __exit bcm47xx_parser_exit(void)
577 +{
578 + deregister_mtd_parser(&bcm47xx_parser);
579 +}
580 +
581 +module_init(bcm47xx_parser_init);
582 +module_exit(bcm47xx_parser_exit);
583 +
584 +MODULE_LICENSE("GPL");
585 +MODULE_DESCRIPTION("Parsing code for flash partitions on bcm47xx SoCs");
This page took 0.070752 seconds and 5 git commands to generate.