All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] Revert "of: net: support NVMEM cells with MAC in text format"
@ 2022-01-11  8:12 Michael Walle
  2022-01-12  2:28 ` Jakub Kicinski
  2022-01-12 14:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Walle @ 2022-01-11  8:12 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: Rafał Miłecki, Andrew Lunn, Heiner Kallweit,
	Russell King, David S . Miller, Jakub Kicinski, Michael Walle

This reverts commit 9ed319e411915e882bb4ed99be3ae78667a70022.

We can already post process a nvmem cell value in a particular driver.
Instead of having yet another place to convert the values, the post
processing hook of the nvmem provider should be used in this case.

Signed-off-by: Michael Walle <michael@walle.cc>
---

As mentioned in [1] I think we should discuss this a bit more and revert
the patch for now before there are any users of it.

[1] https://lore.kernel.org/netdev/20211229124047.1286965-1-michael@walle.cc/

btw, now with net-next closed, should this patch have net-next or net as
the queue in the subject?

 net/core/of_net.c | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/net/core/of_net.c b/net/core/of_net.c
index 95a64c813ae5..f1a9bf7578e7 100644
--- a/net/core/of_net.c
+++ b/net/core/of_net.c
@@ -61,7 +61,7 @@ static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
 {
 	struct platform_device *pdev = of_find_device_by_node(np);
 	struct nvmem_cell *cell;
-	const void *buf;
+	const void *mac;
 	size_t len;
 	int ret;
 
@@ -78,32 +78,21 @@ static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
 	if (IS_ERR(cell))
 		return PTR_ERR(cell);
 
-	buf = nvmem_cell_read(cell, &len);
+	mac = nvmem_cell_read(cell, &len);
 	nvmem_cell_put(cell);
 
-	if (IS_ERR(buf))
-		return PTR_ERR(buf);
-
-	ret = 0;
-	if (len == ETH_ALEN) {
-		if (is_valid_ether_addr(buf))
-			memcpy(addr, buf, ETH_ALEN);
-		else
-			ret = -EINVAL;
-	} else if (len == 3 * ETH_ALEN - 1) {
-		u8 mac[ETH_ALEN];
-
-		if (mac_pton(buf, mac))
-			memcpy(addr, mac, ETH_ALEN);
-		else
-			ret = -EINVAL;
-	} else {
-		ret = -EINVAL;
+	if (IS_ERR(mac))
+		return PTR_ERR(mac);
+
+	if (len != ETH_ALEN || !is_valid_ether_addr(mac)) {
+		kfree(mac);
+		return -EINVAL;
 	}
 
-	kfree(buf);
+	memcpy(addr, mac, ETH_ALEN);
+	kfree(mac);
 
-	return ret;
+	return 0;
 }
 
 /**
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] Revert "of: net: support NVMEM cells with MAC in text format"
  2022-01-11  8:12 [PATCH net-next] Revert "of: net: support NVMEM cells with MAC in text format" Michael Walle
@ 2022-01-12  2:28 ` Jakub Kicinski
  2022-01-12 14:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2022-01-12  2:28 UTC (permalink / raw)
  To: Michael Walle
  Cc: netdev, linux-kernel, Rafał Miłecki, Andrew Lunn,
	Heiner Kallweit, Russell King, David S . Miller

On Tue, 11 Jan 2022 09:12:06 +0100 Michael Walle wrote:
> This reverts commit 9ed319e411915e882bb4ed99be3ae78667a70022.
> 
> We can already post process a nvmem cell value in a particular driver.
> Instead of having yet another place to convert the values, the post
> processing hook of the nvmem provider should be used in this case.
> 
> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
> As mentioned in [1] I think we should discuss this a bit more and revert
> the patch for now before there are any users of it.
> 
> [1] https://lore.kernel.org/netdev/20211229124047.1286965-1-michael@walle.cc/

Revert seems reasonable since there are two different proposals, 
but I won't pretend to understand the space so if anyone has opinions
please share them.

> btw, now with net-next closed, should this patch have net-next or net as
> the queue in the subject?

net, technically, although currently the trees are pretty much
identical.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] Revert "of: net: support NVMEM cells with MAC in text format"
  2022-01-11  8:12 [PATCH net-next] Revert "of: net: support NVMEM cells with MAC in text format" Michael Walle
  2022-01-12  2:28 ` Jakub Kicinski
@ 2022-01-12 14:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-12 14:20 UTC (permalink / raw)
  To: Michael Walle
  Cc: netdev, linux-kernel, rafal, andrew, hkallweit1, linux, davem, kuba

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Tue, 11 Jan 2022 09:12:06 +0100 you wrote:
> This reverts commit 9ed319e411915e882bb4ed99be3ae78667a70022.
> 
> We can already post process a nvmem cell value in a particular driver.
> Instead of having yet another place to convert the values, the post
> processing hook of the nvmem provider should be used in this case.
> 
> Signed-off-by: Michael Walle <michael@walle.cc>
> 
> [...]

Here is the summary with links:
  - [net-next] Revert "of: net: support NVMEM cells with MAC in text format"
    https://git.kernel.org/netdev/net/c/3486eb774f9d

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] 3+ messages in thread

end of thread, other threads:[~2022-01-12 14:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11  8:12 [PATCH net-next] Revert "of: net: support NVMEM cells with MAC in text format" Michael Walle
2022-01-12  2:28 ` Jakub Kicinski
2022-01-12 14:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.