History

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.

Laxman Dewangan committed 13 years ago

Commit 3287c241 parent 529301c4 files · +35 −10Browse files

Unified · Split

4 files
  1. drivers/pinctrl/pinconf-generic.c +5 −4
  2. drivers/pinctrl/pinctrl-palmas.c +1 −1
  3. drivers/pinctrl/pinctrl-utils.c +9 −3
  4. include/linux/pinctrl/pinconf-generic.h +20 −2
drivers/pinctrl/pinconf-generic.c+5−4
@@ -240,7 +240,8 @@ out: · 239 unmodified lines
240240
241241 int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
242242 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)
244245 {
245246 int ret;
246247 const char *function;
@@ -295,7 +296,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, · 48 unmodified lines
295296 if (num_configs) {
296297 ret = pinctrl_utils_add_map_configs(pctldev, map,
297298 reserved_maps, num_maps, group, configs,
298− num_configs, PIN_MAP_TYPE_CONFIGS_PIN);
299+ num_configs, type);
299300 if (ret < 0)
300301 goto exit;
301302 }
@@ -310,7 +311,7 @@ EXPORT_SYMBOL_GPL(pinconf_generic_dt_subnode_to_map); · 8 unmodified lines
310311
311312 int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
312313 struct device_node *np_config, struct pinctrl_map **map,
313− unsigned *num_maps)
314+ unsigned *num_maps, enum pinctrl_map_type type)
314315 {
315316 unsigned reserved_maps;
316317 struct device_node *np;
@@ -322,7 +323,7 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev, · 5 unmodified lines
322323
323324 for_each_child_of_node(np_config, np) {
324325 ret = pinconf_generic_dt_subnode_to_map(pctldev, np, map,
325− &reserved_maps, num_maps);
326+ &reserved_maps, num_maps, type);
326327 if (ret < 0) {
327328 pinctrl_utils_dt_free_map(pctldev, *map, *num_maps);
328329 return ret;
drivers/pinctrl/pinctrl-palmas.c+1−1
@@ -655,7 +655,7 @@ static const struct pinctrl_ops palmas_pinctrl_ops = { · 654 unmodified lines
655655 .get_groups_count = palmas_pinctrl_get_groups_count,
656656 .get_group_name = palmas_pinctrl_get_group_name,
657657 .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,
659659 .dt_free_map = pinctrl_utils_dt_free_map,
660660 };
661661
drivers/pinctrl/pinctrl-utils.c+9−3
@@ -126,10 +126,16 @@ void pinctrl_utils_dt_free_map(struct pinctrl_dev *pctldev, · 125 unmodified lines
126126 {
127127 int i;
128128
129− for (i = 0; i < num_maps; i++)
130− if (map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP)
129+ for (i = 0; i < num_maps; i++) {
130+ switch (map[i].type) {
131+ case PIN_MAP_TYPE_CONFIGS_GROUP:
132+ case PIN_MAP_TYPE_CONFIGS_PIN:
131133 kfree(map[i].data.configs.configs);
132−
134+ break;
135+ default:
136+ break;
137+ }
138+ }
133139 kfree(map);
134140 }
135141 EXPORT_SYMBOL_GPL(pinctrl_utils_dt_free_map);
include/linux/pinctrl/pinconf-generic.h+20−2
@@ -140,15 +140,33 @@ static inline unsigned long pinconf_to_config_packed(enum pin_config_param param · 139 unmodified lines
140140 #ifdef CONFIG_OF
141141
142142 #include <linux/device.h>
143+#include <linux/pinctrl/machine.h>
143144 struct pinctrl_dev;
144145 struct pinctrl_map;
145146
146147 int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
147148 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);
149151 int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
150152 struct device_node *np_config, struct pinctrl_map **map,
151− unsigned *num_maps);
153+ unsigned *num_maps, enum pinctrl_map_type type);
154+
155+static 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+
163+static 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+}
152170
153171 #endif
154172

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t