Re: [PATCH net-next 1/5] net: ravb: Get rid of the temporary variable irq

From: Sergey Shtylyov
Date: Thu Feb 08 2024 - 15:44:26 EST


On 2/7/24 3:07 PM, Claudiu wrote:

> From: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx>
>
> The 4th argument of ravb_setup_irq() is used to save the IRQ number that
> will be further used by the driver code. Not all ravb_setup_irqs() calls
> need to save the IRQ number. The previous code used to pass a dummy
> variable as the 4th argument in case the IRQ is not needed for further
> usage. That is not necessary as the code from ravb_setup_irq() can detect
> by itself if the IRQ needs to be saved. Thus, get rid of the code that is
> not needed.
>
> Reported-by: Sergey Shtylyov <s.shtylyov@xxxxxx>
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx>
[...]

> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 9521cd054274..e235342e0827 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -2611,17 +2611,20 @@ static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name,
> if (!dev_name)
> return -ENOMEM;
>
> - *irq = platform_get_irq_byname(pdev, irq_name);
> + error = platform_get_irq_byname(pdev, irq_name);
> flags = 0;
> } else {
> dev_name = ndev->name;
> - *irq = platform_get_irq(pdev, 0);
> + error = platform_get_irq(pdev, 0);
> flags = IRQF_SHARED;
> }
> - if (*irq < 0)
> - return *irq;
> + if (error < 0)
> + return error;
>
> - error = devm_request_irq(dev, *irq, handler, flags, dev_name, ndev);
> + if (irq)
> + *irq = error;
> +
> + error = devm_request_irq(dev, error, handler, flags, dev_name, ndev);
> if (error)
> netdev_err(ndev, "cannot request IRQ %s\n", dev_name);
>

Thanks for addressing my IRC comment! Tho the naming seems awful. :-)
I'd suggest to add a local variable (named e.g, irq_num) and use it to
store the result of platform_get_irq[_byname]().

[...]

MBR, Sergey