Input: ep93xx_keypad - Fix handling of platform_get_irq() error
Subsystems (3)
PATCH v2 1/4 Input: ep93xx_keypad - Fix handling of platform_get_irq() error
platform_get_irq() returns -ERRNO on error. In such case comparison to 0 would pass the check.
---
Changes since v1:
1. None
--- drivers/input/keyboard/ep93xx_keypad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/ep93xx_keypad.c +2 -2
@@ -250,8 +250,8 @@ static int ep93xx_keypad_probe(struct platform_device *pdev) } keypad->irq =platform_get_irq (pdev,0 ); -if (!keypad->irq) { - err = -ENXIO ; +if (keypad->irq <0 ) { + err = keypad->irq; goto failed_free; }
Signature · 1 line
2.17.1
PATCH v2 2/4 Input: omap4-keypad - Fix handling of platform_get_irq() error
platform_get_irq() returns -ERRNO on error. In such case comparison to 0 would pass the check.
---
Changes since v1:
1. None
--- drivers/input/keyboard/omap4-keypad.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/keyboard/omap4-keypad.c +2 -4
@@ -240,10 +240,8 @@ static int omap4_keypad_probe(struct platform_device *pdev) } irq =platform_get_irq (pdev,0 ); -if (!irq) { -dev_err (&pdev->dev,"no keyboard irq assigned\n" ); -return -EINVAL ; - } +if (irq <0 ) +return -irq; keypad_data =kzalloc (sizeof (struct omap4_keypad ),GFP_KERNEL );if (!keypad_data) {
Signature · 1 line
2.17.1
PATCH v2 4/4 Input: sun4i-ps2 - Fix handling of platform_get_irq() error
In reply to Krzysztof Kozlowskiplatform_get_irq() returns -ERRNO on error. In such case comparison to 0 would pass the check.
---
Changes since v1:
1. None
--- drivers/input/serio/sun4i-ps2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/input/serio/sun4i-ps2.c +2 -3
@@ -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; }
Signature · 1 line
2.17.1
PATCH v2 3/4 Input: twl4030_keypad - Fix handling of platform_get_irq() error
In reply to Krzysztof Kozlowskiplatform_get_irq() returns -ERRNO on error. In such case casting to unsigned and comparing to 0 would pass the check.
---
Changes since v1:
1. Fix also casting return value to unsigned.
--- drivers/input/keyboard/twl4030_keypad.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/input/keyboard/twl4030_keypad.c +3 -5
@@ -50,7 +50,7 @@ struct twl4030_keypad {bool autorepeat;unsigned int n_rows;unsigned int n_cols; -unsigned int irq; +int irq;struct device *dbg_dev;struct input_dev *input;
@@ -376,10 +376,8 @@ static int twl4030_kp_probe(struct platform_device *pdev) } kp->irq =platform_get_irq (pdev,0 ); -if (!kp->irq) { -dev_err (&pdev->dev,"no keyboard irq assigned\n" ); -return -EINVAL ; - } +if (kp->irq <0 ) +return kp->irq; error = matrix_keypad_build_keymap(keymap_data, NULL, TWL4030_MAX_ROWS,
Signature · 1 line
2.17.1
Re: [PATCH v2 4/4] Input: sun4i-ps2 - Fix handling of platform_get_irq() error
In reply to Krzysztof KozlowskiQuoted 6 lines · Krzysztof Kozlowski
platform_get_irq()returns-ERRNOon 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 <[email protected]>
Quoted 6 lines · Krzysztof Kozlowski
platform_get_irq()returns-ERRNOon error. In such case comparison to 0 would pass the check.Fixes 60214f058f44 ("Input: ep93xx_keypad - update driver to new core support")Signed-off-by Krzysztof Kozlowski <[email protected]>
Quoted 7 lines
---
Changes since v1:
1. None--- drivers/input/keyboard/ep93xx_keypad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Hi Dmitry,
Any comments on the series?
Best regards,
Krzysztof
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Dmitry Torokhov
maintainerHi Krzysztof,
Quoted 2 lines · Krzysztof Kozlowski
platform_get_irq()returns-ERRNOon error. In such case comparison to 0 would pass the check.
platform_get_irq() is a bit of a mess. Historically we allowed defining interrupt resource with r->start == 0 and for such cases non-OF non-ACPI code will return 0 from platform_get_irq() to indicate that IRQ is not assigned.
We either need to stop doing this in platform_get_irq(), or the conditions in this patch and followups should be "irq <= 0" and we need to make sure we do not accidentally return 0 from probe ...
Thanks.
Signature · 1 line
Dmitry
Quoted 7 lines · Dmitry Torokhov
Hi Krzysztof,
Quoted 2 lines · Krzysztof Kozlowski
platform_get_irq()returns-ERRNOon error. In such case comparison to 0 would pass the check.
Quoted 8 lines
platform_get_irq()is a bit of a mess. Historically we allowed defining interrupt resource withr->start== 0 and for such cases non-OF non-ACPI code will return 0 fromplatform_get_irq()to indicate that IRQ is not assigned.We either need to stop doing this in
platform_get_irq(), or the conditions in this patch and followups should be "irq <= 0" and we need to make sure we do not accidentally return 0 from probe ...
Hi,
It's then contradictory to platform_get_irq documentation which explicitly says - zero will not be returned on error. This was also clarified in commit e330b9a6bb35 ("platform: don't return 0 from platform_get_irq[_byname]() on error").
As I understood the input drivers code, they check for errors so the coe in my patch is correct. Any "<=0" is not correct with current documentation and implementation.
Best regards,
Krzysztof
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Dmitry Torokhov
maintainerRe: [PATCH v2 2/4] Input: omap4-keypad - Fix handling of platform_get_irq() error
In reply to Krzysztof KozlowskiQuoted 19 lines · Krzysztof Kozlowski
platform_get_irq()returns-ERRNOon error. In such case comparison to 0 would pass the check.Fixes f3a1ba60dbdb ("Input: omap4-keypad - use platform device helpers")Signed-off-by Krzysztof Kozlowski <[email protected]>---
Changes since v1:
1. None--- drivers/input/keyboard/omap4-keypad.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/input/keyboard/omap4-keypad.c +0
-0
drivers/input/keyboard/omap4-keypad.c static int omap4_keypad_probe(struct platform_device *pdev) · line 244
Quoted 9 lines
drivers/input/keyboard/omap4-keypad.c +2
-4@@ -240,10 +240,8 @@ static int omap4_keypad_probe(struct platform_device *pdev) } irq =platform_get_irq (pdev,0 ); -if (!irq) { -dev_err (&pdev->dev,"no keyboard irq assigned\n" ); -return -EINVAL ; - } +if (irq <0 ) +return -irq;
You must have meant just "irq", right?
Quoted 6 lines
drivers/input/keyboard/omap4-keypad.c +0
-0keypad_data =kzalloc (sizeof (struct omap4_keypad ),GFP_KERNEL );if (!keypad_data) {Signature · 1 line
2.17.1
Signature · 1 line
Dmitry
Dmitry Torokhov
maintainerQuoted 17 lines · Krzysztof Kozlowski
Quoted 7 lines · Dmitry Torokhov
Hi Krzysztof,
Quoted 2 lines · Krzysztof Kozlowski
platform_get_irq()returns-ERRNOon error. In such case comparison to 0 would pass the check.Quoted 8 lines
platform_get_irq()is a bit of a mess. Historically we allowed defining interrupt resource withr->start== 0 and for such cases non-OF non-ACPI code will return 0 fromplatform_get_irq()to indicate that IRQ is not assigned.We either need to stop doing this in
platform_get_irq(), or the conditions in this patch and followups should be "irq <= 0" and we need to make sure we do not accidentally return 0 from probe ...
Quoted 6 lines
Hi,
It's then contradictory to
platform_get_irqdocumentation which explicitly says - zero will not be returned on error. This was also clarified in commite330b9a6bb35("platform: don't return 0 from platform_get_irq[_byname]() on error").
It was for OF/ACPI, but not for resources described via DEFINE_RES_IRQ or other means. However I see we added a big fat WARN_ON() in case if we end up returning 0 still, so I will be applying your patches.
Thanks.
Signature · 1 line
Dmitry
Dmitry Torokhov
maintainerRe: [PATCH v2 4/4] Input: sun4i-ps2 - Fix handling of platform_get_irq() error
In reply to Krzysztof KozlowskiQuoted 19 lines · Krzysztof Kozlowski
platform_get_irq()returns-ERRNOon 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 <[email protected]>---
Changes since v1:
1. None--- drivers/input/serio/sun4i-ps2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/input/serio/sun4i-ps2.c +0
-0
drivers/input/serio/sun4i-ps2.c static int sun4i_ps2_probe(struct platform_device *pdev) · line 268
Quoted 7 lines
drivers/input/serio/sun4i-ps2.c +1
-3@@ -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.
Quoted 7 lines
drivers/input/serio/sun4i-ps2.c +1
-0+ error = irq; goto err_disable_clk; }Signature · 1 line
2.17.1
Thanks.
Signature · 1 line
Dmitry
Re: [PATCH v2 2/4] Input: omap4-keypad - Fix handling of platform_get_irq() error
In reply to Dmitry TorokhovQuoted 23 lines · Dmitry Torokhov
Quoted 21 lines · Krzysztof Kozlowski
platform_get_irq()returns-ERRNOon error. In such case comparison to 0 would pass the check.Fixes f3a1ba60dbdb ("Input: omap4-keypad - use platform device helpers")Signed-off-by Krzysztof Kozlowski <[email protected]>---
Changes since v1:
1. None--- drivers/input/keyboard/omap4-keypad.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/input/keyboard/omap4-keypad.c +0
-0@@ -240,10 +240,8 @@ static int omap4_keypad_probe(struct platform_device *pdev) }
Quoted 9 lines
drivers/input/keyboard/omap4-keypad.c static int omap4_keypad_probe(struct platform_device *pdev) · line 244
Quoted 7 lines
drivers/input/keyboard/omap4-keypad.c +2
-4irq =platform_get_irq (pdev,0 ); -if (!irq) { -dev_err (&pdev->dev,"no keyboard irq assigned\n" ); -return -EINVAL ; - } +if (irq <0 ) +return -irq;You must have meant just "irq", right?
Damn it, of course. I'll send a v2 for this.
Best regards,
Krzysztof
Re: [PATCH v2 4/4] Input: sun4i-ps2 - Fix handling of platform_get_irq() error
In reply to Dmitry TorokhovQuoted 22 lines · Dmitry Torokhov
Quoted 20 lines · Krzysztof Kozlowski
platform_get_irq()returns-ERRNOon 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 <[email protected]>---
Changes since v1:
1. None--- drivers/input/serio/sun4i-ps2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/input/serio/sun4i-ps2.c +0
-0@@ -265,9 +265,8 @@ static int sun4i_ps2_probe(struct platform_device *pdev)
Quoted 9 lines
drivers/input/serio/sun4i-ps2.c static int sun4i_ps2_probe(struct platform_device *pdev) · line 268
Quoted 6 lines
drivers/input/serio/sun4i-ps2.c +1
-3/* 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->irqwhich 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
Dmitry Torokhov
maintainerRe: [PATCH v2 2/4] Input: omap4-keypad - Fix handling of platform_get_irq() error
In reply to Krzysztof KozlowskiQuoted 35 lines · Krzysztof Kozlowski
Quoted 23 lines · Dmitry Torokhov
Quoted 21 lines · Krzysztof Kozlowski
platform_get_irq()returns-ERRNOon error. In such case comparison to 0 would pass the check.Fixes f3a1ba60dbdb ("Input: omap4-keypad - use platform device helpers")Signed-off-by Krzysztof Kozlowski <[email protected]>---
Changes since v1:
1. None--- drivers/input/keyboard/omap4-keypad.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/input/keyboard/omap4-keypad.c +0
-0@@ -240,10 +240,8 @@ static int omap4_keypad_probe(struct platform_device *pdev) }Quoted 9 lines
drivers/input/keyboard/omap4-keypad.c static int omap4_keypad_probe(struct platform_device *pdev) · line 244
Quoted 7 lines
drivers/input/keyboard/omap4-keypad.c +2
-4irq =platform_get_irq (pdev,0 ); -if (!irq) { -dev_err (&pdev->dev,"no keyboard irq assigned\n" ); -return -EINVAL ; - } +if (irq <0 ) +return -irq;You must have meant just "irq", right?
Quoted 1 line
Damn it, of course. I'll send a v2 for this.
It's fine, I can fix it up locally.
Thanks.
Signature · 1 line
Dmitry