* [PATCH -next] net: hisilicon: fix the return value handle and remove redundant netdev_err() for platform_get_irq()
@ 2023-07-31 7:38 Ruan Jinjie
2023-07-31 20:01 ` Jesse Brandeburg
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Ruan Jinjie @ 2023-07-31 7:38 UTC (permalink / raw)
To: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni, netdev,
linux-kernel
Cc: ruanjinjie
There is no possible for platform_get_irq() to return 0
and the return value of platform_get_irq() is more sensible
to show the error reason.
And there is no need to call the netdev_err() function directly to print
a custom message when handling an error from platform_get_irq() function as
it is going to display an appropriate error message in case of a failure.
Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
---
drivers/net/ethernet/hisilicon/hip04_eth.c | 4 ++--
drivers/net/ethernet/hisilicon/hisi_femac.c | 4 ++--
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 5 ++---
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c
index 50c3f5d6611f..ecf92a5d56bb 100644
--- a/drivers/net/ethernet/hisilicon/hip04_eth.c
+++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
@@ -960,8 +960,8 @@ static int hip04_mac_probe(struct platform_device *pdev)
}
irq = platform_get_irq(pdev, 0);
- if (irq <= 0) {
- ret = -EINVAL;
+ if (irq < 0) {
+ ret = irq;
goto init_fail;
}
diff --git a/drivers/net/ethernet/hisilicon/hisi_femac.c b/drivers/net/ethernet/hisilicon/hisi_femac.c
index ce2571c16e43..cb7b0293fe85 100644
--- a/drivers/net/ethernet/hisilicon/hisi_femac.c
+++ b/drivers/net/ethernet/hisilicon/hisi_femac.c
@@ -862,8 +862,8 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)
goto out_disconnect_phy;
ndev->irq = platform_get_irq(pdev, 0);
- if (ndev->irq <= 0) {
- ret = -ENODEV;
+ if (ndev->irq < 0) {
+ ret = ndev->irq;
goto out_disconnect_phy;
}
diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index f867e9531117..26d22bb04b87 100644
--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
@@ -1206,9 +1206,8 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
}
ndev->irq = platform_get_irq(pdev, 0);
- if (ndev->irq <= 0) {
- netdev_err(ndev, "No irq resource\n");
- ret = -EINVAL;
+ if (ndev->irq < 0) {
+ ret = ndev->irq;
goto out_phy_node;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH -next] net: hisilicon: fix the return value handle and remove redundant netdev_err() for platform_get_irq()
2023-07-31 7:38 [PATCH -next] net: hisilicon: fix the return value handle and remove redundant netdev_err() for platform_get_irq() Ruan Jinjie
@ 2023-07-31 20:01 ` Jesse Brandeburg
2023-08-01 21:43 ` Jakub Kicinski
2023-08-02 19:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Jesse Brandeburg @ 2023-07-31 20:01 UTC (permalink / raw)
To: Ruan Jinjie, yisen.zhuang, salil.mehta, davem, edumazet, kuba,
pabeni, netdev, linux-kernel
On 7/31/2023 12:38 AM, Ruan Jinjie wrote:
> There is no possible for platform_get_irq() to return 0
> and the return value of platform_get_irq() is more sensible
> to show the error reason.
>
> And there is no need to call the netdev_err() function directly to print
> a custom message when handling an error from platform_get_irq() function as
> it is going to display an appropriate error message in case of a failure.
>
> Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Makes sense
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -next] net: hisilicon: fix the return value handle and remove redundant netdev_err() for platform_get_irq()
2023-07-31 7:38 [PATCH -next] net: hisilicon: fix the return value handle and remove redundant netdev_err() for platform_get_irq() Ruan Jinjie
2023-07-31 20:01 ` Jesse Brandeburg
@ 2023-08-01 21:43 ` Jakub Kicinski
2023-08-02 6:00 ` Dan Carpenter
2023-08-02 19:10 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2023-08-01 21:43 UTC (permalink / raw)
To: Dan Carpenter
Cc: Ruan Jinjie, yisen.zhuang, salil.mehta, davem, edumazet, pabeni,
netdev, linux-kernel
On Mon, 31 Jul 2023 15:38:58 +0800 Ruan Jinjie wrote:
> There is no possible for platform_get_irq() to return 0
> and the return value of platform_get_irq() is more sensible
> to show the error reason.
>
> And there is no need to call the netdev_err() function directly to print
> a custom message when handling an error from platform_get_irq() function as
> it is going to display an appropriate error message in case of a failure.
>
> Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Dan, with the sample of one patch from you I just applied I induce
that treating 0 as error and returning a -EINVAL in that case may
be preferable here?
> diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c
> index 50c3f5d6611f..ecf92a5d56bb 100644
> --- a/drivers/net/ethernet/hisilicon/hip04_eth.c
> +++ b/drivers/net/ethernet/hisilicon/hip04_eth.c
> @@ -960,8 +960,8 @@ static int hip04_mac_probe(struct platform_device *pdev)
> }
>
> irq = platform_get_irq(pdev, 0);
> - if (irq <= 0) {
> - ret = -EINVAL;
> + if (irq < 0) {
> + ret = irq;
> goto init_fail;
> }
>
> diff --git a/drivers/net/ethernet/hisilicon/hisi_femac.c b/drivers/net/ethernet/hisilicon/hisi_femac.c
> index ce2571c16e43..cb7b0293fe85 100644
> --- a/drivers/net/ethernet/hisilicon/hisi_femac.c
> +++ b/drivers/net/ethernet/hisilicon/hisi_femac.c
> @@ -862,8 +862,8 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)
> goto out_disconnect_phy;
>
> ndev->irq = platform_get_irq(pdev, 0);
> - if (ndev->irq <= 0) {
> - ret = -ENODEV;
> + if (ndev->irq < 0) {
> + ret = ndev->irq;
> goto out_disconnect_phy;
> }
>
> diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> index f867e9531117..26d22bb04b87 100644
> --- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> +++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
> @@ -1206,9 +1206,8 @@ static int hix5hd2_dev_probe(struct platform_device *pdev)
> }
>
> ndev->irq = platform_get_irq(pdev, 0);
> - if (ndev->irq <= 0) {
> - netdev_err(ndev, "No irq resource\n");
> - ret = -EINVAL;
> + if (ndev->irq < 0) {
> + ret = ndev->irq;
> goto out_phy_node;
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -next] net: hisilicon: fix the return value handle and remove redundant netdev_err() for platform_get_irq()
2023-08-01 21:43 ` Jakub Kicinski
@ 2023-08-02 6:00 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2023-08-02 6:00 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Ruan Jinjie, yisen.zhuang, salil.mehta, davem, edumazet, pabeni,
netdev, linux-kernel
On Tue, Aug 01, 2023 at 02:43:47PM -0700, Jakub Kicinski wrote:
> On Mon, 31 Jul 2023 15:38:58 +0800 Ruan Jinjie wrote:
> > There is no possible for platform_get_irq() to return 0
> > and the return value of platform_get_irq() is more sensible
> > to show the error reason.
> >
> > And there is no need to call the netdev_err() function directly to print
> > a custom message when handling an error from platform_get_irq() function as
> > it is going to display an appropriate error message in case of a failure.
> >
> > Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
>
> Dan, with the sample of one patch from you I just applied I induce
> that treating 0 as error and returning a -EINVAL in that case may
> be preferable here?
This patch is correct.
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
The comments for platform_get_irq() say it returns negatives on error
and that's also how the code is implemented.
Is zero an error code? Historically, a lot of IRQ functions returned
0 on error and some of those haven't been replaced with new functions
that return negative error codes. irq_of_parse_and_map() is an example
of this. I've been meaning to make a complete list but apparently
that's the only one Smatch checks for.
Is zero a valid IRQ? In upstream code the answer is no and it never
will be. In this code the platform_get_irq_optional() will trigger a
warning for that.
if (WARN(!ret, "0 is an invalid IRQ number\n"))
However there are some old out of tree arches where zero is a valid IRQ.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -next] net: hisilicon: fix the return value handle and remove redundant netdev_err() for platform_get_irq()
2023-07-31 7:38 [PATCH -next] net: hisilicon: fix the return value handle and remove redundant netdev_err() for platform_get_irq() Ruan Jinjie
2023-07-31 20:01 ` Jesse Brandeburg
2023-08-01 21:43 ` Jakub Kicinski
@ 2023-08-02 19:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-02 19:10 UTC (permalink / raw)
To: Ruan Jinjie
Cc: yisen.zhuang, salil.mehta, davem, edumazet, kuba, pabeni, netdev,
linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 31 Jul 2023 15:38:58 +0800 you wrote:
> There is no possible for platform_get_irq() to return 0
> and the return value of platform_get_irq() is more sensible
> to show the error reason.
>
> And there is no need to call the netdev_err() function directly to print
> a custom message when handling an error from platform_get_irq() function as
> it is going to display an appropriate error message in case of a failure.
>
> [...]
Here is the summary with links:
- [-next] net: hisilicon: fix the return value handle and remove redundant netdev_err() for platform_get_irq()
https://git.kernel.org/netdev/net-next/c/ae1d60c41e58
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-02 19:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-31 7:38 [PATCH -next] net: hisilicon: fix the return value handle and remove redundant netdev_err() for platform_get_irq() Ruan Jinjie
2023-07-31 20:01 ` Jesse Brandeburg
2023-08-01 21:43 ` Jakub Kicinski
2023-08-02 6:00 ` Dan Carpenter
2023-08-02 19:10 ` patchwork-bot+netdevbpf
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).