The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH net] net: ethernet: sun4i-emac: Fix IRQ error handling
@ 2026-08-24 10:09 phucduc.bui
  2026-08-25 10:32 ` Andre Przywara
  0 siblings, 1 reply; 3+ messages in thread
From: phucduc.bui @ 2026-08-24 10:09 UTC (permalink / raw)
  To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Chen-Yu Tsai, Jernej Skrabec
  Cc: Samuel Holland, Linus Walleij, Kees Cook, Bartosz Golaszewski,
	Arnd Bergmann, Stefan Roese, Maxime Ripard, linux-arm-kernel,
	linux-sunxi, linux-kernel, netdev, bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

irq_of_parse_and_map() returns 0 when parsing or mapping an IRQ fails.
The current code checks for -ENXIO and therefore does not detect the
failure.

Check for a zero return value and convert it to -ENXIO.

Fixes: 492205050d77 ("net: Add EMAC ethernet driver found on Allwinner A10 SoC's")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 drivers/net/ethernet/allwinner/sun4i-emac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 42174249ef61..942454e29488 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -996,9 +996,9 @@ static int emac_probe(struct platform_device *pdev)
 	/* fill in parameters for net-dev structure */
 	ndev->base_addr = (unsigned long)db->membase;
 	ndev->irq = irq_of_parse_and_map(np, 0);
-	if (ndev->irq == -ENXIO) {
+	if (!ndev->irq) {
 		netdev_err(ndev, "No irq resource\n");
-		ret = ndev->irq;
+		ret = -ENXIO;
 		goto out_iounmap;
 	}
 
-- 
2.43.0


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

* Re: [PATCH net] net: ethernet: sun4i-emac: Fix IRQ error handling
  2026-08-24 10:09 [PATCH net] net: ethernet: sun4i-emac: Fix IRQ error handling phucduc.bui
@ 2026-08-25 10:32 ` Andre Przywara
  2026-08-25 10:44   ` Bui Duc Phuc
  0 siblings, 1 reply; 3+ messages in thread
From: Andre Przywara @ 2026-08-25 10:32 UTC (permalink / raw)
  To: phucduc.bui, Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Chen-Yu Tsai, Jernej Skrabec
  Cc: Samuel Holland, Linus Walleij, Kees Cook, Bartosz Golaszewski,
	Arnd Bergmann, Stefan Roese, Maxime Ripard, linux-arm-kernel,
	linux-sunxi, linux-kernel, netdev

Hi,

On 8/24/26 12:09, phucduc.bui@gmail.com wrote:
> From: bui duc phuc <phucduc.bui@gmail.com>
> 
> irq_of_parse_and_map() returns 0 when parsing or mapping an IRQ fails.
> The current code checks for -ENXIO and therefore does not detect the
> failure.
> 
> Check for a zero return value and convert it to -ENXIO.

Yes, the return value is the IRQ number, or 0 in case of a missing IRQ.

> Fixes: 492205050d77 ("net: Add EMAC ethernet driver found on Allwinner A10 SoC's")
> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Thanks,
Andre

> ---
>   drivers/net/ethernet/allwinner/sun4i-emac.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
> index 42174249ef61..942454e29488 100644
> --- a/drivers/net/ethernet/allwinner/sun4i-emac.c
> +++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
> @@ -996,9 +996,9 @@ static int emac_probe(struct platform_device *pdev)
>   	/* fill in parameters for net-dev structure */
>   	ndev->base_addr = (unsigned long)db->membase;
>   	ndev->irq = irq_of_parse_and_map(np, 0);
> -	if (ndev->irq == -ENXIO) {
> +	if (!ndev->irq) {
>   		netdev_err(ndev, "No irq resource\n");
> -		ret = ndev->irq;
> +		ret = -ENXIO;
>   		goto out_iounmap;
>   	}
>   


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

* Re: [PATCH net] net: ethernet: sun4i-emac: Fix IRQ error handling
  2026-08-25 10:32 ` Andre Przywara
@ 2026-08-25 10:44   ` Bui Duc Phuc
  0 siblings, 0 replies; 3+ messages in thread
From: Bui Duc Phuc @ 2026-08-25 10:44 UTC (permalink / raw)
  To: Andre Przywara
  Cc: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Linus Walleij,
	Kees Cook, Bartosz Golaszewski, Arnd Bergmann, Stefan Roese,
	Maxime Ripard, linux-arm-kernel, linux-sunxi, linux-kernel,
	netdev

Hi Andre,

Thank you for your review and the Reviewed-by tag.

>
> Reviewed-by: Andre Przywara <andre.przywara@arm.com>
>

Best regards,
Phuc

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

end of thread, other threads:[~2026-08-25 10:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24 10:09 [PATCH net] net: ethernet: sun4i-emac: Fix IRQ error handling phucduc.bui
2026-08-25 10:32 ` Andre Przywara
2026-08-25 10:44   ` Bui Duc Phuc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox