451ba3af8bcfbe3062d404d73365ee2e426b2e1e
[openwrt/staging/chunkeey.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 diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
15 index fe3df7437483..e9c21579ba35 100644
16 --- a/drivers/mtd/redboot.c
17 +++ b/drivers/mtd/redboot.c
18 @@ -25,7 +25,7 @@
19 #include <linux/slab.h>
20 #include <linux/init.h>
21 #include <linux/vmalloc.h>
22 -
23 +#include <linux/of.h>
24 #include <linux/mtd/mtd.h>
25 #include <linux/mtd/partitions.h>
26 #include <linux/module.h>
27 @@ -56,6 +56,31 @@ static inline int redboot_checksum(struct fis_image_desc *img)
28 return 1;
29 }
30
31 +#ifdef CONFIG_OF
32 +static void parse_redboot_of(struct mtd_info *master)
33 +{
34 + struct device_node *np;
35 + u32 dirblock;
36 + int ret;
37 +
38 + np = mtd_get_of_node(master);
39 + if (!np)
40 + return;
41 + ret = of_property_read_u32(np, "fis-index-block", &dirblock);
42 + if (ret)
43 + return;
44 + /*
45 + * Assign the block found in the device tree to the local
46 + * directory block pointer.
47 + */
48 + directory = dirblock;
49 +}
50 +#else
51 +static void parse_redboot_of(struct mtd_info *master)
52 +{
53 +}
54 +#endif
55 +
56 static int parse_redboot_partitions(struct mtd_info *master,
57 const struct mtd_partition **pparts,
58 struct mtd_part_parser_data *data)
59 @@ -75,6 +100,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
60 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
61 static char nullstring[] = "unallocated";
62 #endif
63 + parse_redboot_of(master);
64
65 if ( directory < 0 ) {
66 offset = master->size + directory * master->erasesize;
67 @@ -298,6 +324,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
68
69 static const struct of_device_id redboot_parser_of_match_table[] = {
70 { .compatible = "ecoscentric,redboot-fis-partitions" },
71 + { .compatible = "redboot-fis" },
72 {},
73 };
74 MODULE_DEVICE_TABLE(of, redboot_parser_of_match_table);
75 --
76 2.19.2
77