* [PATCH] pinctrl: at91-pio4: fix has_config check in atmel_pctl_dt_subnode_to_map()
@ 2018-09-10 8:37 Dan Carpenter
2018-09-10 8:50 ` Ludovic Desroches
2018-09-13 12:17 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2018-09-10 8:37 UTC (permalink / raw)
To: kernel-janitors
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: 776180848b57 ("pinctrl: introduce driver for Atmel PIO4 controller")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index ef7ab208b951..9e2f3738bf3e 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -493,7 +493,6 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
unsigned num_pins, num_configs, reserve;
unsigned long *configs;
struct property *pins;
- bool has_config;
u32 pinfunc;
int ret, i;
@@ -509,9 +508,6 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
return ret;
}
- if (num_configs)
- has_config = true;
-
num_pins = pins->length / sizeof(u32);
if (!num_pins) {
dev_err(pctldev->dev, "no pins found in node %pOF\n", np);
@@ -524,7 +520,7 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
* map for each pin.
*/
reserve = 1;
- if (has_config && num_pins >= 1)
+ if (num_configs)
reserve++;
reserve *= num_pins;
ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps, num_maps,
@@ -547,7 +543,7 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
pinctrl_utils_add_map_mux(pctldev, map, reserved_maps, num_maps,
group, func);
- if (has_config) {
+ if (num_configs) {
ret = pinctrl_utils_add_map_configs(pctldev, map,
reserved_maps, num_maps, group,
configs, num_configs,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: at91-pio4: fix has_config check in atmel_pctl_dt_subnode_to_map()
2018-09-10 8:37 [PATCH] pinctrl: at91-pio4: fix has_config check in atmel_pctl_dt_subnode_to_map() Dan Carpenter
@ 2018-09-10 8:50 ` Ludovic Desroches
2018-09-13 12:17 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Desroches @ 2018-09-10 8:50 UTC (permalink / raw)
To: kernel-janitors
On Mon, Sep 10, 2018 at 11:37:45AM +0300, Dan Carpenter wrote:
> 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: 776180848b57 ("pinctrl: introduce driver for Atmel PIO4 controller")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Thanks
>
> diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
> index ef7ab208b951..9e2f3738bf3e 100644
> --- a/drivers/pinctrl/pinctrl-at91-pio4.c
> +++ b/drivers/pinctrl/pinctrl-at91-pio4.c
> @@ -493,7 +493,6 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
> unsigned num_pins, num_configs, reserve;
> unsigned long *configs;
> struct property *pins;
> - bool has_config;
> u32 pinfunc;
> int ret, i;
>
> @@ -509,9 +508,6 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
> return ret;
> }
>
> - if (num_configs)
> - has_config = true;
> -
> num_pins = pins->length / sizeof(u32);
> if (!num_pins) {
> dev_err(pctldev->dev, "no pins found in node %pOF\n", np);
> @@ -524,7 +520,7 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
> * map for each pin.
> */
> reserve = 1;
> - if (has_config && num_pins >= 1)
> + if (num_configs)
> reserve++;
> reserve *= num_pins;
> ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps, num_maps,
> @@ -547,7 +543,7 @@ static int atmel_pctl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
> pinctrl_utils_add_map_mux(pctldev, map, reserved_maps, num_maps,
> group, func);
>
> - if (has_config) {
> + if (num_configs) {
> ret = pinctrl_utils_add_map_configs(pctldev, map,
> reserved_maps, num_maps, group,
> configs, num_configs,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: at91-pio4: fix has_config check in atmel_pctl_dt_subnode_to_map()
2018-09-10 8:37 [PATCH] pinctrl: at91-pio4: fix has_config check in atmel_pctl_dt_subnode_to_map() Dan Carpenter
2018-09-10 8:50 ` Ludovic Desroches
@ 2018-09-13 12:17 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2018-09-13 12:17 UTC (permalink / raw)
To: kernel-janitors
On Mon, Sep 10, 2018 at 10:37 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 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: 776180848b57 ("pinctrl: introduce driver for Atmel PIO4 controller")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Patch applied with Ludovic's ACK.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-13 12:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-10 8:37 [PATCH] pinctrl: at91-pio4: fix has_config check in atmel_pctl_dt_subnode_to_map() Dan Carpenter
2018-09-10 8:50 ` Ludovic Desroches
2018-09-13 12:17 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.