kernel: bump 4.19 to 4.19.21
[oweals/openwrt.git] / target / linux / gemini / patches-4.19 / 0010-mtd-partitions-Add-second-compatible-for-redboot.patch
1 From e1b9d122030220d8b8176d9e23568e26fa2f9d23 Mon Sep 17 00:00:00 2001
2 From: Linus Walleij <linus.walleij@linaro.org>
3 Date: Fri, 19 Oct 2018 08:56:41 +0200
4 Subject: [PATCH 10/18] mtd: partitions: Add second compatible for redboot
5
6 Simple backport of the upstream redboot partition table
7 bindings that are used in the mainline Linux kernel.
8
9 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
10 ---
11  drivers/mtd/redboot.c | 29 ++++++++++++++++++++++++++++-
12  1 file changed, 28 insertions(+), 1 deletion(-)
13
14 --- a/drivers/mtd/redboot.c
15 +++ b/drivers/mtd/redboot.c
16 @@ -25,7 +25,7 @@
17  #include <linux/slab.h>
18  #include <linux/init.h>
19  #include <linux/vmalloc.h>
20 -
21 +#include <linux/of.h>
22  #include <linux/mtd/mtd.h>
23  #include <linux/mtd/partitions.h>
24  #include <linux/module.h>
25 @@ -56,6 +56,31 @@ static inline int redboot_checksum(struc
26         return 1;
27  }
28  
29 +#ifdef CONFIG_OF
30 +static void parse_redboot_of(struct mtd_info *master)
31 +{
32 +       struct device_node *np;
33 +       u32 dirblock;
34 +       int ret;
35 +
36 +       np = mtd_get_of_node(master);
37 +       if (!np)
38 +               return;
39 +       ret = of_property_read_u32(np, "fis-index-block", &dirblock);
40 +       if (ret)
41 +               return;
42 +       /*
43 +        * Assign the block found in the device tree to the local
44 +        * directory block pointer.
45 +        */
46 +       directory = dirblock;
47 +}
48 +#else
49 +static void parse_redboot_of(struct mtd_info *master)
50 +{
51 +}
52 +#endif
53 +
54  static int parse_redboot_partitions(struct mtd_info *master,
55                                     const struct mtd_partition **pparts,
56                                     struct mtd_part_parser_data *data)
57 @@ -75,6 +100,7 @@ static int parse_redboot_partitions(stru
58  #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
59         static char nullstring[] = "unallocated";
60  #endif
61 +       parse_redboot_of(master);
62  
63         if ( directory < 0 ) {
64                 offset = master->size + directory * master->erasesize;
65 @@ -298,6 +324,7 @@ static int parse_redboot_partitions(stru
66  
67  static const struct of_device_id redboot_parser_of_match_table[] = {
68         { .compatible = "ecoscentric,redboot-fis-partitions" },
69 +       { .compatible = "redboot-fis" },
70         {},
71  };
72  MODULE_DEVICE_TABLE(of, redboot_parser_of_match_table);