Commit 3b468fa9 authored by Dan Carpenter's avatar Dan Carpenter Committed by Kleber Sacilotto de Souza

pinctrl: at91-pio4: fix has_config check in atmel_pctl_dt_subnode_to_map()

BugLink: https://bugs.launchpad.net/bugs/1853881

[ Upstream commit b97760ae ]

Smatch complains about this condition:

	if (has_config && num_pins >= 1)

The "has_config" variable is either uninitialized or true.  The
"num_pins" variable is unsigned and we verified that it is non-zero on
the lines before so we know "num_pines >= 1" is true.  Really, we could
just check "num_configs" directly and remove the "has_config" variable.

Fixes: 77618084 ("pinctrl: introduce driver for Atmel PIO4 controller")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarLudovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 5f5a788d
...@@ -477,7 +477,6 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev, ...@@ -477,7 +477,6 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
unsigned num_pins, num_configs, reserve; unsigned num_pins, num_configs, reserve;
unsigned long *configs; unsigned long *configs;
struct property *pins; struct property *pins;
bool has_config;
u32 pinfunc; u32 pinfunc;
int ret, i; int ret, i;
...@@ -493,9 +492,6 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev, ...@@ -493,9 +492,6 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
return ret; return ret;
} }
if (num_configs)
has_config = true;
num_pins = pins->length / sizeof(u32); num_pins = pins->length / sizeof(u32);
if (!num_pins) { if (!num_pins) {
dev_err(pctldev->dev, "no pins found in node %s\n", dev_err(pctldev->dev, "no pins found in node %s\n",
...@@ -508,7 +504,7 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev, ...@@ -508,7 +504,7 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
* map for each pin. * map for each pin.
*/ */
reserve = 1; reserve = 1;
if (has_config && num_pins >= 1) if (num_configs)
reserve++; reserve++;
reserve *= num_pins; reserve *= num_pins;
ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps, num_maps, ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps, num_maps,
...@@ -531,7 +527,7 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev, ...@@ -531,7 +527,7 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
pinctrl_utils_add_map_mux(pctldev, map, reserved_maps, num_maps, pinctrl_utils_add_map_mux(pctldev, map, reserved_maps, num_maps,
group, func); group, func);
if (has_config) { if (num_configs) {
ret = pinctrl_utils_add_map_configs(pctldev, map, ret = pinctrl_utils_add_map_configs(pctldev, map,
reserved_maps, num_maps, group, reserved_maps, num_maps, group,
configs, num_configs, configs, num_configs,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment