* [PATCH] pinctrl: mediatek: mtk-common: initialize unmask
@ 2015-04-20 11:15 ` Colin King
0 siblings, 0 replies; 4+ messages in thread
From: Colin King @ 2015-04-20 11:15 UTC (permalink / raw)
To: Linus Walleij, Matthias Brugger, Hongzhou Yang, Yingjoe Chen,
Maoguang Meng, linux-gpio, linux-arm-kernel, linux-mediatek
Cc: linux-kernel
From: Colin Ian King <colin.king@canonical.com>
cppcheck detected an unitialized variable:
[drivers/pinctrl/mediatek/pinctrl-mtk-common.c:897]:
(error) Uninitialized variable: unmask
unmask should be initialized to zero to ensure unmasking
only occurs if a previous mask occurred. The current situation
is that the unmask variable could contain any random garbage
causing random unexpected unmasking.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index 493294c..3173125 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -881,7 +881,8 @@ static int mtk_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
if (!mtk_eint_get_mask(pctl, eint_num)) {
mtk_eint_mask(d);
unmask = 1;
- }
+ } else
+ unmask = 0;
clr_bit = 0xff << eint_offset;
writel(clr_bit, pctl->eint_reg_base + clr_offset);
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] pinctrl: mediatek: mtk-common: initialize unmask
@ 2015-04-20 11:15 ` Colin King
0 siblings, 0 replies; 4+ messages in thread
From: Colin King @ 2015-04-20 11:15 UTC (permalink / raw)
To: linux-arm-kernel
From: Colin Ian King <colin.king@canonical.com>
cppcheck detected an unitialized variable:
[drivers/pinctrl/mediatek/pinctrl-mtk-common.c:897]:
(error) Uninitialized variable: unmask
unmask should be initialized to zero to ensure unmasking
only occurs if a previous mask occurred. The current situation
is that the unmask variable could contain any random garbage
causing random unexpected unmasking.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index 493294c..3173125 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -881,7 +881,8 @@ static int mtk_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
if (!mtk_eint_get_mask(pctl, eint_num)) {
mtk_eint_mask(d);
unmask = 1;
- }
+ } else
+ unmask = 0;
clr_bit = 0xff << eint_offset;
writel(clr_bit, pctl->eint_reg_base + clr_offset);
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] pinctrl: mediatek: mtk-common: initialize unmask
2015-04-20 11:15 ` Colin King
@ 2015-04-20 12:32 ` Sergei Shtylyov
-1 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2015-04-20 12:32 UTC (permalink / raw)
To: Colin King, Linus Walleij, Matthias Brugger, Hongzhou Yang,
Yingjoe Chen, Maoguang Meng, linux-gpio, linux-arm-kernel,
linux-mediatek
Cc: linux-kernel
Hello.
On 04/20/2015 02:15 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> cppcheck detected an unitialized variable:
Uninitialized.
> [drivers/pinctrl/mediatek/pinctrl-mtk-common.c:897]:
> (error) Uninitialized variable: unmask
> unmask should be initialized to zero to ensure unmasking
> only occurs if a previous mask occurred. The current situation
> is that the unmask variable could contain any random garbage
> causing random unexpected unmasking.
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> index 493294c..3173125 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> @@ -881,7 +881,8 @@ static int mtk_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
> if (!mtk_eint_get_mask(pctl, eint_num)) {
> mtk_eint_mask(d);
> unmask = 1;
> - }
> + } else
> + unmask = 0;
The CodingStyle dictates that there should be {} around *else* branch too.
[...]
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] pinctrl: mediatek: mtk-common: initialize unmask
@ 2015-04-20 12:32 ` Sergei Shtylyov
0 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2015-04-20 12:32 UTC (permalink / raw)
To: linux-arm-kernel
Hello.
On 04/20/2015 02:15 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> cppcheck detected an unitialized variable:
Uninitialized.
> [drivers/pinctrl/mediatek/pinctrl-mtk-common.c:897]:
> (error) Uninitialized variable: unmask
> unmask should be initialized to zero to ensure unmasking
> only occurs if a previous mask occurred. The current situation
> is that the unmask variable could contain any random garbage
> causing random unexpected unmasking.
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> index 493294c..3173125 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> @@ -881,7 +881,8 @@ static int mtk_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
> if (!mtk_eint_get_mask(pctl, eint_num)) {
> mtk_eint_mask(d);
> unmask = 1;
> - }
> + } else
> + unmask = 0;
The CodingStyle dictates that there should be {} around *else* branch too.
[...]
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-20 12:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-20 11:15 [PATCH] pinctrl: mediatek: mtk-common: initialize unmask Colin King
2015-04-20 11:15 ` Colin King
2015-04-20 12:32 ` Sergei Shtylyov
2015-04-20 12:32 ` Sergei Shtylyov
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.