* [PATCH] net: stmmac: loongson1: Use dev_err_probe()
@ 2026-06-15 12:24 Keguang Zhang via B4 Relay
2026-06-16 23:42 ` Jacob Keller
0 siblings, 1 reply; 5+ messages in thread
From: Keguang Zhang via B4 Relay @ 2026-06-15 12:24 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue
Cc: linux-mips, netdev, linux-stm32, linux-arm-kernel, linux-kernel,
Keguang Zhang
From: Keguang Zhang <keguang.zhang@gmail.com>
Use dev_err_probe() for the missing match data case to simplify
error handling.
Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
index de9aba756aac..ec34adb63f61 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
@@ -176,10 +176,8 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
"Unable to find syscon\n");
data = of_device_get_match_data(&pdev->dev);
- if (!data) {
- dev_err(&pdev->dev, "No of match data provided\n");
- return -EINVAL;
- }
+ if (!data)
+ return dev_err_probe(&pdev->dev, -EINVAL, "No of match data provided\n");
dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
if (!dwmac)
---
base-commit: ec039126b7fac4e3af35ebccaa7c6f9b6875ba81
change-id: 20260602-dwmac-loongson1-5e1b9dfc3c62
Best regards,
--
Keguang Zhang <keguang.zhang@gmail.com>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net: stmmac: loongson1: Use dev_err_probe()
2026-06-15 12:24 [PATCH] net: stmmac: loongson1: Use dev_err_probe() Keguang Zhang via B4 Relay
@ 2026-06-16 23:42 ` Jacob Keller
2026-06-17 20:54 ` Jakub Kicinski
0 siblings, 1 reply; 5+ messages in thread
From: Jacob Keller @ 2026-06-16 23:42 UTC (permalink / raw)
To: keguang.zhang, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue
Cc: linux-mips, netdev, linux-stm32, linux-arm-kernel, linux-kernel
On 6/15/2026 5:24 AM, Keguang Zhang via B4 Relay wrote:
> From: Keguang Zhang <keguang.zhang@gmail.com>
>
> Use dev_err_probe() for the missing match data case to simplify
> error handling.
>
> Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> ---
At first I recalled that dev_err_probe does strange things with
-EPROBE_DEFER. From the documentation for dev_err_probe:
> * @dev: the pointer to the struct device
> * @err: error value to test
> * @fmt: printf-style format string
> * @...: arguments as specified in the format string
> *
> * This helper implements common pattern present in probe functions for error
> * checking: print debug or error message depending if the error value is
> * -EPROBE_DEFER and propagate error upwards.
> * In case of -EPROBE_DEFER it sets also defer probe reason, which can be
> * checked later by reading devices_deferred debugfs attribute.
> * It replaces the following code sequence::
> *
> * if (err != -EPROBE_DEFER)
> * dev_err(dev, ...);
> * else
> * dev_dbg(dev, ...);
> * return err;
> *
> * with::
> *
> * return dev_err_probe(dev, err, ...);
> *
> * Using this helper in your probe function is totally fine even if @err
> * is known to never be -EPROBE_DEFER.
> * The benefit compared to a normal dev_err() is the standardized format
> * of the error code, which is emitted symbolically (i.e. you get "EAGAIN"
> * instead of "-35"), and having the error code returned allows more
> * compact error paths.
> *
> * Returns @err.
> */
I guess even without -EPROBE_DEFER this is still acceptable. The change
seems fine, if a bit of a minor cleanup. However, net-next is closed,
and this is definitely not a bug-fix worthy of net. This does have the
added benefit of
I'd probably also argue this may go against the desired goals of
net-next with only wanting such cleanups when in the context of other
larger work. Of course that decision ultimately belongs to the maintainers.
You can add my reviewed-by when/if you resubmit when net-next re-opens:
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
> index de9aba756aac..ec34adb63f61 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
> @@ -176,10 +176,8 @@ static int ls1x_dwmac_probe(struct platform_device *pdev)
> "Unable to find syscon\n");
>
> data = of_device_get_match_data(&pdev->dev);
> - if (!data) {
> - dev_err(&pdev->dev, "No of match data provided\n");
> - return -EINVAL;
> - }
> + if (!data)
> + return dev_err_probe(&pdev->dev, -EINVAL, "No of match data provided\n");
>
> dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
> if (!dwmac)
>
> ---
> base-commit: ec039126b7fac4e3af35ebccaa7c6f9b6875ba81
> change-id: 20260602-dwmac-loongson1-5e1b9dfc3c62
>
> Best regards,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: stmmac: loongson1: Use dev_err_probe()
2026-06-16 23:42 ` Jacob Keller
@ 2026-06-17 20:54 ` Jakub Kicinski
2026-06-17 21:26 ` Jacob Keller
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2026-06-17 20:54 UTC (permalink / raw)
To: Jacob Keller
Cc: keguang.zhang, Andrew Lunn, David S. Miller, Eric Dumazet,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, linux-mips,
netdev, linux-stm32, linux-arm-kernel, linux-kernel
On Tue, 16 Jun 2026 16:42:18 -0700 Jacob Keller wrote:
> I'd probably also argue this may go against the desired goals of
> net-next with only wanting such cleanups when in the context of other
> larger work. Of course that decision ultimately belongs to the maintainers.
Yes, feeding const EINVAL into dev_err_probe() is pretty pointless
so if this helps it's just by "saving" 2 LoC. I'm not sure it's worth
it even in context of larger work, let along by itself.
--
pw-bot: reject
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: stmmac: loongson1: Use dev_err_probe()
2026-06-17 20:54 ` Jakub Kicinski
@ 2026-06-17 21:26 ` Jacob Keller
2026-06-17 22:07 ` Jakub Kicinski
0 siblings, 1 reply; 5+ messages in thread
From: Jacob Keller @ 2026-06-17 21:26 UTC (permalink / raw)
To: Jakub Kicinski
Cc: keguang.zhang, Andrew Lunn, David S. Miller, Eric Dumazet,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, linux-mips,
netdev, linux-stm32, linux-arm-kernel, linux-kernel
On 6/17/2026 1:54 PM, Jakub Kicinski wrote:
> On Tue, 16 Jun 2026 16:42:18 -0700 Jacob Keller wrote:
>> I'd probably also argue this may go against the desired goals of
>> net-next with only wanting such cleanups when in the context of other
>> larger work. Of course that decision ultimately belongs to the maintainers.
>
> Yes, feeding const EINVAL into dev_err_probe() is pretty pointless
> so if this helps it's just by "saving" 2 LoC. I'm not sure it's worth
> it even in context of larger work, let along by itself.
It does claim that it has benefit since you get the error code emitted
symbolically. But we have %pe for that. I wonder if dev_err_probe
predates %pe?
Per commit: 532888a59505 ("driver core: Better advertise dev_err_probe()"):
> Describing the usage of dev_err_probe() as being (only?) "deemed
> acceptable" has a bad connotation. In fact dev_err_probe() fulfills
> three tasks:
>
> - handling of EPROBE_DEFER (even more than degrading to dev_dbg())
> - symbolic output of the error code
> - return err for compact error code paths
This was in 2023.. %pe was introduced in 2019, so I guess %pe is even older.
I personally find dev_err_probe acceptable and might find it nice when
writing new code, but I agree its not really meaningful gain to refactor
existing legacy code.
Anyways, all this to say in too many words: this patch doesn't seem to
have much value for netdev.
Thanks,
Jake
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: stmmac: loongson1: Use dev_err_probe()
2026-06-17 21:26 ` Jacob Keller
@ 2026-06-17 22:07 ` Jakub Kicinski
0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2026-06-17 22:07 UTC (permalink / raw)
To: Jacob Keller
Cc: keguang.zhang, Andrew Lunn, David S. Miller, Eric Dumazet,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, linux-mips,
netdev, linux-stm32, linux-arm-kernel, linux-kernel
On Wed, 17 Jun 2026 14:26:25 -0700 Jacob Keller wrote:
> It does claim that it has benefit since you get the error code emitted
> symbolically. But we have %pe for that. I wonder if dev_err_probe
> predates %pe?
I'd argue
No of match data provided: -EINVAL
is more confusing than just:
No of match data provided
the EINVAL is meaningless and hardcoded in this case?
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-17 22:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15 12:24 [PATCH] net: stmmac: loongson1: Use dev_err_probe() Keguang Zhang via B4 Relay
2026-06-16 23:42 ` Jacob Keller
2026-06-17 20:54 ` Jakub Kicinski
2026-06-17 21:26 ` Jacob Keller
2026-06-17 22:07 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox