[patch] pinctrl: mediatek: signedness bug in mtk_pmx_gpio_request_enable()

Dan Carpenter dan.carpenter at oracle.com
Tue Feb 16 12:06:58 PST 2016


"muxval" stores a value from 0-255 or a negative error code.  It has to
be signed for the error handling to work.

Fixes: 59ee9c96dd5d ('pinctrl: mediatek: Add gpio_request_enable support')
Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index cbc2204..1fbaf28 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -755,14 +755,14 @@ 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);
 
 	if (muxval < 0) {
 		dev_err(pctl->dev, "invalid gpio pin %d.\n", offset);
-		return -EINVAL;
+		return muxval;
 	}
 
 	mtk_pmx_set_mode(pctldev, offset, muxval);



More information about the Linux-mediatek mailing list