0028-mtd-ofpart-grab-device-tree-node-directly-from-maste.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. From 62b613003aa4cef3f8bf9a2ec4c7709daf4dde8a Mon Sep 17 00:00:00 2001
  2. From: Brian Norris <computersforpeace@gmail.com>
  3. Date: Fri, 30 Oct 2015 20:33:21 -0700
  4. Subject: [PATCH 28/33] mtd: ofpart: grab device tree node directly from master
  5. device node
  6. It seems more logical to use a device node directly associated with the
  7. MTD master device (i.e., mtd->dev.of_node field) rather than requiring
  8. auxiliary partition parser information to be passed in by the driver in
  9. a separate struct.
  10. This patch supports the mtd->dev.of_node field and deprecates the parser
  11. data 'of_node' field
  12. Driver conversions may now follow.
  13. Additional side benefit to assigning mtd->dev.of_node rather than using
  14. parser data: the driver core will automatically create a device -> node
  15. symlink for us.
  16. Signed-off-by: Brian Norris <computersforpeace@gmail.com>
  17. Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
  18. ---
  19. drivers/mtd/ofpart.c | 18 ++++++++++--------
  20. include/linux/mtd/partitions.h | 4 +++-
  21. 2 files changed, 13 insertions(+), 9 deletions(-)
  22. diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
  23. index 9ed6038..cf4780c 100644
  24. --- a/drivers/mtd/ofpart.c
  25. +++ b/drivers/mtd/ofpart.c
  26. @@ -37,10 +37,11 @@ static int parse_ofpart_partitions(struct mtd_info *master,
  27. bool dedicated = true;
  28. - if (!data)
  29. - return 0;
  30. -
  31. - mtd_node = data->of_node;
  32. + /*
  33. + * of_node can be provided through auxiliary parser data or (preferred)
  34. + * by assigning the master device node
  35. + */
  36. + mtd_node = data && data->of_node ? data->of_node : mtd_get_of_node(master);
  37. if (!mtd_node)
  38. return 0;
  39. @@ -157,10 +158,11 @@ static int parse_ofoldpart_partitions(struct mtd_info *master,
  40. } *part;
  41. const char *names;
  42. - if (!data)
  43. - return 0;
  44. -
  45. - dp = data->of_node;
  46. + /*
  47. + * of_node can be provided through auxiliary parser data or (preferred)
  48. + * by assigning the master device node
  49. + */
  50. + dp = data && data->of_node ? data->of_node : mtd_get_of_node(master);
  51. if (!dp)
  52. return 0;
  53. diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
  54. index 6a35e6d..e742f34 100644
  55. --- a/include/linux/mtd/partitions.h
  56. +++ b/include/linux/mtd/partitions.h
  57. @@ -56,7 +56,9 @@ struct device_node;
  58. /**
  59. * struct mtd_part_parser_data - used to pass data to MTD partition parsers.
  60. * @origin: for RedBoot, start address of MTD device
  61. - * @of_node: for OF parsers, device node containing partitioning information
  62. + * @of_node: for OF parsers, device node containing partitioning information.
  63. + * This field is deprecated, as the device node should simply be
  64. + * assigned to the master struct device.
  65. */
  66. struct mtd_part_parser_data {
  67. unsigned long origin;
  68. --
  69. 2.8.1