aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-01-31 18:36:51 +0000
committerGabor Juhos <juhosg@openwrt.org>2012-01-31 18:36:51 +0000
commitd5d37febb4d917882569ec00a5a4c65492e6807d (patch)
treec96b479c88146cb0e0ab162f2155594424d9f107
parent44ed690cb321a0fe489d8f78bbfa4d40f3c412d8 (diff)
downloadupstream-d5d37febb4d917882569ec00a5a4c65492e6807d.tar.gz
upstream-d5d37febb4d917882569ec00a5a4c65492e6807d.tar.bz2
upstream-d5d37febb4d917882569ec00a5a4c65492e6807d.zip
ar71xx: use dynamically allocated partitions in wrt160nl_part
SVN-Revision: 29970
-rw-r--r--target/linux/ar71xx/files/drivers/mtd/wrt160nl_part.c18
-rw-r--r--target/linux/ar71xx/patches-3.2/308-wrt160nl_part-3.2-fixes.patch2
2 files changed, 15 insertions, 5 deletions
diff --git a/target/linux/ar71xx/files/drivers/mtd/wrt160nl_part.c b/target/linux/ar71xx/files/drivers/mtd/wrt160nl_part.c
index d979365d66..1f1879ac29 100644
--- a/target/linux/ar71xx/files/drivers/mtd/wrt160nl_part.c
+++ b/target/linux/ar71xx/files/drivers/mtd/wrt160nl_part.c
@@ -77,8 +77,6 @@ struct wrt160nl_header {
struct uimage_header uimage;
} __attribute__ ((packed));
-static struct mtd_partition trx_parts[TRX_PARTS];
-
#define WRT160NL_UBOOT_LEN 0x40000
#define WRT160NL_ART_LEN 0x10000
#define WRT160NL_NVRAM_LEN 0x10000
@@ -90,6 +88,7 @@ static int wrt160nl_parse_partitions(struct mtd_info *master,
struct wrt160nl_header *header;
struct trx_header *theader;
struct uimage_header *uheader;
+ struct mtd_partition *trx_parts;
size_t retlen;
unsigned int kernel_len;
unsigned int uboot_len;
@@ -101,10 +100,17 @@ static int wrt160nl_parse_partitions(struct mtd_info *master,
nvram_len = max_t(unsigned int, master->erasesize, WRT160NL_NVRAM_LEN);
art_len = max_t(unsigned int, master->erasesize, WRT160NL_ART_LEN);
+ trx_parts = kzalloc(TRX_PARTS * sizeof(struct mtd_partition),
+ GFP_KERNEL);
+ if (!trx_parts) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
header = vmalloc(sizeof(*header));
if (!header) {
return -ENOMEM;
- goto out;
+ goto free_parts;
}
ret = master->read(master, uboot_len, sizeof(*header),
@@ -169,11 +175,15 @@ static int wrt160nl_parse_partitions(struct mtd_info *master,
trx_parts[5].size = master->size - uboot_len - nvram_len - art_len;
trx_parts[5].mask_flags = 0;
+ vfree(header);
+
*pparts = trx_parts;
- ret = TRX_PARTS;
+ return TRX_PARTS;
free_hdr:
vfree(header);
+free_parts:
+ kfree(trx_parts);
out:
return ret;
}
diff --git a/target/linux/ar71xx/patches-3.2/308-wrt160nl_part-3.2-fixes.patch b/target/linux/ar71xx/patches-3.2/308-wrt160nl_part-3.2-fixes.patch
index d4d68400dd..3e69e46ce7 100644
--- a/target/linux/ar71xx/patches-3.2/308-wrt160nl_part-3.2-fixes.patch
+++ b/target/linux/ar71xx/patches-3.2/308-wrt160nl_part-3.2-fixes.patch
@@ -1,6 +1,6 @@
--- a/drivers/mtd/wrt160nl_part.c
+++ b/drivers/mtd/wrt160nl_part.c
-@@ -85,7 +85,7 @@ static struct mtd_partition trx_parts[TR
+@@ -83,7 +83,7 @@ struct wrt160nl_header {
static int wrt160nl_parse_partitions(struct mtd_info *master,
struct mtd_partition **pparts,