aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2014-09-30 05:11:50 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-09-30 05:23:19 -0400
commitb07f92a220fa4df01e7feb1791245882249ba200 (patch)
tree7675c472ab4113f9111972daf83b3d446a360bc5 /drivers/pinctrl
parent90d099383d3a93de5b363a05f4013f3a78cab593 (diff)
pinctrl: abx500: use helpers for map allocation/free
This switches the abx500 driver to use the pin control helper utils for allocating and free:ing maps. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/nomadik/pinctrl-abx500.c43
1 files changed, 5 insertions, 38 deletions
diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nomadik/pinctrl-abx500.c
index b0289824cf73..be95f5e68c01 100644
--- a/drivers/pinctrl/nomadik/pinctrl-abx500.c
+++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c
@@ -34,6 +34,7 @@
34#include "pinctrl-abx500.h" 34#include "pinctrl-abx500.h"
35#include "../core.h" 35#include "../core.h"
36#include "../pinconf.h" 36#include "../pinconf.h"
37#include "../pinctrl-utils.h"
37 38
38/* 39/*
39 * The AB9540 and AB8540 GPIO support are extended versions 40 * The AB9540 and AB8540 GPIO support are extended versions
@@ -827,41 +828,6 @@ static void abx500_pin_dbg_show(struct pinctrl_dev *pctldev,
827 chip->base + offset - 1); 828 chip->base + offset - 1);
828} 829}
829 830
830static void abx500_dt_free_map(struct pinctrl_dev *pctldev,
831 struct pinctrl_map *map, unsigned num_maps)
832{
833 int i;
834
835 for (i = 0; i < num_maps; i++)
836 if (map[i].type == PIN_MAP_TYPE_CONFIGS_PIN)
837 kfree(map[i].data.configs.configs);
838 kfree(map);
839}
840
841static int abx500_dt_reserve_map(struct pinctrl_map **map,
842 unsigned *reserved_maps,
843 unsigned *num_maps,
844 unsigned reserve)
845{
846 unsigned old_num = *reserved_maps;
847 unsigned new_num = *num_maps + reserve;
848 struct pinctrl_map *new_map;
849
850 if (old_num >= new_num)
851 return 0;
852
853 new_map = krealloc(*map, sizeof(*new_map) * new_num, GFP_KERNEL);
854 if (!new_map)
855 return -ENOMEM;
856
857 memset(new_map + old_num, 0, (new_num - old_num) * sizeof(*new_map));
858
859 *map = new_map;
860 *reserved_maps = new_num;
861
862 return 0;
863}
864
865static int abx500_dt_add_map_mux(struct pinctrl_map **map, 831static int abx500_dt_add_map_mux(struct pinctrl_map **map,
866 unsigned *reserved_maps, 832 unsigned *reserved_maps,
867 unsigned *num_maps, const char *group, 833 unsigned *num_maps, const char *group,
@@ -958,7 +924,8 @@ static int abx500_dt_subnode_to_map(struct pinctrl_dev *pctldev,
958 924
959 reserve *= ret; 925 reserve *= ret;
960 926
961 ret = abx500_dt_reserve_map(map, reserved_maps, num_maps, reserve); 927 ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps,
928 num_maps, reserve);
962 if (ret < 0) 929 if (ret < 0)
963 goto exit; 930 goto exit;
964 931
@@ -999,7 +966,7 @@ static int abx500_dt_node_to_map(struct pinctrl_dev *pctldev,
999 ret = abx500_dt_subnode_to_map(pctldev, np, map, 966 ret = abx500_dt_subnode_to_map(pctldev, np, map,
1000 &reserved_maps, num_maps); 967 &reserved_maps, num_maps);
1001 if (ret < 0) { 968 if (ret < 0) {
1002 abx500_dt_free_map(pctldev, *map, *num_maps); 969 pinctrl_utils_dt_free_map(pctldev, *map, *num_maps);
1003 return ret; 970 return ret;
1004 } 971 }
1005 } 972 }
@@ -1013,7 +980,7 @@ static const struct pinctrl_ops abx500_pinctrl_ops = {
1013 .get_group_pins = abx500_get_group_pins, 980 .get_group_pins = abx500_get_group_pins,
1014 .pin_dbg_show = abx500_pin_dbg_show, 981 .pin_dbg_show = abx500_pin_dbg_show,
1015 .dt_node_to_map = abx500_dt_node_to_map, 982 .dt_node_to_map = abx500_dt_node_to_map,
1016 .dt_free_map = abx500_dt_free_map, 983 .dt_free_map = pinctrl_utils_dt_free_map,
1017}; 984};
1018 985
1019static int abx500_pin_config_get(struct pinctrl_dev *pctldev, 986static int abx500_pin_config_get(struct pinctrl_dev *pctldev,