aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/patches-4.3/0101-mtd-add-rtn56u-support.patch
blob: 50b88dbcd3efdea40690d9552712d200a33b8e34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -807,8 +807,11 @@ static void split_uimage(struct mtd_info
 {
 	struct {
 		__be32 magic;
-		__be32 pad[2];
+		__be32 pad0[2];
 		__be32 size;
+		__be32 pad1[4];
+		__be32 name[7];
+		__be32 kern_size;
 	} hdr;
 	size_t len;
 
@@ -818,7 +821,10 @@ static void split_uimage(struct mtd_info
 	if (len != sizeof(hdr) || hdr.magic != cpu_to_be32(UBOOT_MAGIC))
 		return;
 
-	len = be32_to_cpu(hdr.size) + 0x40;
+	if (hdr.kern_size != 0 && hdr.name[0] == 0)
+		len = be32_to_cpu(hdr.kern_size);
+	else
+		len = be32_to_cpu(hdr.size) + 0x40;
 
 	if (config_enabled(CONFIG_MTD_SPLIT_UIMAGE_FW))
 		pr_err("Dedicated partitioner didn't split firmware partition, please fill a bug report!\n");