Re: [PATCH] net:mv643xx_eth: use platform_get_irq() instead of platform_get_resource()

From: Jakub Kicinski
Date: Wed Mar 09 2022 - 23:28:28 EST


On Wed, 9 Mar 2022 03:54:38 +0000 cgel.zte@xxxxxxxxx wrote:
> Subject: [PATCH] net:mv643xx_eth: use platform_get_irq() instead of platform_get_resource()

Add a space after "net:" please.

> It is not recommened to use platform_get_resource(pdev, IORESOURCE_IRQ)
> for requesting IRQ's resources any more, as they can be not ready yet in
> case of DT-booting.
>
> platform_get_irq() instead is a recommended way for getting IRQ even if
> it was not retrieved earlier.
>
> It also makes code simpler because we're getting "int" value right away
> and no conversion from resource to int is required.
>
> Reported-by: Zeal Robot <zealci@xxxxxxxxxx>
> Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@xxxxxxxxxx>
> ---
> drivers/net/ethernet/marvell/mv643xx_eth.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
> index 143ca8be5eb5..125d18430296 100644
> --- a/drivers/net/ethernet/marvell/mv643xx_eth.c
> +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
> @@ -3092,8 +3092,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
> struct mv643xx_eth_private *mp;
> struct net_device *dev;
> struct phy_device *phydev = NULL;
> - struct resource *res;
> - int err;
> + int err, irq;
>
> pd = dev_get_platdata(&pdev->dev);
> if (pd == NULL) {
> @@ -3189,9 +3188,9 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
> timer_setup(&mp->rx_oom, oom_timer_wrapper, 0);
>
>
> - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> - BUG_ON(!res);
> - dev->irq = res->start;
> + irq = platform_get_irq(pdev, 0);
> + BUG_ON(irq < 0);

Let's also get rid of this BUG_ON() while at it and handle the error
gracefully.

> + dev->irq = irq;
>
> dev->netdev_ops = &mv643xx_eth_netdev_ops;
>