aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/patches-4.9/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/generic/patches-4.9/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch')
-rw-r--r--target/linux/generic/patches-4.9/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch89
1 files changed, 35 insertions, 54 deletions
diff --git a/target/linux/generic/patches-4.9/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch b/target/linux/generic/patches-4.9/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch
index 379e551b7f..2726220b8e 100644
--- a/target/linux/generic/patches-4.9/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch
+++ b/target/linux/generic/patches-4.9/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch
@@ -8,35 +8,32 @@ Content-Transfer-Encoding: 8bit
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
- drivers/mtd/bcm47xxpart.c | 50 +++++++++++++++++++++++++++++++++++++----------
- 1 file changed, 40 insertions(+), 10 deletions(-)
---- a/drivers/mtd/bcm47xxpart.c
-+++ b/drivers/mtd/bcm47xxpart.c
-@@ -62,6 +62,34 @@ static void bcm47xxpart_add_part(struct
- part->mask_flags = mask_flags;
- }
+--- a/drivers/mtd/parsers/parser_trx.c
++++ b/drivers/mtd/parsers/parser_trx.c
+@@ -29,6 +29,33 @@ struct trx_header {
+ uint32_t offset[3];
+ } __packed;
+/*
+ * Calculate real end offset (address) for a given amount of data. It checks
+ * all blocks skipping bad ones.
+ */
-+static size_t bcm47xxpart_real_offset(struct mtd_info *master, size_t offset,
-+ size_t bytes)
++static size_t parser_trx_real_offset(struct mtd_info *mtd, size_t bytes)
+{
-+ size_t real_offset = offset;
++ size_t real_offset = 0;
+
-+ if (mtd_block_isbad(master, real_offset))
++ if (mtd_block_isbad(mtd, real_offset))
+ pr_warn("Base offset shouldn't be at bad block");
+
-+ while (bytes >= master->erasesize) {
-+ bytes -= master->erasesize;
-+ real_offset += master->erasesize;
-+ while (mtd_block_isbad(master, real_offset)) {
-+ real_offset += master->erasesize;
++ while (bytes >= mtd->erasesize) {
++ bytes -= mtd->erasesize;
++ real_offset += mtd->erasesize;
++ while (mtd_block_isbad(mtd, real_offset)) {
++ real_offset += mtd->erasesize;
+
-+ if (real_offset >= master->size)
-+ return real_offset - master->erasesize;
++ if (real_offset >= mtd->size)
++ return real_offset - mtd->erasesize;
+ }
+ }
+
@@ -45,47 +42,31 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+ return real_offset;
+}
+
- static const char *bcm47xxpart_trx_data_part_name(struct mtd_info *master,
- size_t offset)
+ static const char *parser_trx_data_part_name(struct mtd_info *master,
+ size_t offset)
{
-@@ -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]) {
-- 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);
+@@ -83,21 +110,21 @@ static int parser_trx_parse(struct mtd_i
+ if (trx.offset[2]) {
+ part = &parts[curr_part++];
+ part->name = "loader";
+- part->offset = trx.offset[i];
++ part->offset = parser_trx_real_offset(mtd, trx.offset[i]);
i++;
}
- 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);
+ if (trx.offset[i]) {
+ part = &parts[curr_part++];
+ part->name = "linux";
+- part->offset = trx.offset[i];
++ part->offset = parser_trx_real_offset(mtd, trx.offset[i]);
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);
+ if (trx.offset[i]) {
+ part = &parts[curr_part++];
+ part->name = parser_trx_data_part_name(mtd, trx.offset[i]);
+- part->offset = trx.offset[i];
++ part->offset = parser_trx_real_offset(mtd, trx.offset[i]);
i++;
+ }
+