0010-mtd-partitions-Add-second-compatible-for-redboot.patch 2.0 KB

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