linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] misc: atmel_tclib: fix error return code in tc_probe()
@ 2017-08-09 16:42 Gustavo A. R. Silva
  2017-08-09 22:08 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2017-08-09 16:42 UTC (permalink / raw)
  To: linux-arm-kernel

platform_get_irq() returns an error code, but the atmel_tclib driver
ignores it and always returns -EINVAL. This is not correct and,
prevents -EPROBE_DEFER from being propagated properly.

Print error message and propagate the return value of platform_get_irq
on failure.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/misc/atmel_tclib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c
index ac24a4b..c5d3449 100644
--- a/drivers/misc/atmel_tclib.c
+++ b/drivers/misc/atmel_tclib.c
@@ -112,8 +112,10 @@ static int __init tc_probe(struct platform_device *pdev)
 	unsigned int	i;
 
 	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		return -EINVAL;
+	if (irq < 0) {
+		dev_err(&pdev->dev, "Failed to get IRQ: %d\n", irq);
+		return irq;
+	}
 
 	tc = devm_kzalloc(&pdev->dev, sizeof(struct atmel_tc), GFP_KERNEL);
 	if (!tc)
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] misc: atmel_tclib: fix error return code in tc_probe()
  2017-08-09 16:42 [PATCH] misc: atmel_tclib: fix error return code in tc_probe() Gustavo A. R. Silva
@ 2017-08-09 22:08 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2017-08-09 22:08 UTC (permalink / raw)
  To: linux-arm-kernel

On 09/08/2017 at 11:42:50 -0500, Gustavo A. R. Silva wrote:
> platform_get_irq() returns an error code, but the atmel_tclib driver
> ignores it and always returns -EINVAL. This is not correct and,
> prevents -EPROBE_DEFER from being propagated properly.
> 

Which will never happen because the kernel would not reach that point if
the irqchip driver was not present. I would really love people to stop
littering perfectly working drivers with unused error strings.

> Print error message and propagate the return value of platform_get_irq
> on failure.
> 
> This issue was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>  drivers/misc/atmel_tclib.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c
> index ac24a4b..c5d3449 100644
> --- a/drivers/misc/atmel_tclib.c
> +++ b/drivers/misc/atmel_tclib.c
> @@ -112,8 +112,10 @@ static int __init tc_probe(struct platform_device *pdev)
>  	unsigned int	i;
>  
>  	irq = platform_get_irq(pdev, 0);
> -	if (irq < 0)
> -		return -EINVAL;
> +	if (irq < 0) {
> +		dev_err(&pdev->dev, "Failed to get IRQ: %d\n", irq);
> +		return irq;
> +	}
>  
>  	tc = devm_kzalloc(&pdev->dev, sizeof(struct atmel_tc), GFP_KERNEL);
>  	if (!tc)
> -- 
> 2.5.0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-09 22:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-09 16:42 [PATCH] misc: atmel_tclib: fix error return code in tc_probe() Gustavo A. R. Silva
2017-08-09 22:08 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).