--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
-@@ -61,6 +61,34 @@ static void bcm47xxpart_add_part(struct
+@@ -62,6 +62,34 @@ static void bcm47xxpart_add_part(struct
part->mask_flags = mask_flags;
}
static const char *bcm47xxpart_trx_data_part_name(struct mtd_info *master,
size_t offset)
{
-@@ -182,6 +210,8 @@ static int bcm47xxpart_parse(struct mtd_
+@@ -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;
- /* TRX */
- if (buf[0x000 / 4] == TRX_MAGIC) {
-+ uint32_t tmp;
-+
- if (BCM47XXPART_MAX_PARTS - curr_part < 4) {
- pr_warn("Not enough partitions left to register trx, scanning stopped!\n");
- break;
-@@ -196,18 +226,18 @@ static int bcm47xxpart_parse(struct mtd_
- i = 0;
- /* We have LZMA loader if offset[2] points to sth */
- if (trx->offset[2]) {
-+ tmp = bcm47xxpart_real_offset(master, offset,
-+ trx->offset[i]);
- bcm47xxpart_add_part(&parts[curr_part++],
-- "loader",
-- offset + trx->offset[i],
-- 0);
-+ "loader", tmp, 0);
- i++;
- }
+@@ -110,21 +139,25 @@ static int bcm47xxpart_parse_trx(struct
- if (trx->offset[i]) {
-+ tmp = bcm47xxpart_real_offset(master, offset,
-+ trx->offset[i]);
- bcm47xxpart_add_part(&parts[curr_part++],
-- "linux",
-- offset + trx->offset[i],
-- 0);
-+ "linux", tmp, 0);
- i++;
- }
+ /* We have LZMA loader if offset[2] points to sth */
+ if (header.offset[2]) {
+- bcm47xxpart_add_part(&parts[curr_part++], "loader",
+- trx->offset + header.offset[i], 0);
++ offset = bcm47xxpart_real_offset(master, trx->offset,
++ header.offset[i]);
++ bcm47xxpart_add_part(&parts[curr_part++], "loader", offset, 0);
+ i++;
+ }
-@@ -219,11 +249,11 @@ static int bcm47xxpart_parse(struct mtd_
- if (trx->offset[i]) {
- const char *name;
+ if (header.offset[i]) {
+- bcm47xxpart_add_part(&parts[curr_part++], "linux",
+- trx->offset + header.offset[i], 0);
++ offset = bcm47xxpart_real_offset(master, trx->offset,
++ header.offset[i]);
++ bcm47xxpart_add_part(&parts[curr_part++], "linux", offset, 0);
+ i++;
+ }
-- name = bcm47xxpart_trx_data_part_name(master, offset + trx->offset[i]);
-+ tmp = bcm47xxpart_real_offset(master, offset,
-+ trx->offset[i]);
-+ name = bcm47xxpart_trx_data_part_name(master, tmp);
- bcm47xxpart_add_part(&parts[curr_part++],
-- name,
-- offset + trx->offset[i],
-- 0);
-+ name, tmp, 0);
- i++;
- }
+ if (header.offset[i]) {
+- size_t offset = trx->offset + header.offset[i];
+- const char *name = bcm47xxpart_trx_data_part_name(master,
+- offset);
++ const char *name;
++
++ offset = bcm47xxpart_real_offset(master, trx->offset,
++ header.offset[i]);
++ name = bcm47xxpart_trx_data_part_name(master, offset);
+ bcm47xxpart_add_part(&parts[curr_part++], name, offset, 0);
+ i++;