Skip to content

Commit 4f359b6

Browse files
Łukasz Stelmachdavem330
authored andcommitted
net/smscx5xx: change to of_get_mac_address() eth_platform_get_mac_address()
Use more generic eth_platform_get_mac_address() which can get a MAC address from other than DT platform specific sources too. Check if the obtained address is valid. Signed-off-by: Łukasz Stelmach <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a3d0ba8 commit 4f359b6

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

drivers/net/usb/smsc75xx.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -757,13 +757,14 @@ static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
757757

758758
static void smsc75xx_init_mac_address(struct usbnet *dev)
759759
{
760-
const u8 *mac_addr;
761-
762760
/* maybe the boot loader passed the MAC address in devicetree */
763-
mac_addr = of_get_mac_address(dev->udev->dev.of_node);
764-
if (!IS_ERR(mac_addr)) {
765-
ether_addr_copy(dev->net->dev_addr, mac_addr);
766-
return;
761+
if (!eth_platform_get_mac_address(&dev->udev->dev,
762+
dev->net->dev_addr)) {
763+
if (is_valid_ether_addr(dev->net->dev_addr)) {
764+
/* device tree values are valid so use them */
765+
netif_dbg(dev, ifup, dev->net, "MAC address read from the device tree\n");
766+
return;
767+
}
767768
}
768769

769770
/* try reading mac address from EEPROM */

drivers/net/usb/smsc95xx.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -755,13 +755,14 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
755755

756756
static void smsc95xx_init_mac_address(struct usbnet *dev)
757757
{
758-
const u8 *mac_addr;
759-
760758
/* maybe the boot loader passed the MAC address in devicetree */
761-
mac_addr = of_get_mac_address(dev->udev->dev.of_node);
762-
if (!IS_ERR(mac_addr)) {
763-
ether_addr_copy(dev->net->dev_addr, mac_addr);
764-
return;
759+
if (!eth_platform_get_mac_address(&dev->udev->dev,
760+
dev->net->dev_addr)) {
761+
if (is_valid_ether_addr(dev->net->dev_addr)) {
762+
/* device tree values are valid so use them */
763+
netif_dbg(dev, ifup, dev->net, "MAC address read from the device tree\n");
764+
return;
765+
}
765766
}
766767

767768
/* try reading mac address from EEPROM */

0 commit comments

Comments
 (0)