0005-pinctrl-gemini-Use-generic-DT-parser.patch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. From 09240ae27ffca65518f7b9d2360c020c1b1ddabe Mon Sep 17 00:00:00 2001
  2. From: Linus Walleij <[email protected]>
  3. Date: Sat, 28 Oct 2017 15:37:18 +0200
  4. Subject: [PATCH 05/31] pinctrl: gemini: Use generic DT parser
  5. We can just use the generic Device Tree parser code
  6. in this driver and save some code.
  7. Acked-by: Hans Ulli Kroll <[email protected]>
  8. Signed-off-by: Linus Walleij <[email protected]>
  9. ---
  10. drivers/pinctrl/Kconfig | 1 +
  11. drivers/pinctrl/pinctrl-gemini.c | 66 +++-------------------------------------
  12. 2 files changed, 5 insertions(+), 62 deletions(-)
  13. --- a/drivers/pinctrl/Kconfig
  14. +++ b/drivers/pinctrl/Kconfig
  15. @@ -153,6 +153,7 @@ config PINCTRL_GEMINI
  16. depends on ARCH_GEMINI
  17. default ARCH_GEMINI
  18. select PINMUX
  19. + select GENERIC_PINCONF
  20. select MFD_SYSCON
  21. config PINCTRL_MCP23S08
  22. --- a/drivers/pinctrl/pinctrl-gemini.c
  23. +++ b/drivers/pinctrl/pinctrl-gemini.c
  24. @@ -13,6 +13,8 @@
  25. #include <linux/pinctrl/machine.h>
  26. #include <linux/pinctrl/pinctrl.h>
  27. #include <linux/pinctrl/pinmux.h>
  28. +#include <linux/pinctrl/pinconf.h>
  29. +#include <linux/pinctrl/pinconf-generic.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/slab.h>
  32. #include <linux/regmap.h>
  33. @@ -1918,73 +1920,13 @@ static void gemini_pin_dbg_show(struct p
  34. seq_printf(s, " " DRIVER_NAME);
  35. }
  36. -static int gemini_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
  37. - struct device_node *np,
  38. - struct pinctrl_map **map,
  39. - unsigned int *reserved_maps,
  40. - unsigned int *num_maps)
  41. -{
  42. - int ret;
  43. - const char *function = NULL;
  44. - const char *group;
  45. - struct property *prop;
  46. -
  47. - ret = of_property_read_string(np, "function", &function);
  48. - if (ret < 0)
  49. - return ret;
  50. -
  51. - ret = of_property_count_strings(np, "groups");
  52. - if (ret < 0)
  53. - return ret;
  54. -
  55. - ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps,
  56. - num_maps, ret);
  57. - if (ret < 0)
  58. - return ret;
  59. -
  60. - of_property_for_each_string(np, "groups", prop, group) {
  61. - ret = pinctrl_utils_add_map_mux(pctldev, map, reserved_maps,
  62. - num_maps, group, function);
  63. - if (ret < 0)
  64. - return ret;
  65. - pr_debug("ADDED FUNCTION %s <-> GROUP %s\n",
  66. - function, group);
  67. - }
  68. -
  69. - return 0;
  70. -}
  71. -
  72. -static int gemini_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
  73. - struct device_node *np_config,
  74. - struct pinctrl_map **map,
  75. - unsigned int *num_maps)
  76. -{
  77. - unsigned int reserved_maps = 0;
  78. - struct device_node *np;
  79. - int ret;
  80. -
  81. - *map = NULL;
  82. - *num_maps = 0;
  83. -
  84. - for_each_child_of_node(np_config, np) {
  85. - ret = gemini_pinctrl_dt_subnode_to_map(pctldev, np, map,
  86. - &reserved_maps, num_maps);
  87. - if (ret < 0) {
  88. - pinctrl_utils_free_map(pctldev, *map, *num_maps);
  89. - return ret;
  90. - }
  91. - }
  92. -
  93. - return 0;
  94. -};
  95. -
  96. static const struct pinctrl_ops gemini_pctrl_ops = {
  97. .get_groups_count = gemini_get_groups_count,
  98. .get_group_name = gemini_get_group_name,
  99. .get_group_pins = gemini_get_group_pins,
  100. .pin_dbg_show = gemini_pin_dbg_show,
  101. - .dt_node_to_map = gemini_pinctrl_dt_node_to_map,
  102. - .dt_free_map = pinctrl_utils_free_map,
  103. + .dt_node_to_map = pinconf_generic_dt_node_to_map_group,
  104. + .dt_free_map = pinconf_generic_dt_free_map,
  105. };
  106. /**