000-4.5-02-mtd-ofpart-grab-device-tree-node-directly-from-maste.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From 3b6521eab0386a4854d47b1a01947d7dc46ec98d 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] 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. --- a/drivers/mtd/ofpart.c
  23. +++ b/drivers/mtd/ofpart.c
  24. @@ -37,10 +37,11 @@ static int parse_ofpart_partitions(struc
  25. bool dedicated = true;
  26. - if (!data)
  27. - return 0;
  28. -
  29. - mtd_node = data->of_node;
  30. + /*
  31. + * of_node can be provided through auxiliary parser data or (preferred)
  32. + * by assigning the master device node
  33. + */
  34. + mtd_node = data && data->of_node ? data->of_node : mtd_get_of_node(master);
  35. if (!mtd_node)
  36. return 0;
  37. @@ -157,10 +158,11 @@ static int parse_ofoldpart_partitions(st
  38. } *part;
  39. const char *names;
  40. - if (!data)
  41. - return 0;
  42. -
  43. - dp = data->of_node;
  44. + /*
  45. + * of_node can be provided through auxiliary parser data or (preferred)
  46. + * by assigning the master device node
  47. + */
  48. + dp = data && data->of_node ? data->of_node : mtd_get_of_node(master);
  49. if (!dp)
  50. return 0;
  51. --- a/include/linux/mtd/partitions.h
  52. +++ b/include/linux/mtd/partitions.h
  53. @@ -56,7 +56,9 @@ struct device_node;
  54. /**
  55. * struct mtd_part_parser_data - used to pass data to MTD partition parsers.
  56. * @origin: for RedBoot, start address of MTD device
  57. - * @of_node: for OF parsers, device node containing partitioning information
  58. + * @of_node: for OF parsers, device node containing partitioning information.
  59. + * This field is deprecated, as the device node should simply be
  60. + * assigned to the master struct device.
  61. */
  62. struct mtd_part_parser_data {
  63. unsigned long origin;