diff mbox

pinctrl: mediatek: fix handling return value of mtk_pmx_find_gpio_mode

Message ID 1455201248-4988-1-git-send-email-a.hajda@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrzej Hajda Feb. 11, 2016, 2:34 p.m. UTC
The function can return negative values, so its result should
be assigned to signed variable.

The problem has been detected using coccinelle semantic patch
scripts/coccinelle/tests/assign_signed_to_unsigned.cocci.

Fixes: 59ee9c9 ('pinctrl: mediatek: Add gpio_request_enable support')
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hongzhou Yang Feb. 12, 2016, 2:59 a.m. UTC | #1
On Thu, 2016-02-11 at 15:34 +0100, Andrzej Hajda wrote:
> The function can return negative values, so its result should
> be assigned to signed variable.
> 
> The problem has been detected using coccinelle semantic patch
> scripts/coccinelle/tests/assign_signed_to_unsigned.cocci.
> 
> Fixes: 59ee9c9 ('pinctrl: mediatek: Add gpio_request_enable support')
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> index cbc2204..ddc9217 100644
> --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> @@ -755,7 +755,7 @@ static int mtk_pmx_gpio_request_enable(struct pinctrl_dev *pctldev,
>  				    struct pinctrl_gpio_range *range,
>  				    unsigned offset)
>  {
> -	unsigned long muxval;
> +	int muxval;
>  	struct mtk_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
>  
>  	muxval = mtk_pmx_find_gpio_mode(pctl, offset);


Thank you very much.

Acked-by: Hongzhou Yang <hongzhou.yang@mediatek.com>

Yours,
Hongzhou
Linus Walleij Feb. 15, 2016, 11:31 p.m. UTC | #2
On Thu, Feb 11, 2016 at 3:34 PM, Andrzej Hajda <a.hajda@samsung.com> wrote:

> The function can return negative values, so its result should
> be assigned to signed variable.
>
> The problem has been detected using coccinelle semantic patch
> scripts/coccinelle/tests/assign_signed_to_unsigned.cocci.
>
> Fixes: 59ee9c9 ('pinctrl: mediatek: Add gpio_request_enable support')
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Patch applied with Hongzhou's ACK.

Yours,
Linus Walleij
diff mbox

Patch

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index cbc2204..ddc9217 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -755,7 +755,7 @@  static int mtk_pmx_gpio_request_enable(struct pinctrl_dev *pctldev,
 				    struct pinctrl_gpio_range *range,
 				    unsigned offset)
 {
-	unsigned long muxval;
+	int muxval;
 	struct mtk_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
 
 	muxval = mtk_pmx_find_gpio_mode(pctl, offset);