kernel: update bcma and ssb to version from wireless-testing/master tag master-2013...
[openwrt.git] / target / linux / brcm47xx / patches-3.8 / 025-mtd-bcm47xxpart-look-for-NVRAM-at-the-end-of-device.patch
1 --- a/drivers/mtd/bcm47xxpart.c
2 +++ b/drivers/mtd/bcm47xxpart.c
3 @@ -63,6 +63,7 @@ static int bcm47xxpart_parse(struct mtd_
4         struct trx_header *trx;
5         int trx_part = -1;
6         int last_trx_part = -1;
7 +       int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, };
8  
9         if (blocksize <= 0x10000)
10                 blocksize = 0x10000;
11 @@ -99,13 +100,6 @@ static int bcm47xxpart_parse(struct mtd_
12                         continue;
13                 }
14  
15 -               /* Standard NVRAM */
16 -               if (buf[0x000 / 4] == NVRAM_HEADER) {
17 -                       bcm47xxpart_add_part(&parts[curr_part++], "nvram",
18 -                                            offset, 0);
19 -                       continue;
20 -               }
21 -
22                 /*
23                  * board_data starts with board_id which differs across boards,
24                  * but we can use 'MPFR' (hopefully) magic at 0x100
25 @@ -174,6 +168,30 @@ static int bcm47xxpart_parse(struct mtd_
26                         continue;
27                 }
28         }
29 +
30 +       /* Look for NVRAM at the end of the last block. */
31 +       for (i = 0; i < ARRAY_SIZE(possible_nvram_sizes); i++) {
32 +               if (curr_part > BCM47XXPART_MAX_PARTS) {
33 +                       pr_warn("Reached maximum number of partitions, scanning stopped!\n");
34 +                       break;
35 +               }
36 +
37 +               offset = master->size - possible_nvram_sizes[i];
38 +               if (mtd_read(master, offset, 0x4, &bytes_read,
39 +                            (uint8_t *)buf) < 0) {
40 +                       pr_err("mtd_read error while reading at offset 0x%X!\n",
41 +                              offset);
42 +                       continue;
43 +               }
44 +
45 +               /* Standard NVRAM */
46 +               if (buf[0] == NVRAM_HEADER) {
47 +                       bcm47xxpart_add_part(&parts[curr_part++], "nvram",
48 +                                            master->size - blocksize, 0);
49 +                       break;
50 +               }
51 +       }
52 +
53         kfree(buf);
54  
55         /*