diff mbox

pinctrl: mediatek: signedness bug in mtk_pmx_gpio_request_enable()

Message ID 20160216200658.GA9223@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Feb. 16, 2016, 8:06 p.m. UTC
"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@oracle.com>

Comments

Axel Lin Feb. 17, 2016, 1:44 a.m. UTC | #1
2016-02-17 4:06 GMT+08:00 Dan Carpenter <dan.carpenter@oracle.com>:
> "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@oracle.com>
Reviewed-by: Axel Lin <axel.lin@ingics.com>
Linus Walleij Feb. 18, 2016, 11:27 p.m. UTC | #2
On Tue, Feb 16, 2016 at 9:06 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:

> "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@oracle.com>

I already applied something like this.

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..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);