atheros[ar231x-eth]: pass phys address of I/O memory via platform res
[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,15 @@ 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 +
26 + sizeof(BOARD_CONFIG_PART), GFP_KERNEL);
27
28 if (!parts) {
29 ret = -ENOMEM;
30 goto out;
31 }
32
33 - nullname = (char *)&parts[nrparts];
34 + nullname = (char *)&parts[nrparts + 1];
35 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
36 if (nulllen > 0) {
37 strcpy(nullname, nullstring);
38 @@ -251,6 +255,8 @@ static int parse_redboot_partitions(stru
39 }
40 #endif
41 for ( ; i<nrparts; i++) {
42 + if (max_offset < buf[i].flash_base + buf[i].size)
43 + max_offset = buf[i].flash_base + buf[i].size;
44 parts[i].size = fl->img->size;
45 parts[i].offset = fl->img->flash_base;
46 parts[i].name = names;
47 @@ -284,6 +290,13 @@ static int parse_redboot_partitions(stru
48 fl = fl->next;
49 kfree(tmp_fl);
50 }
51 + if (master->size - max_offset >= master->erasesize) {
52 + parts[nrparts].size = master->size - max_offset;
53 + parts[nrparts].offset = max_offset;
54 + parts[nrparts].name = names;
55 + strcpy(names, BOARD_CONFIG_PART);
56 + nrparts++;
57 + }
58 ret = nrparts;
59 *pparts = parts;
60 out: