diff mbox series

[v2] net: mv643xx_eth: process retval from of_get_mac_address

Message ID 20220223142337.41757-1-maukka@ext.kapsi.fi (mailing list archive)
State Accepted
Commit 42404d8f1c01861b22ccfa1d70f950242720ae57
Delegated to: Netdev Maintainers
Headers show
Series [v2] net: mv643xx_eth: process retval from of_get_mac_address | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
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: 6 this patch: 6
netdev/cc_maintainers success CCed 4 of 4 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/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 6 this patch: 6
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 48 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Mauri Sandberg Feb. 23, 2022, 2:23 p.m. UTC
Obtaining a MAC address may be deferred in cases when the MAC is stored
in an NVMEM block, for example, and it may not be ready upon the first
retrieval attempt and return EPROBE_DEFER.

It is also possible that a port that does not rely on NVMEM has been
already created when getting the defer request. Thus, also the resources
allocated previously must be freed when doing a roll-back.

Signed-off-by: Mauri Sandberg <maukka@ext.kapsi.fi>
Cc: Andrew Lunn <andrew@lunn.ch>
---
v1 -> v2
 - escalate all error values from of_get_mac_address()
 - move mv643xx_eth_shared_of_remove() before
   mv643xx_eth_shared_of_probe()
 - release all resources potentially allocated for previous port nodes
 - update commit title and message
---
 drivers/net/ethernet/marvell/mv643xx_eth.c | 24 +++++++++++++---------
 1 file changed, 14 insertions(+), 10 deletions(-)


base-commit: cfb92440ee71adcc2105b0890bb01ac3cddb8507

Comments

Jakub Kicinski Feb. 24, 2022, 4:57 p.m. UTC | #1
On Wed, 23 Feb 2022 16:23:37 +0200 Mauri Sandberg wrote:
> Obtaining a MAC address may be deferred in cases when the MAC is stored
> in an NVMEM block, for example, and it may not be ready upon the first
> retrieval attempt and return EPROBE_DEFER.
> 
> It is also possible that a port that does not rely on NVMEM has been
> already created when getting the defer request. Thus, also the resources
> allocated previously must be freed when doing a roll-back.
> 
> Signed-off-by: Mauri Sandberg <maukka@ext.kapsi.fi>
> Cc: Andrew Lunn <andrew@lunn.ch>

While we wait for Andrew's ack, is this the correct fixes tag?

Fixes: 76723bca2802 ("net: mv643xx_eth: add DT parsing support")
Andrew Lunn Feb. 24, 2022, 5:43 p.m. UTC | #2
On Thu, Feb 24, 2022 at 08:57:54AM -0800, Jakub Kicinski wrote:
> On Wed, 23 Feb 2022 16:23:37 +0200 Mauri Sandberg wrote:
> > Obtaining a MAC address may be deferred in cases when the MAC is stored
> > in an NVMEM block, for example, and it may not be ready upon the first
> > retrieval attempt and return EPROBE_DEFER.
> > 
> > It is also possible that a port that does not rely on NVMEM has been
> > already created when getting the defer request. Thus, also the resources
> > allocated previously must be freed when doing a roll-back.
> > 
> > Signed-off-by: Mauri Sandberg <maukka@ext.kapsi.fi>
> > Cc: Andrew Lunn <andrew@lunn.ch>
> 
> While we wait for Andrew's ack, is this the correct fixes tag?
> 
> Fixes: 76723bca2802 ("net: mv643xx_eth: add DT parsing support")


Yes, that looks correct. The history around here is convoluted, and
anybody trying to backport that far is going to need a few different
versions.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
patchwork-bot+netdevbpf@kernel.org Feb. 24, 2022, 6:20 p.m. UTC | #3
Hello:

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

On Wed, 23 Feb 2022 16:23:37 +0200 you wrote:
> Obtaining a MAC address may be deferred in cases when the MAC is stored
> in an NVMEM block, for example, and it may not be ready upon the first
> retrieval attempt and return EPROBE_DEFER.
> 
> It is also possible that a port that does not rely on NVMEM has been
> already created when getting the defer request. Thus, also the resources
> allocated previously must be freed when doing a roll-back.
> 
> [...]

Here is the summary with links:
  - [v2] net: mv643xx_eth: process retval from of_get_mac_address
    https://git.kernel.org/netdev/net/c/42404d8f1c01

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 105247582684..143ca8be5eb5 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2704,6 +2704,16 @@  MODULE_DEVICE_TABLE(of, mv643xx_eth_shared_ids);
 
 static struct platform_device *port_platdev[3];
 
+static void mv643xx_eth_shared_of_remove(void)
+{
+	int n;
+
+	for (n = 0; n < 3; n++) {
+		platform_device_del(port_platdev[n]);
+		port_platdev[n] = NULL;
+	}
+}
+
 static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
 					  struct device_node *pnp)
 {
@@ -2740,7 +2750,9 @@  static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
 		return -EINVAL;
 	}
 
-	of_get_mac_address(pnp, ppd.mac_addr);
+	ret = of_get_mac_address(pnp, ppd.mac_addr);
+	if (ret)
+		return ret;
 
 	mv643xx_eth_property(pnp, "tx-queue-size", ppd.tx_queue_size);
 	mv643xx_eth_property(pnp, "tx-sram-addr", ppd.tx_sram_addr);
@@ -2804,21 +2816,13 @@  static int mv643xx_eth_shared_of_probe(struct platform_device *pdev)
 		ret = mv643xx_eth_shared_of_add_port(pdev, pnp);
 		if (ret) {
 			of_node_put(pnp);
+			mv643xx_eth_shared_of_remove();
 			return ret;
 		}
 	}
 	return 0;
 }
 
-static void mv643xx_eth_shared_of_remove(void)
-{
-	int n;
-
-	for (n = 0; n < 3; n++) {
-		platform_device_del(port_platdev[n]);
-		port_platdev[n] = NULL;
-	}
-}
 #else
 static inline int mv643xx_eth_shared_of_probe(struct platform_device *pdev)
 {