aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2013-08-21 07:23:37 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-08-23 02:56:32 -0400
commit3287c24088abded9f111ca797fdd36f86912d199 (patch)
tree537d6a48cb062129171a9c491bc7add698aeb842
parent529301c19cbc315929e1b39ee71859061910b652 (diff)
pinctrl: utils : add support to pass config type in generic util APIs
Add support to pass the config type like GROUP or PIN when using the utils or generic pin configuration APIs. This will make the APIs more generic. Added additional inline APIs such that it can be use directly as callback for the pinctrl_ops. Changes from V1: - Remove separate implementation for pins and group for pinctrl_utils_dt_free_map and improve this function to support both i.e. PINS and GROUPs. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Tested-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/pinctrl/pinconf-generic.c9
-rw-r--r--drivers/pinctrl/pinctrl-palmas.c2
-rw-r--r--drivers/pinctrl/pinctrl-utils.c12
-rw-r--r--include/linux/pinctrl/pinconf-generic.h22
4 files changed, 35 insertions, 10 deletions
diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index d9536caa9c41..2c62225bafab 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -240,7 +240,8 @@ out:
240 240
241int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, 241int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
242 struct device_node *np, struct pinctrl_map **map, 242 struct device_node *np, struct pinctrl_map **map,
243 unsigned *reserved_maps, unsigned *num_maps) 243 unsigned *reserved_maps, unsigned *num_maps,
244 enum pinctrl_map_type type)
244{ 245{
245 int ret; 246 int ret;
246 const char *function; 247 const char *function;
@@ -295,7 +296,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
295 if (num_configs) { 296 if (num_configs) {
296 ret = pinctrl_utils_add_map_configs(pctldev, map, 297 ret = pinctrl_utils_add_map_configs(pctldev, map,
297 reserved_maps, num_maps, group, configs, 298 reserved_maps, num_maps, group, configs,
298 num_configs, PIN_MAP_TYPE_CONFIGS_PIN); 299 num_configs, type);
299 if (ret < 0) 300 if (ret < 0)
300 goto exit; 301 goto exit;
301 } 302 }
@@ -310,7 +311,7 @@ EXPORT_SYMBOL_GPL(pinconf_generic_dt_subnode_to_map);
310 311
311int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev, 312int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
312 struct device_node *np_config, struct pinctrl_map **map, 313 struct device_node *np_config, struct pinctrl_map **map,
313 unsigned *num_maps) 314 unsigned *num_maps, enum pinctrl_map_type type)
314{ 315{
315 unsigned reserved_maps; 316 unsigned reserved_maps;
316 struct device_node *np; 317 struct device_node *np;
@@ -322,7 +323,7 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
322 323
323 for_each_child_of_node(np_config, np) { 324 for_each_child_of_node(np_config, np) {
324 ret = pinconf_generic_dt_subnode_to_map(pctldev, np, map, 325 ret = pinconf_generic_dt_subnode_to_map(pctldev, np, map,
325 &reserved_maps, num_maps); 326 &reserved_maps, num_maps, type);
326 if (ret < 0) { 327 if (ret < 0) {
327 pinctrl_utils_dt_free_map(pctldev, *map, *num_maps); 328 pinctrl_utils_dt_free_map(pctldev, *map, *num_maps);
328 return ret; 329 return ret;
diff --git a/drivers/pinctrl/pinctrl-palmas.c b/drivers/pinctrl/pinctrl-palmas.c
index 2697c2efd74b..9550c33b2544 100644
--- a/drivers/pinctrl/pinctrl-palmas.c
+++ b/drivers/pinctrl/pinctrl-palmas.c
@@ -655,7 +655,7 @@ static const struct pinctrl_ops palmas_pinctrl_ops = {
655 .get_groups_count = palmas_pinctrl_get_groups_count, 655 .get_groups_count = palmas_pinctrl_get_groups_count,
656 .get_group_name = palmas_pinctrl_get_group_name, 656 .get_group_name = palmas_pinctrl_get_group_name,
657 .get_group_pins = palmas_pinctrl_get_group_pins, 657 .get_group_pins = palmas_pinctrl_get_group_pins,
658 .dt_node_to_map = pinconf_generic_dt_node_to_map, 658 .dt_node_to_map = pinconf_generic_dt_node_to_map_pin,
659 .dt_free_map = pinctrl_utils_dt_free_map, 659 .dt_free_map = pinctrl_utils_dt_free_map,
660}; 660};
661 661
diff --git a/drivers/pinctrl/pinctrl-utils.c b/drivers/pinctrl/pinctrl-utils.c
index b7ac646c43ba..48277e025f84 100644
--- a/drivers/pinctrl/pinctrl-utils.c
+++ b/drivers/pinctrl/pinctrl-utils.c
@@ -126,10 +126,16 @@ void pinctrl_utils_dt_free_map(struct pinctrl_dev *pctldev,
126{ 126{
127 int i; 127 int i;
128 128
129 for (i = 0; i < num_maps; i++) 129 for (i = 0; i < num_maps; i++) {
130 if (map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP) 130 switch (map[i].type) {
131 case PIN_MAP_TYPE_CONFIGS_GROUP:
132 case PIN_MAP_TYPE_CONFIGS_PIN:
131 kfree(map[i].data.configs.configs); 133 kfree(map[i].data.configs.configs);
132 134 break;
135 default:
136 break;
137 }
138 }
133 kfree(map); 139 kfree(map);
134} 140}
135EXPORT_SYMBOL_GPL(pinctrl_utils_dt_free_map); 141EXPORT_SYMBOL_GPL(pinctrl_utils_dt_free_map);
diff --git a/include/linux/pinctrl/pinconf-generic.h b/include/linux/pinctrl/pinconf-generic.h
index 83f5179ea0c5..fb90ef5eb038 100644
--- a/include/linux/pinctrl/pinconf-generic.h
+++ b/include/linux/pinctrl/pinconf-generic.h
@@ -140,15 +140,33 @@ static inline unsigned long pinconf_to_config_packed(enum pin_config_param param
140#ifdef CONFIG_OF 140#ifdef CONFIG_OF
141 141
142#include <linux/device.h> 142#include <linux/device.h>
143#include <linux/pinctrl/machine.h>
143struct pinctrl_dev; 144struct pinctrl_dev;
144struct pinctrl_map; 145struct pinctrl_map;
145 146
146int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, 147int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
147 struct device_node *np, struct pinctrl_map **map, 148 struct device_node *np, struct pinctrl_map **map,
148 unsigned *reserved_maps, unsigned *num_maps); 149 unsigned *reserved_maps, unsigned *num_maps,
150 enum pinctrl_map_type type);
149int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev, 151int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
150 struct device_node *np_config, struct pinctrl_map **map, 152 struct device_node *np_config, struct pinctrl_map **map,
151 unsigned *num_maps); 153 unsigned *num_maps, enum pinctrl_map_type type);
154
155static inline int pinconf_generic_dt_node_to_map_group(
156 struct pinctrl_dev *pctldev, struct device_node *np_config,
157 struct pinctrl_map **map, unsigned *num_maps)
158{
159 return pinconf_generic_dt_node_to_map(pctldev, np_config, map, num_maps,
160 PIN_MAP_TYPE_CONFIGS_GROUP);
161}
162
163static inline int pinconf_generic_dt_node_to_map_pin(
164 struct pinctrl_dev *pctldev, struct device_node *np_config,
165 struct pinctrl_map **map, unsigned *num_maps)
166{
167 return pinconf_generic_dt_node_to_map(pctldev, np_config, map, num_maps,
168 PIN_MAP_TYPE_CONFIGS_PIN);
169}
152 170
153#endif 171#endif
154 172