mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-16 05:50:19 +00:00
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>
This commit is contained in:
parent
529301c19c
commit
3287c24088
@ -240,7 +240,8 @@ out:
|
||||
|
||||
int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
|
||||
struct device_node *np, struct pinctrl_map **map,
|
||||
unsigned *reserved_maps, unsigned *num_maps)
|
||||
unsigned *reserved_maps, unsigned *num_maps,
|
||||
enum pinctrl_map_type type)
|
||||
{
|
||||
int ret;
|
||||
const char *function;
|
||||
@ -295,7 +296,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
|
||||
if (num_configs) {
|
||||
ret = pinctrl_utils_add_map_configs(pctldev, map,
|
||||
reserved_maps, num_maps, group, configs,
|
||||
num_configs, PIN_MAP_TYPE_CONFIGS_PIN);
|
||||
num_configs, type);
|
||||
if (ret < 0)
|
||||
goto exit;
|
||||
}
|
||||
@ -310,7 +311,7 @@ EXPORT_SYMBOL_GPL(pinconf_generic_dt_subnode_to_map);
|
||||
|
||||
int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
|
||||
struct device_node *np_config, struct pinctrl_map **map,
|
||||
unsigned *num_maps)
|
||||
unsigned *num_maps, enum pinctrl_map_type type)
|
||||
{
|
||||
unsigned reserved_maps;
|
||||
struct device_node *np;
|
||||
@ -322,7 +323,7 @@ int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
|
||||
|
||||
for_each_child_of_node(np_config, np) {
|
||||
ret = pinconf_generic_dt_subnode_to_map(pctldev, np, map,
|
||||
&reserved_maps, num_maps);
|
||||
&reserved_maps, num_maps, type);
|
||||
if (ret < 0) {
|
||||
pinctrl_utils_dt_free_map(pctldev, *map, *num_maps);
|
||||
return ret;
|
||||
|
@ -655,7 +655,7 @@ static const struct pinctrl_ops palmas_pinctrl_ops = {
|
||||
.get_groups_count = palmas_pinctrl_get_groups_count,
|
||||
.get_group_name = palmas_pinctrl_get_group_name,
|
||||
.get_group_pins = palmas_pinctrl_get_group_pins,
|
||||
.dt_node_to_map = pinconf_generic_dt_node_to_map,
|
||||
.dt_node_to_map = pinconf_generic_dt_node_to_map_pin,
|
||||
.dt_free_map = pinctrl_utils_dt_free_map,
|
||||
};
|
||||
|
||||
|
@ -126,10 +126,16 @@ void pinctrl_utils_dt_free_map(struct pinctrl_dev *pctldev,
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num_maps; i++)
|
||||
if (map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP)
|
||||
for (i = 0; i < num_maps; i++) {
|
||||
switch (map[i].type) {
|
||||
case PIN_MAP_TYPE_CONFIGS_GROUP:
|
||||
case PIN_MAP_TYPE_CONFIGS_PIN:
|
||||
kfree(map[i].data.configs.configs);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
kfree(map);
|
||||
}
|
||||
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
|
||||
#ifdef CONFIG_OF
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/pinctrl/machine.h>
|
||||
struct pinctrl_dev;
|
||||
struct pinctrl_map;
|
||||
|
||||
int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev,
|
||||
struct device_node *np, struct pinctrl_map **map,
|
||||
unsigned *reserved_maps, unsigned *num_maps);
|
||||
unsigned *reserved_maps, unsigned *num_maps,
|
||||
enum pinctrl_map_type type);
|
||||
int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
|
||||
struct device_node *np_config, struct pinctrl_map **map,
|
||||
unsigned *num_maps);
|
||||
unsigned *num_maps, enum pinctrl_map_type type);
|
||||
|
||||
static inline int pinconf_generic_dt_node_to_map_group(
|
||||
struct pinctrl_dev *pctldev, struct device_node *np_config,
|
||||
struct pinctrl_map **map, unsigned *num_maps)
|
||||
{
|
||||
return pinconf_generic_dt_node_to_map(pctldev, np_config, map, num_maps,
|
||||
PIN_MAP_TYPE_CONFIGS_GROUP);
|
||||
}
|
||||
|
||||
static inline int pinconf_generic_dt_node_to_map_pin(
|
||||
struct pinctrl_dev *pctldev, struct device_node *np_config,
|
||||
struct pinctrl_map **map, unsigned *num_maps)
|
||||
{
|
||||
return pinconf_generic_dt_node_to_map(pctldev, np_config, map, num_maps,
|
||||
PIN_MAP_TYPE_CONFIGS_PIN);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user