From da4d46fd63086e4d36efd47b9196098f5cee2a58 Mon Sep 17 00:00:00 2001 From: nbd Date: Tue, 17 Jul 2012 11:35:03 -0400 Subject: [PATCH 13/76] 421-redboot_boardconfig Import of the above patch from openwrt trunk, as of this commit: ---------- commit c1d79f64eed0a7ac36b5b9bca52275b397bec424 Author: nbd Date: Mon Jul 16 16:26:51 2012 +0000 uboot-ar71xx: fix compile on recent mac os x versions git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32750 3c298f89-4303-0410-b956-a3cf2f4a3e73 ---------- Path to patch in the repo is: target/linux/generic/patches-3.3 Repo is: git://nbd.name/openwrt.git Signed-off-by: Paul Gortmaker --- drivers/mtd/redboot.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c index 8ff130b..68a289b 100644 --- a/drivers/mtd/redboot.c +++ b/drivers/mtd/redboot.c @@ -30,6 +30,8 @@ #include #include +#define BOARD_CONFIG_PART "boardconfig" + struct fis_image_desc { unsigned char name[16]; // Null terminated name uint32_t flash_base; // Address within FLASH of image @@ -60,6 +62,7 @@ static int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts, struct mtd_part_parser_data *data) { + unsigned long max_offset = 0; int nrparts = 0; struct fis_image_desc *buf; struct mtd_partition *parts; @@ -225,14 +228,14 @@ static int parse_redboot_partitions(struct mtd_info *master, } } #endif - parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL); + parts = kzalloc(sizeof(*parts) * (nrparts + 1) + nulllen + namelen + sizeof(BOARD_CONFIG_PART), GFP_KERNEL); if (!parts) { ret = -ENOMEM; goto out; } - nullname = (char *)&parts[nrparts]; + nullname = (char *)&parts[nrparts + 1]; #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED if (nulllen > 0) { strcpy(nullname, nullstring); @@ -251,6 +254,8 @@ static int parse_redboot_partitions(struct mtd_info *master, } #endif for ( ; iimg->size; parts[i].offset = fl->img->flash_base; parts[i].name = names; @@ -284,6 +289,14 @@ static int parse_redboot_partitions(struct mtd_info *master, fl = fl->next; kfree(tmp_fl); } + if(master->size - max_offset >= master->erasesize) + { + parts[nrparts].size = master->size - max_offset; + parts[nrparts].offset = max_offset; + parts[nrparts].name = names; + strcpy(names, BOARD_CONFIG_PART); + nrparts++; + } ret = nrparts; *pparts = parts; out: -- 1.7.10.4