diff options
author | Sergey Ryazanov <ryazanov.s.a@gmail.com> | 2018-05-21 12:19:29 +0300 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2018-05-24 17:24:30 +0200 |
commit | 586872da59946a378d75d2d0ab4e3da93b4b9979 (patch) | |
tree | 70f2251133136be1630ef13be3ee8143e7c52d23 /target/linux/ath25/patches-4.14/142-redboot_various_erase_size_fix.patch | |
parent | acdac1aa55d06f5e84b28aa3b5c7c97c2e6cb1db (diff) | |
download | upstream-586872da59946a378d75d2d0ab4e3da93b4b9979.tar.gz upstream-586872da59946a378d75d2d0ab4e3da93b4b9979.tar.bz2 upstream-586872da59946a378d75d2d0ab4e3da93b4b9979.zip |
ath25: add kernel 4.14 support
Copy and refresh patches and config from 4.9, no more work is need.
Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
(cherry picked from commit 3d69857ac1647e5bc924a9af1e8d00182316cb0d)
Diffstat (limited to 'target/linux/ath25/patches-4.14/142-redboot_various_erase_size_fix.patch')
-rw-r--r-- | target/linux/ath25/patches-4.14/142-redboot_various_erase_size_fix.patch | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/target/linux/ath25/patches-4.14/142-redboot_various_erase_size_fix.patch b/target/linux/ath25/patches-4.14/142-redboot_various_erase_size_fix.patch new file mode 100644 index 0000000000..ce039df9f1 --- /dev/null +++ b/target/linux/ath25/patches-4.14/142-redboot_various_erase_size_fix.patch @@ -0,0 +1,72 @@ +--- a/drivers/mtd/redboot.c ++++ b/drivers/mtd/redboot.c +@@ -58,6 +58,22 @@ static inline int redboot_checksum(struc + return 1; + } + ++static uint32_t mtd_get_offset_erasesize(struct mtd_info *mtd, uint64_t offset) ++{ ++ struct mtd_erase_region_info *regions = mtd->eraseregions; ++ int i; ++ ++ for (i = 0; i < mtd->numeraseregions; i++) { ++ if (regions[i].offset + ++ regions[i].numblocks * regions[i].erasesize <= offset) ++ continue; ++ ++ return regions[i].erasesize; ++ } ++ ++ return mtd->erasesize; ++} ++ + static int parse_redboot_partitions(struct mtd_info *master, + const struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +@@ -74,6 +90,7 @@ static int parse_redboot_partitions(stru + int namelen = 0; + int nulllen = 0; + int numslots; ++ int first_slot; + unsigned long offset; + #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED + static char nullstring[] = "unallocated"; +@@ -186,7 +203,10 @@ static int parse_redboot_partitions(stru + goto out; + } + +- for (i = 0; i < numslots; i++) { ++ first_slot = (buf[i].flash_base & (master->erasesize - 1)) / ++ sizeof(struct fis_image_desc); ++ ++ for (i = first_slot; i < first_slot + numslots; i++) { + struct fis_list *new_fl, **prev; + + if (buf[i].name[0] == 0xff) { +@@ -262,12 +282,13 @@ static int parse_redboot_partitions(stru + } + #endif + for ( ; i<nrparts; i++) { +- if (max_offset < buf[i].flash_base + buf[i].size) +- max_offset = buf[i].flash_base + buf[i].size; + parts[i].size = fl->img->size; + parts[i].offset = fl->img->flash_base; + parts[i].name = names; + ++ if (max_offset < parts[i].offset + parts[i].size) ++ max_offset = parts[i].offset + parts[i].size; ++ + strcpy(names, fl->img->name); + #ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY + if (!memcmp(names, "RedBoot", 8) || +@@ -297,7 +318,9 @@ static int parse_redboot_partitions(stru + fl = fl->next; + kfree(tmp_fl); + } +- if (master->size - max_offset >= master->erasesize) { ++ ++ if (master->size - max_offset >= ++ mtd_get_offset_erasesize(master, max_offset)) { + parts[nrparts].size = master->size - max_offset; + parts[nrparts].offset = max_offset; + parts[nrparts].name = names; |