diff options
author | Sergio Paracuellos <sergio.paracuellos@gmail.com> | 2020-12-13 17:17:15 +0100 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2021-01-04 15:38:34 +0100 |
commit | 53abfe67f024ab8eeac101d05703a49e7e154b67 (patch) | |
tree | 8a57ccdb699ee1437e8e7483d397c92d2111a6e2 /drivers/pinctrl/ralink | |
parent | 86e666df40c995add80a2acfb394dbce7c68dee2 (diff) | |
download | linux-stable-53abfe67f024ab8eeac101d05703a49e7e154b67.tar.gz linux-stable-53abfe67f024ab8eeac101d05703a49e7e154b67.tar.bz2 linux-stable-53abfe67f024ab8eeac101d05703a49e7e154b67.zip |
pinctrl: ralink: rt2880: avoid double pointer to simplify code
Double pointer is being used and assigned in a bit dirty way to
assign functions in pinctrl. Instead of doing this just avoid it
and use directly 'p->func' instead.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20201213161721.6514-3-sergio.paracuellos@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/ralink')
-rw-r--r-- | drivers/pinctrl/ralink/pinctrl-rt2880.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/pinctrl/ralink/pinctrl-rt2880.c b/drivers/pinctrl/ralink/pinctrl-rt2880.c index 42b1c6cecb57..c933e1a1d4fa 100644 --- a/drivers/pinctrl/ralink/pinctrl-rt2880.c +++ b/drivers/pinctrl/ralink/pinctrl-rt2880.c @@ -193,7 +193,6 @@ static struct rt2880_pmx_func gpio_func = { static int rt2880_pinmux_index(struct rt2880_priv *p) { - struct rt2880_pmx_func **f; struct rt2880_pmx_group *mux = p->groups; int i, j, c = 0; @@ -218,31 +217,29 @@ static int rt2880_pinmux_index(struct rt2880_priv *p) p->func_count++; /* allocate our function and group mapping index buffers */ - f = p->func = devm_kcalloc(p->dev, - p->func_count, - sizeof(*p->func), - GFP_KERNEL); + p->func = devm_kcalloc(p->dev, p->func_count, + sizeof(*p->func), GFP_KERNEL); gpio_func.groups = devm_kcalloc(p->dev, p->group_count, sizeof(int), GFP_KERNEL); - if (!f || !gpio_func.groups) - return -1; + if (!p->func || !gpio_func.groups) + return -ENOMEM; /* add a backpointer to the function so it knows its group */ gpio_func.group_count = p->group_count; for (i = 0; i < gpio_func.group_count; i++) gpio_func.groups[i] = i; - f[c] = &gpio_func; + p->func[c] = &gpio_func; c++; /* add remaining functions */ for (i = 0; i < p->group_count; i++) { for (j = 0; j < p->groups[i].func_count; j++) { - f[c] = &p->groups[i].func[j]; - f[c]->groups = devm_kzalloc(p->dev, sizeof(int), + p->func[c] = &p->groups[i].func[j]; + p->func[c]->groups = devm_kzalloc(p->dev, sizeof(int), GFP_KERNEL); - f[c]->groups[0] = i; - f[c]->group_count = 1; + p->func[c]->groups[0] = i; + p->func[c]->group_count = 1; c++; } } |