diff mbox series

[net] net: lan966x: check devm_of_phy_get() for -EDEFER_PROBE

Message ID 20220525231239.1307298-1-michael@walle.cc (mailing list archive)
State Accepted
Commit b58cdd4388b1d8f5bee9f5a3897a7e780d1eaa48
Delegated to: Netdev Maintainers
Headers show
Series [net] net: lan966x: check devm_of_phy_get() for -EDEFER_PROBE | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Walle May 25, 2022, 11:12 p.m. UTC
At the moment, if devm_of_phy_get() returns an error the serdes
simply isn't set. While it is bad to ignore an error in general, there
is a particular bug that network isn't working if the serdes driver is
compiled as a module. In that case, devm_of_phy_get() returns
-EDEFER_PROBE and the error is silently ignored.

The serdes is optional, it is not there if the port is using RGMII, in
which case devm_of_phy_get() returns -ENODEV. Rearrange the error
handling so that -ENODEV will be handled but other error codes will
abort the probing.

Fixes: d28d6d2e37d1 ("net: lan966x: add port module support")
Signed-off-by: Michael Walle <michael@walle.cc>
---
 drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org May 27, 2022, 4:48 a.m. UTC | #1
Hello:

This patch was applied to bpf/bpf.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 26 May 2022 01:12:39 +0200 you wrote:
> At the moment, if devm_of_phy_get() returns an error the serdes
> simply isn't set. While it is bad to ignore an error in general, there
> is a particular bug that network isn't working if the serdes driver is
> compiled as a module. In that case, devm_of_phy_get() returns
> -EDEFER_PROBE and the error is silently ignored.
> 
> The serdes is optional, it is not there if the port is using RGMII, in
> which case devm_of_phy_get() returns -ENODEV. Rearrange the error
> handling so that -ENODEV will be handled but other error codes will
> abort the probing.
> 
> [...]

Here is the summary with links:
  - [net] net: lan966x: check devm_of_phy_get() for -EDEFER_PROBE
    https://git.kernel.org/bpf/bpf/c/b58cdd4388b1

You are awesome, thank you!
Michael Walle May 27, 2022, 7:54 a.m. UTC | #2
> This patch was applied to bpf/bpf.git (master)

bpf tree?

-michael
Jakub Kicinski May 27, 2022, 10:52 p.m. UTC | #3
On Fri, 27 May 2022 09:54:37 +0200 Michael Walle wrote:
> > This patch was applied to bpf/bpf.git (master)  
> 
> bpf tree?

Nah, treat pw-bot like a toddler who occasionally says the darndest
things. BPF and netdev share a patchwork instance. The BPF maintainers
probably forwarded their tree around the same time I pushed this patch
to net and the bot noticed it in their tree first.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
index 6ad68b422129..5784c4161e5e 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
@@ -1120,8 +1120,13 @@  static int lan966x_probe(struct platform_device *pdev)
 		lan966x->ports[p]->fwnode = fwnode_handle_get(portnp);
 
 		serdes = devm_of_phy_get(lan966x->dev, to_of_node(portnp), NULL);
-		if (!IS_ERR(serdes))
-			lan966x->ports[p]->serdes = serdes;
+		if (PTR_ERR(serdes) == -ENODEV)
+			serdes = NULL;
+		if (IS_ERR(serdes)) {
+			err = PTR_ERR(serdes);
+			goto cleanup_ports;
+		}
+		lan966x->ports[p]->serdes = serdes;
 
 		lan966x_port_init(lan966x->ports[p]);
 	}