mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-22 12:14:01 +08:00
staging: mt7621-pinctrl: use pinconf-generic for 'dt_node_to_map' and 'dt_free_map'
Instead of reimplement afunction to do 'dt_node_to_map' task like
'rt2880_pinctrl_dt_node_to_map' make use of 'pinconf_generic_dt_node_to_map_all'
generic function for this task. Also use its equivalent function for free which
is 'pinconf_generic_dt_free_map'. Remove 'rt2880_pinctrl_dt_node_to_map' function
which is not needed anymore. This decrease a bit driver LOC and make it more
generic. To properly compile this changes 'GENERIC_PINCONF' option is selected
with the driver in its Kconfig file.
This also fix a problem with function 'rt2880_pinctrl_dt_node_to_map' which was
calling internally 'pinctrl_utils_reserve_map' which expects 'num_maps' to be initialized.
It does a memory allocation based on the value, and triggers the following
warning if is not properly set:
if (unlikely(order >= MAX_ORDER)) {
WARN_ON_ONCE(!(gfp_mask & __GFP_NOWARN));
return NULL;
}
Generic function 'pinconf_generic_dt_node_to_map_all' initializes properly
'num_maps' to zero fixing the problem.
Fixes: e12a1a6e08
("staging: mt7621-pinctrl: refactor rt2880_pinctrl_dt_node_to_map function")
Reported-by: NeilBrown <neil@brown.name>
Tested-by: NeilBrown <neil@brown.name>
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9a47dc5f7e
commit
0ca1f90861
@ -2,3 +2,4 @@ config PINCTRL_RT2880
|
||||
bool "RT2800 pinctrl driver for RALINK/Mediatek SOCs"
|
||||
depends on RALINK
|
||||
select PINMUX
|
||||
select GENERIC_PINCONF
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <linux/of.h>
|
||||
#include <linux/pinctrl/pinctrl.h>
|
||||
#include <linux/pinctrl/pinconf.h>
|
||||
#include <linux/pinctrl/pinconf-generic.h>
|
||||
#include <linux/pinctrl/pinmux.h>
|
||||
#include <linux/pinctrl/consumer.h>
|
||||
#include <linux/pinctrl/machine.h>
|
||||
@ -73,48 +74,12 @@ static int rt2880_get_group_pins(struct pinctrl_dev *pctrldev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev,
|
||||
struct device_node *np_config,
|
||||
struct pinctrl_map **map,
|
||||
unsigned int *num_maps)
|
||||
{
|
||||
struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
|
||||
struct property *prop;
|
||||
const char *function_name, *group_name;
|
||||
int ret;
|
||||
int ngroups = 0;
|
||||
unsigned int reserved_maps = 0;
|
||||
|
||||
for_each_node_with_property(np_config, "group")
|
||||
ngroups++;
|
||||
|
||||
*map = NULL;
|
||||
ret = pinctrl_utils_reserve_map(pctrldev, map, &reserved_maps,
|
||||
num_maps, ngroups);
|
||||
if (ret) {
|
||||
dev_err(p->dev, "can't reserve map: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
of_property_for_each_string(np_config, "group", prop, group_name) {
|
||||
ret = pinctrl_utils_add_map_mux(pctrldev, map, &reserved_maps,
|
||||
num_maps, group_name,
|
||||
function_name);
|
||||
if (ret) {
|
||||
dev_err(p->dev, "can't add map: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct pinctrl_ops rt2880_pctrl_ops = {
|
||||
.get_groups_count = rt2880_get_group_count,
|
||||
.get_group_name = rt2880_get_group_name,
|
||||
.get_group_pins = rt2880_get_group_pins,
|
||||
.dt_node_to_map = rt2880_pinctrl_dt_node_to_map,
|
||||
.dt_free_map = pinctrl_utils_free_map,
|
||||
.dt_node_to_map = pinconf_generic_dt_node_to_map_all,
|
||||
.dt_free_map = pinconf_generic_dt_free_map,
|
||||
};
|
||||
|
||||
static int rt2880_pmx_func_count(struct pinctrl_dev *pctrldev)
|
||||
|
Loading…
Reference in New Issue
Block a user