public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: enc28j60: use of_get_ethdev_address
@ 2026-04-27  5:25 Rosen Penev
  2026-04-27 14:19 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Rosen Penev @ 2026-04-27  5:25 UTC (permalink / raw)
  To: netdev
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, open list

Since this is an OF only driver, of_ instead of device_ allows nvmem to
be used to specify the MAC address.

Add EPROBE_DEFER handling for NVMEM.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/ethernet/microchip/enc28j60.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/enc28j60.c b/drivers/net/ethernet/microchip/enc28j60.c
index d6c9491537e4..2b9b4163e419 100644
--- a/drivers/net/ethernet/microchip/enc28j60.c
+++ b/drivers/net/ethernet/microchip/enc28j60.c
@@ -24,6 +24,7 @@
 #include <linux/skbuff.h>
 #include <linux/delay.h>
 #include <linux/spi/spi.h>
+#include <linux/of_net.h>
 
 #include "enc28j60_hw.h"
 
@@ -1554,7 +1555,10 @@ static int enc28j60_probe(struct spi_device *spi)
 		goto error_irq;
 	}
 
-	if (device_get_ethdev_address(&spi->dev, dev))
+	ret = of_get_ethdev_address(spi->dev.of_node, dev);
+	if (ret == -EPROBE_DEFER)
+		return ret;
+	if (ret)
 		eth_hw_addr_random(dev);
 	enc28j60_set_hw_macaddr(dev);
 
-- 
2.54.0


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

* Re: [PATCH net-next] net: enc28j60: use of_get_ethdev_address
  2026-04-27  5:25 [PATCH net-next] net: enc28j60: use of_get_ethdev_address Rosen Penev
@ 2026-04-27 14:19 ` Andrew Lunn
  2026-04-27 19:18   ` Rosen Penev
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2026-04-27 14:19 UTC (permalink / raw)
  To: Rosen Penev
  Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, open list

On Sun, Apr 26, 2026 at 10:25:33PM -0700, Rosen Penev wrote:
> Since this is an OF only driver, of_ instead of device_ allows nvmem to
> be used to specify the MAC address.

Now that is usual, somebody converting device_ to of_. It is normally
the other way around, for not particularly good reasons. Nice.

> -	if (device_get_ethdev_address(&spi->dev, dev))
> +	ret = of_get_ethdev_address(spi->dev.of_node, dev);
> +	if (ret == -EPROBE_DEFER)
> +		return ret;

/**
 * device_get_mac_address - Get the MAC for a given device
 * @dev:	Pointer to the device
 * @addr:	Address of buffer to store the MAC in
 */
int device_get_mac_address(struct device *dev, char *addr)
{
	if (!fwnode_get_mac_address(dev_fwnode(dev), addr))
		return 0;

	return nvmem_get_mac_address(dev, addr);
}
EXPORT_SYMBOL(device_get_mac_address);

This appears to support nvmem. Would device_get_mac_address() actually
work? I'm not against swapping to of_get_ethdev_address, but the
commit message should be accurate.

   Andrew

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

* Re: [PATCH net-next] net: enc28j60: use of_get_ethdev_address
  2026-04-27 14:19 ` Andrew Lunn
@ 2026-04-27 19:18   ` Rosen Penev
  0 siblings, 0 replies; 3+ messages in thread
From: Rosen Penev @ 2026-04-27 19:18 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, open list

On Mon, Apr 27, 2026 at 7:19 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Sun, Apr 26, 2026 at 10:25:33PM -0700, Rosen Penev wrote:
> > Since this is an OF only driver, of_ instead of device_ allows nvmem to
> > be used to specify the MAC address.
>
> Now that is usual, somebody converting device_ to of_. It is normally
> the other way around, for not particularly good reasons. Nice.
>
> > -     if (device_get_ethdev_address(&spi->dev, dev))
> > +     ret = of_get_ethdev_address(spi->dev.of_node, dev);
> > +     if (ret == -EPROBE_DEFER)
> > +             return ret;
>
> /**
>  * device_get_mac_address - Get the MAC for a given device
>  * @dev:        Pointer to the device
>  * @addr:       Address of buffer to store the MAC in
>  */
> int device_get_mac_address(struct device *dev, char *addr)
> {
>         if (!fwnode_get_mac_address(dev_fwnode(dev), addr))
>                 return 0;
>
>         return nvmem_get_mac_address(dev, addr);
> }
> EXPORT_SYMBOL(device_get_mac_address);
>
> This appears to support nvmem. Would device_get_mac_address() actually
> work? I'm not against swapping to of_get_ethdev_address, but the
> commit message should be accurate.
I seem to have missed
https://lore.kernel.org/all/20250912140332.35395-3-wahrenst@gmx.net/
>
>    Andrew

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

end of thread, other threads:[~2026-04-27 19:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27  5:25 [PATCH net-next] net: enc28j60: use of_get_ethdev_address Rosen Penev
2026-04-27 14:19 ` Andrew Lunn
2026-04-27 19:18   ` Rosen Penev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox