diff mbox series

[v2,4/4] Input: sun4i-ps2 - Fix handling of platform_get_irq() error

Message ID 20200828145744.3636-4-krzk@kernel.org (mailing list archive)
State Accepted
Commit cafb3abea6136e59ea534004e5773361e196bb94
Headers show
Series [v2,1/4] Input: ep93xx_keypad - Fix handling of platform_get_irq() error | expand

Commit Message

Krzysztof Kozlowski Aug. 28, 2020, 2:57 p.m. UTC
platform_get_irq() returns -ERRNO on error.  In such case comparison
to 0 would pass the check.

Fixes: e443631d20f5 ("Input: serio - add support for Alwinner A10/A20 PS/2 controller")
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

---

Changes since v1:
1. None
---
 drivers/input/serio/sun4i-ps2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Chen-Yu Tsai Aug. 28, 2020, 3:34 p.m. UTC | #1
On Fri, Aug 28, 2020 at 10:58 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> platform_get_irq() returns -ERRNO on error.  In such case comparison
> to 0 would pass the check.
>
> Fixes: e443631d20f5 ("Input: serio - add support for Alwinner A10/A20 PS/2 controller")
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

Acked-by: Chen-Yu Tsai <wens@csie.org>
Dmitry Torokhov Sept. 16, 2020, 1:01 a.m. UTC | #2
On Fri, Aug 28, 2020 at 04:57:44PM +0200, Krzysztof Kozlowski wrote:
> platform_get_irq() returns -ERRNO on error.  In such case comparison
> to 0 would pass the check.
> 
> Fixes: e443631d20f5 ("Input: serio - add support for Alwinner A10/A20 PS/2 controller")
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> 
> ---
> 
> Changes since v1:
> 1. None
> ---
>  drivers/input/serio/sun4i-ps2.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/serio/sun4i-ps2.c b/drivers/input/serio/sun4i-ps2.c
> index a681a2c04e39..7da1ea8741fc 100644
> --- a/drivers/input/serio/sun4i-ps2.c
> +++ b/drivers/input/serio/sun4i-ps2.c
> @@ -265,9 +265,8 @@ static int sun4i_ps2_probe(struct platform_device *pdev)
>  
>  	/* Get IRQ for the device */
>  	irq = platform_get_irq(pdev, 0);
> -	if (!irq) {
> -		dev_err(dev, "no IRQ found\n");
> -		error = -ENXIO;
> +	if (irq < 0) {

"irq" is unsigned here, so this will not work. I'll change it to use
drvdat->irq which happens to be signed, and drop "irq" variable.

> +		error = irq;
>  		goto err_disable_clk;
>  	}
>  
> -- 
> 2.17.1
> 

Thanks.
Krzysztof Kozlowski Sept. 16, 2020, 6:08 a.m. UTC | #3
On Wed, 16 Sep 2020 at 03:01, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
>
> On Fri, Aug 28, 2020 at 04:57:44PM +0200, Krzysztof Kozlowski wrote:
> > platform_get_irq() returns -ERRNO on error.  In such case comparison
> > to 0 would pass the check.
> >
> > Fixes: e443631d20f5 ("Input: serio - add support for Alwinner A10/A20 PS/2 controller")
> > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> >
> > ---
> >
> > Changes since v1:
> > 1. None
> > ---
> >  drivers/input/serio/sun4i-ps2.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/input/serio/sun4i-ps2.c b/drivers/input/serio/sun4i-ps2.c
> > index a681a2c04e39..7da1ea8741fc 100644
> > --- a/drivers/input/serio/sun4i-ps2.c
> > +++ b/drivers/input/serio/sun4i-ps2.c
> > @@ -265,9 +265,8 @@ static int sun4i_ps2_probe(struct platform_device *pdev)
> >
> >       /* Get IRQ for the device */
> >       irq = platform_get_irq(pdev, 0);
> > -     if (!irq) {
> > -             dev_err(dev, "no IRQ found\n");
> > -             error = -ENXIO;
> > +     if (irq < 0) {
>
> "irq" is unsigned here, so this will not work. I'll change it to use
> drvdat->irq which happens to be signed, and drop "irq" variable.

Yes, thanks. I wonder now why there was no warning of unsigned<0 comparison.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/input/serio/sun4i-ps2.c b/drivers/input/serio/sun4i-ps2.c
index a681a2c04e39..7da1ea8741fc 100644
--- a/drivers/input/serio/sun4i-ps2.c
+++ b/drivers/input/serio/sun4i-ps2.c
@@ -265,9 +265,8 @@  static int sun4i_ps2_probe(struct platform_device *pdev)
 
 	/* Get IRQ for the device */
 	irq = platform_get_irq(pdev, 0);
-	if (!irq) {
-		dev_err(dev, "no IRQ found\n");
-		error = -ENXIO;
+	if (irq < 0) {
+		error = irq;
 		goto err_disable_clk;
 	}