On 16.05.25 10:18, Adriano Cordova wrote:
Add eth_get_ethaddr_from_dev() to retrieve the MAC address
of a specific eth udevice. The function eth_get_ethaddr()
preserves its behavior of returning the MAC address of the
current eth udevice.

Signed-off-by: Adriano Cordova <adriano.cord...@canonical.com>

Reviewed-by: Heinrich Schuchardt <xypron.g...@gmx.de>

---
  include/net-common.h |  1 +
  net/eth-uclass.c     | 11 ++++++++---
  2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/net-common.h b/include/net-common.h
index e536968a92b..c429d77d7c3 100644
--- a/include/net-common.h
+++ b/include/net-common.h
@@ -292,6 +292,7 @@ struct eth_ops {
struct udevice *eth_get_dev(void); /* get the current device */
  void eth_set_dev(struct udevice *dev); /* set a device */
+unsigned char *eth_get_ethaddr_from_dev(struct udevice *dev); /* get a 
device's MAC */
  unsigned char *eth_get_ethaddr(void); /* get the current device MAC */
  int eth_rx(void);                      /* Check for received packets */
  void eth_halt(void);                  /* stop SCC */
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 5555f82f23e..984d888e2fc 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -175,18 +175,23 @@ struct udevice *eth_get_dev_by_name(const char *devname)
        return NULL;
  }
-unsigned char *eth_get_ethaddr(void)
+unsigned char *eth_get_ethaddr_from_dev(struct udevice *dev)
  {
        struct eth_pdata *pdata;
- if (eth_get_dev()) {
-               pdata = dev_get_plat(eth_get_dev());
+       if (dev) {
+               pdata = dev_get_plat(dev);
                return pdata->enetaddr;
        }
return NULL;
  }
+unsigned char *eth_get_ethaddr(void)
+{
+       return eth_get_ethaddr_from_dev(eth_get_dev());
+}
+
  /* Set active state without calling start on the driver */
  int eth_init_state_only(void)
  {

Reply via email to