aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/pending-4.4/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch
diff options
context:
space:
mode:
authorJohn Crispin <john@phrozen.org>2016-12-25 20:11:34 +0100
committerJohn Crispin <john@phrozen.org>2017-08-05 08:46:36 +0200
commit74d00a8c3849c1340efd713eb94b786e304c201f (patch)
treede481743de61c34da96ab5f9dba3af3edcfb8260 /target/linux/generic/pending-4.4/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch
parentde350550ef648d9728351b986b0516fa29465c45 (diff)
downloadupstream-74d00a8c3849c1340efd713eb94b786e304c201f.tar.gz
upstream-74d00a8c3849c1340efd713eb94b786e304c201f.tar.bz2
upstream-74d00a8c3849c1340efd713eb94b786e304c201f.zip
kernel: split patches folder up into backport, pending and hack folders
* properly format/comment all patches * merge debloat patches * merge Kconfig patches * merge swconfig patches * merge hotplug patches * drop 200-fix_localversion.patch - upstream * drop 222-arm_zimage_none.patch - unused * drop 252-mv_cesa_depends.patch - no longer required * drop 410-mtd-move-forward-declaration-of-struct-mtd_info.patch - unused * drop 661-fq_codel_keep_dropped_stats.patch - outdated * drop 702-phy_add_aneg_done_function.patch - upstream * drop 840-rtc7301.patch - unused * drop 841-rtc_pt7c4338.patch - upstream * drop 921-use_preinit_as_init.patch - unused * drop spio-gpio-old and gpio-mmc - unused Signed-off-by: John Crispin <john@phrozen.org>
Diffstat (limited to 'target/linux/generic/pending-4.4/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch')
-rw-r--r--target/linux/generic/pending-4.4/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch91
1 files changed, 91 insertions, 0 deletions
diff --git a/target/linux/generic/pending-4.4/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch b/target/linux/generic/pending-4.4/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch
new file mode 100644
index 0000000000..379e551b7f
--- /dev/null
+++ b/target/linux/generic/pending-4.4/431-mtd-bcm47xxpart-check-for-bad-blocks-when-calculatin.patch
@@ -0,0 +1,91 @@
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Date: Sat, 2 Jan 2016 01:04:52 +0100
+Subject: [PATCH] mtd: bcm47xxpart: check for bad blocks when calculating
+ offsets
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+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;
+ }
+
++/*
++ * 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)
++{
++ size_t real_offset = offset;
++
++ if (mtd_block_isbad(master, 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;
++
++ if (real_offset >= master->size)
++ return real_offset - master->erasesize;
++ }
++ }
++
++ real_offset += bytes;
++
++ return real_offset;
++}
++
+ static const char *bcm47xxpart_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);
+ 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);
+ 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++;