brcm47xx: add initial support for kernel 3.8
[15.05/openwrt.git] / target / linux / brcm47xx / patches-3.8 / 021-mtd-bcm47xxpart-register-extra-firmware-partition.patch
1 --- a/drivers/mtd/bcm47xxpart.c
2 +++ b/drivers/mtd/bcm47xxpart.c
3 @@ -61,6 +61,8 @@ static int bcm47xxpart_parse(struct mtd_
4         uint32_t offset;
5         uint32_t blocksize = 0x10000;
6         struct trx_header *trx;
7 +       int trx_part = -1;
8 +       int last_trx_part = -1;
9  
10         /* Alloc */
11         parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS,
12 @@ -131,6 +133,10 @@ static int bcm47xxpart_parse(struct mtd_
13                 if (buf[0x000 / 4] == TRX_MAGIC) {
14                         trx = (struct trx_header *)buf;
15  
16 +                       trx_part = curr_part;
17 +                       bcm47xxpart_add_part(&parts[curr_part++], "firmware",
18 +                                            offset, 0);
19 +
20                         i = 0;
21                         /* We have LZMA loader if offset[2] points to sth */
22                         if (trx->offset[2]) {
23 @@ -154,6 +160,8 @@ static int bcm47xxpart_parse(struct mtd_
24                                              offset + trx->offset[i], 0);
25                         i++;
26  
27 +                       last_trx_part = curr_part - 1;
28 +
29                         /*
30                          * We have whole TRX scanned, skip to the next part. Use
31                          * roundown (not roundup), as the loop will increase
32 @@ -174,6 +182,9 @@ static int bcm47xxpart_parse(struct mtd_
33                                        parts[i + 1].offset : master->size;
34  
35                 parts[i].size = next_part_offset - parts[i].offset;
36 +               if (i == last_trx_part && trx_part >= 0)
37 +                       parts[trx_part].size = next_part_offset -
38 +                                              parts[trx_part].offset;
39         }
40  
41         *pparts = parts;