kernel: update bcm47xxpart failsafe partition patches

V2 using helper function was sent for upstream kernel

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
This commit is contained in:
Rafał Miłecki 2017-01-11 09:53:44 +01:00
parent 593240075f
commit 7c8a36340c
5 changed files with 49 additions and 37 deletions

View File

@ -17,7 +17,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
#include <uapi/linux/magic.h> #include <uapi/linux/magic.h>
@@ -250,6 +251,28 @@ static int bcm47xxpart_parse(struct mtd_ @@ -249,6 +250,28 @@ static int bcm47xxpart_parse(struct mtd_
break; break;
} }

View File

@ -14,12 +14,12 @@ is more than 1 TRX partition.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
--- ---
drivers/mtd/bcm47xxpart.c | 124 ++++++++++++++++++++++++++++------------------ drivers/mtd/bcm47xxpart.c | 121 ++++++++++++++++++++++++++++------------------
1 file changed, 77 insertions(+), 47 deletions(-) 1 file changed, 74 insertions(+), 47 deletions(-)
--- a/drivers/mtd/bcm47xxpart.c --- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c
@@ -83,6 +83,70 @@ out_default: @@ -83,6 +83,67 @@ out_default:
return "rootfs"; return "rootfs";
} }
@ -28,7 +28,6 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+ struct mtd_partition *parts, + struct mtd_partition *parts,
+ size_t parts_len) + size_t parts_len)
+{ +{
+ struct mtd_partition *part;
+ struct trx_header header; + struct trx_header header;
+ size_t bytes_read; + size_t bytes_read;
+ int curr_part = 0; + int curr_part = 0;
@ -50,25 +49,23 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+ +
+ /* We have LZMA loader if offset[2] points to sth */ + /* We have LZMA loader if offset[2] points to sth */
+ if (header.offset[2]) { + if (header.offset[2]) {
+ part = &parts[curr_part++]; + bcm47xxpart_add_part(&parts[curr_part++], "loader",
+ part->name = "loader"; + trx->offset + header.offset[i], 0);
+ part->offset = trx->offset + header.offset[i];
+ i++; + i++;
+ } + }
+ +
+ if (header.offset[i]) { + if (header.offset[i]) {
+ part = &parts[curr_part++]; + bcm47xxpart_add_part(&parts[curr_part++], "linux",
+ part->name = "linux"; + trx->offset + header.offset[i], 0);
+ part->offset = trx->offset + header.offset[i];
+ i++; + i++;
+ } + }
+ +
+ if (header.offset[i]) { + if (header.offset[i]) {
+ size_t offset = trx->offset + header.offset[i]; + size_t offset = trx->offset + header.offset[i];
+ const char *name = bcm47xxpart_trx_data_part_name(master,
+ offset);
+ +
+ part = &parts[curr_part++]; + bcm47xxpart_add_part(&parts[curr_part++], name, offset, 0);
+ part->name = bcm47xxpart_trx_data_part_name(master, offset);
+ part->offset = offset;
+ i++; + i++;
+ } + }
+ +
@ -90,7 +87,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
static int bcm47xxpart_parse(struct mtd_info *master, static int bcm47xxpart_parse(struct mtd_info *master,
struct mtd_partition **pparts, struct mtd_partition **pparts,
struct mtd_part_parser_data *data) struct mtd_part_parser_data *data)
@@ -93,9 +157,7 @@ static int bcm47xxpart_parse(struct mtd_ @@ -93,9 +154,7 @@ static int bcm47xxpart_parse(struct mtd_
size_t bytes_read; size_t bytes_read;
uint32_t offset; uint32_t offset;
uint32_t blocksize = master->erasesize; uint32_t blocksize = master->erasesize;
@ -100,7 +97,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, }; int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, };
int err; int err;
@@ -182,54 +244,14 @@ static int bcm47xxpart_parse(struct mtd_ @@ -182,54 +241,14 @@ static int bcm47xxpart_parse(struct mtd_
/* TRX */ /* TRX */
if (buf[0x000 / 4] == TRX_MAGIC) { if (buf[0x000 / 4] == TRX_MAGIC) {
@ -157,7 +154,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
offset = roundup(offset + trx->length, blocksize); offset = roundup(offset + trx->length, blocksize);
/* Next loop iteration will increase the offset */ /* Next loop iteration will increase the offset */
offset -= blocksize; offset -= blocksize;
@@ -307,9 +329,17 @@ static int bcm47xxpart_parse(struct mtd_ @@ -307,9 +326,17 @@ static int bcm47xxpart_parse(struct mtd_
parts[i + 1].offset : master->size; parts[i + 1].offset : master->size;
parts[i].size = next_part_offset - parts[i].offset; parts[i].size = next_part_offset - parts[i].offset;

View File

@ -24,7 +24,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/slab.h> #include <linux/slab.h>
@@ -147,6 +148,30 @@ static int bcm47xxpart_parse_trx(struct @@ -144,6 +145,30 @@ static int bcm47xxpart_parse_trx(struct
return curr_part; return curr_part;
} }
@ -55,7 +55,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
static int bcm47xxpart_parse(struct mtd_info *master, static int bcm47xxpart_parse(struct mtd_info *master,
struct mtd_partition **pparts, struct mtd_partition **pparts,
struct mtd_part_parser_data *data) struct mtd_part_parser_data *data)
@@ -157,7 +182,8 @@ static int bcm47xxpart_parse(struct mtd_ @@ -154,7 +179,8 @@ static int bcm47xxpart_parse(struct mtd_
size_t bytes_read; size_t bytes_read;
uint32_t offset; uint32_t offset;
uint32_t blocksize = master->erasesize; uint32_t blocksize = master->erasesize;
@ -65,7 +65,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, }; int possible_nvram_sizes[] = { 0x8000, 0xF000, 0x10000, };
int err; int err;
@@ -246,7 +272,11 @@ static int bcm47xxpart_parse(struct mtd_ @@ -243,7 +269,11 @@ static int bcm47xxpart_parse(struct mtd_
if (buf[0x000 / 4] == TRX_MAGIC) { if (buf[0x000 / 4] == TRX_MAGIC) {
struct trx_header *trx; struct trx_header *trx;
@ -78,7 +78,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
bcm47xxpart_add_part(&parts[curr_part++], "firmware", bcm47xxpart_add_part(&parts[curr_part++], "firmware",
offset, 0); offset, 0);
@@ -332,14 +362,20 @@ static int bcm47xxpart_parse(struct mtd_ @@ -329,14 +359,20 @@ static int bcm47xxpart_parse(struct mtd_
} }
/* If there was TRX parse it now */ /* If there was TRX parse it now */

View File

@ -48,29 +48,44 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
static const char *bcm47xxpart_trx_data_part_name(struct mtd_info *master, static const char *bcm47xxpart_trx_data_part_name(struct mtd_info *master,
size_t offset) size_t offset)
{ {
@@ -113,19 +141,22 @@ static int bcm47xxpart_parse_trx(struct @@ -91,6 +119,7 @@ static int bcm47xxpart_parse_trx(struct
{
struct trx_header header;
size_t bytes_read;
+ size_t offset;
int curr_part = 0;
int i, err;
@@ -110,21 +139,25 @@ static int bcm47xxpart_parse_trx(struct
/* We have LZMA loader if offset[2] points to sth */
if (header.offset[2]) { if (header.offset[2]) {
part = &parts[curr_part++]; - bcm47xxpart_add_part(&parts[curr_part++], "loader",
part->name = "loader"; - trx->offset + header.offset[i], 0);
- part->offset = trx->offset + header.offset[i]; + offset = bcm47xxpart_real_offset(master, trx->offset,
+ part->offset = bcm47xxpart_real_offset(master, trx->offset, + header.offset[i]);
+ header.offset[i]); + bcm47xxpart_add_part(&parts[curr_part++], "loader", offset, 0);
i++; i++;
} }
if (header.offset[i]) { if (header.offset[i]) {
part = &parts[curr_part++]; - bcm47xxpart_add_part(&parts[curr_part++], "linux",
part->name = "linux"; - trx->offset + header.offset[i], 0);
- part->offset = trx->offset + header.offset[i]; + offset = bcm47xxpart_real_offset(master, trx->offset,
+ part->offset = bcm47xxpart_real_offset(master, trx->offset, + header.offset[i]);
+ header.offset[i]); + bcm47xxpart_add_part(&parts[curr_part++], "linux", offset, 0);
i++; i++;
} }
if (header.offset[i]) { if (header.offset[i]) {
- size_t offset = trx->offset + header.offset[i]; - size_t offset = trx->offset + header.offset[i];
+ size_t offset = bcm47xxpart_real_offset(master, trx->offset, - const char *name = bcm47xxpart_trx_data_part_name(master,
+ header.offset[i]); - offset);
+ const char *name;
+
+ offset = bcm47xxpart_real_offset(master, trx->offset,
+ header.offset[i]);
+ name = bcm47xxpart_trx_data_part_name(master, offset);
part = &parts[curr_part++]; bcm47xxpart_add_part(&parts[curr_part++], name, offset, 0);
part->name = bcm47xxpart_trx_data_part_name(master, offset); i++;

View File

@ -24,7 +24,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
#define ML_MAGIC1 0x39685a42 #define ML_MAGIC1 0x39685a42
#define ML_MAGIC2 0x26594131 #define ML_MAGIC2 0x26594131
#define TRX_MAGIC 0x30524448 #define TRX_MAGIC 0x30524448
@@ -298,6 +299,15 @@ static int bcm47xxpart_parse(struct mtd_ @@ -297,6 +298,15 @@ static int bcm47xxpart_parse(struct mtd_
MTD_WRITEABLE); MTD_WRITEABLE);
continue; continue;
} }