1
0

046-v4.19-mtd-partitions-use-DT-info-for-parsing-partitions-wi.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. From 76a832254ab05502c9394cc51ded6f0abe0e0bee Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Fri, 13 Jul 2018 16:32:21 +0200
  4. Subject: [PATCH] mtd: partitions: use DT info for parsing partitions with
  5. "compatible" prop
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. So far only flash devices could be described in DT regarding partitions
  10. parsing. That could be done with "partitions" subnode and a proper
  11. "compatible" string.
  12. Some devices may use hierarchical (multi-level) layouts and may mix used
  13. layouts (fixed and dynamic). Describing that in DT is done by specifying
  14. "compatible" for DT-represented partition plus optionally more
  15. properties and/or subnodes.
  16. To support such layouts each DT partition has to be checked for
  17. additional description.
  18. Please note this implementation will work in parallel with support for
  19. partition type specified for non-DT setups. That already works since
  20. commit 1a0915be1926 ("mtd: partitions: add support for partition
  21. parsers").
  22. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  23. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
  24. ---
  25. drivers/mtd/mtdpart.c | 33 +++++++++++++--------------------
  26. 1 file changed, 13 insertions(+), 20 deletions(-)
  27. --- a/drivers/mtd/mtdpart.c
  28. +++ b/drivers/mtd/mtdpart.c
  29. @@ -370,22 +370,6 @@ static inline void free_partition(struct
  30. kfree(p);
  31. }
  32. -/**
  33. - * mtd_parse_part - parse MTD partition looking for subpartitions
  34. - *
  35. - * @slave: part that is supposed to be a container and should be parsed
  36. - * @types: NULL-terminated array with names of partition parsers to try
  37. - *
  38. - * Some partitions are kind of containers with extra subpartitions (volumes).
  39. - * There can be various formats of such containers. This function tries to use
  40. - * specified parsers to analyze given partition and registers found
  41. - * subpartitions on success.
  42. - */
  43. -static int mtd_parse_part(struct mtd_part *slave, const char *const *types)
  44. -{
  45. - return parse_mtd_partitions(&slave->mtd, types, NULL);
  46. -}
  47. -
  48. static struct mtd_part *allocate_partition(struct mtd_info *parent,
  49. const struct mtd_partition *part, int partno,
  50. uint64_t cur_offset)
  51. @@ -803,8 +787,8 @@ int add_mtd_partitions(struct mtd_info *
  52. }
  53. mtd_add_partition_attrs(slave);
  54. - if (parts[i].types)
  55. - mtd_parse_part(slave, parts[i].types);
  56. + /* Look for subpartitions */
  57. + parse_mtd_partitions(&slave->mtd, parts[i].types, NULL);
  58. cur_offset = slave->offset + slave->mtd.size;
  59. }
  60. @@ -885,6 +869,12 @@ static const char * const default_mtd_pa
  61. NULL
  62. };
  63. +/* Check DT only when looking for subpartitions. */
  64. +static const char * const default_subpartition_types[] = {
  65. + "ofpart",
  66. + NULL
  67. +};
  68. +
  69. static int mtd_part_do_parse(struct mtd_part_parser *parser,
  70. struct mtd_info *master,
  71. struct mtd_partitions *pparts,
  72. @@ -955,7 +945,9 @@ static int mtd_part_of_parse(struct mtd_
  73. const char *fixed = "fixed-partitions";
  74. int ret, err = 0;
  75. - np = of_get_child_by_name(mtd_get_of_node(master), "partitions");
  76. + np = mtd_get_of_node(master);
  77. + if (!mtd_is_partition(master))
  78. + np = of_get_child_by_name(np, "partitions");
  79. of_property_for_each_string(np, "compatible", prop, compat) {
  80. parser = mtd_part_get_compatible_parser(compat);
  81. if (!parser)
  82. @@ -1018,7 +1010,8 @@ int parse_mtd_partitions(struct mtd_info
  83. int ret, err = 0;
  84. if (!types)
  85. - types = default_mtd_part_types;
  86. + types = mtd_is_partition(master) ? default_subpartition_types :
  87. + default_mtd_part_types;
  88. for ( ; *types; types++) {
  89. /*