linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net/next] r8152: Use MAC address from device tree if available
@ 2020-05-14 12:38 Thierry Reding
  2020-05-14 20:16 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Thierry Reding @ 2020-05-14 12:38 UTC (permalink / raw)
  To: David S. Miller
  Cc: Hayes Wang, Jakub Kicinski, linux-usb, netdev, linux-tegra

From: Thierry Reding <treding@nvidia.com>

If a MAC address was passed via the device tree node for the r8152
device, use it and fall back to reading from EEPROM otherwise. This is
useful for devices where the r8152 EEPROM was not programmed with a
valid MAC address, or if users want to explicitly set a MAC address in
the bootloader and pass that to the kernel.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/net/usb/r8152.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 8f8d9883d363..1af72ec284ca 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1504,15 +1504,19 @@ static int determine_ethernet_addr(struct r8152 *tp, struct sockaddr *sa)
 
 	sa->sa_family = dev->type;
 
-	if (tp->version == RTL_VER_01) {
-		ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data);
-	} else {
-		/* if device doesn't support MAC pass through this will
-		 * be expected to be non-zero
-		 */
-		ret = vendor_mac_passthru_addr_read(tp, sa);
-		if (ret < 0)
-			ret = pla_ocp_read(tp, PLA_BACKUP, 8, sa->sa_data);
+	ret = eth_platform_get_mac_address(&dev->dev, sa->sa_data);
+	if (ret < 0) {
+		if (tp->version == RTL_VER_01) {
+			ret = pla_ocp_read(tp, PLA_IDR, 8, sa->sa_data);
+		} else {
+			/* if device doesn't support MAC pass through this will
+			 * be expected to be non-zero
+			 */
+			ret = vendor_mac_passthru_addr_read(tp, sa);
+			if (ret < 0)
+				ret = pla_ocp_read(tp, PLA_BACKUP, 8,
+						   sa->sa_data);
+		}
 	}
 
 	if (ret < 0) {
-- 
2.24.1


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

* Re: [PATCH net/next] r8152: Use MAC address from device tree if available
  2020-05-14 12:38 [PATCH net/next] r8152: Use MAC address from device tree if available Thierry Reding
@ 2020-05-14 20:16 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-05-14 20:16 UTC (permalink / raw)
  To: thierry.reding; +Cc: hayeswang, kuba, linux-usb, netdev, linux-tegra

From: Thierry Reding <thierry.reding@gmail.com>
Date: Thu, 14 May 2020 14:38:48 +0200

> From: Thierry Reding <treding@nvidia.com>
> 
> If a MAC address was passed via the device tree node for the r8152
> device, use it and fall back to reading from EEPROM otherwise. This is
> useful for devices where the r8152 EEPROM was not programmed with a
> valid MAC address, or if users want to explicitly set a MAC address in
> the bootloader and pass that to the kernel.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>

Yep, that looks good, applied.

Thank you.

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

end of thread, other threads:[~2020-05-14 20:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-14 12:38 [PATCH net/next] r8152: Use MAC address from device tree if available Thierry Reding
2020-05-14 20:16 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).