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.
Unified · Split
| @@ -240,7 +240,8 @@ out: · 239 unmodified lines | |||
| 240 | 240 | ||
| 241 | int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, | 241 | int 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, · 48 unmodified lines | |||
| 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); · 8 unmodified lines | |||
| 310 | 311 | ||
| 311 | int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev, | 312 | int 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, · 5 unmodified lines | |||
| 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; |
| @@ -655,7 +655,7 @@ static const struct pinctrl_ops palmas_pinctrl_ops = { · 654 unmodified lines | |||
| 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 | ||
| @@ -126,10 +126,16 @@ void pinctrl_utils_dt_free_map(struct pinctrl_dev *pctldev, · 125 unmodified lines | |||
| 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 | } |
| 135 | EXPORT_SYMBOL_GPL(pinctrl_utils_dt_free_map); | 141 | EXPORT_SYMBOL_GPL(pinctrl_utils_dt_free_map); |
| @@ -140,15 +140,33 @@ static inline unsigned long pinconf_to_config_packed(enum pin_config_param param · 139 unmodified lines | |||
| 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> | ||
| 143 | struct pinctrl_dev; | 144 | struct pinctrl_dev; |
| 144 | struct pinctrl_map; | 145 | struct pinctrl_map; |
| 145 | 146 | ||
| 146 | int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, | 147 | int 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); | ||
| 149 | int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev, | 151 | int 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 | |||
| 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 | } | ||
| 152 | 170 | ||
| 153 | #endif | 171 | #endif |
| 154 | 172 | ||