atheros: various braces fixes
[openwrt/svn-archive/archive.git] / target / linux / atheros / patches-3.10 / 140-redboot_boardconfig.patch
1 --- a/drivers/mtd/redboot.c
2 +++ b/drivers/mtd/redboot.c
3 @@ -30,6 +30,8 @@
4 #include <linux/mtd/partitions.h>
5 #include <linux/module.h>
6
7 +#define BOARD_CONFIG_PART "boardconfig"
8 +
9 struct fis_image_desc {
10 unsigned char name[16]; // Null terminated name
11 uint32_t flash_base; // Address within FLASH of image
12 @@ -60,6 +62,7 @@ static int parse_redboot_partitions(stru
13 struct mtd_partition **pparts,
14 struct mtd_part_parser_data *data)
15 {
16 + unsigned long max_offset = 0;
17 int nrparts = 0;
18 struct fis_image_desc *buf;
19 struct mtd_partition *parts;
20 @@ -225,14 +228,14 @@ static int parse_redboot_partitions(stru
21 }
22 }
23 #endif
24 - parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);
25 + parts = kzalloc(sizeof(*parts) * (nrparts + 1) + nulllen + namelen + sizeof(BOARD_CONFIG_PART), GFP_KERNEL);
26
27 if (!parts) {
28 ret = -ENOMEM;
29 goto out;
30 }
31
32 - nullname = (char *)&parts[nrparts];
33 + nullname = (char *)&parts[nrparts + 1];
34 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
35 if (nulllen > 0) {
36 strcpy(nullname, nullstring);
37 @@ -251,6 +254,8 @@ static int parse_redboot_partitions(stru
38 }
39 #endif
40 for ( ; i<nrparts; i++) {
41 + if(max_offset < buf[i].flash_base + buf[i].size)
42 + max_offset = buf[i].flash_base + buf[i].size;
43 parts[i].size = fl->img->size;
44 parts[i].offset = fl->img->flash_base;
45 parts[i].name = names;
46 @@ -284,6 +289,13 @@ static int parse_redboot_partitions(stru
47 fl = fl->next;
48 kfree(tmp_fl);
49 }
50 + if (master->size - max_offset >= master->erasesize) {
51 + parts[nrparts].size = master->size - max_offset;
52 + parts[nrparts].offset = max_offset;
53 + parts[nrparts].name = names;
54 + strcpy(names, BOARD_CONFIG_PART);
55 + nrparts++;
56 + }
57 ret = nrparts;
58 *pparts = parts;
59 out: