Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: axienet: Utilize of_get_mac_address()

Do not open code getting the MAC address exclusively from the
"local-mac-address" property, but instead use of_get_mac_address()
which looks up the MAC address using the 3 typical property names.

Also avoid casting away the const qualifier of the return value by
making axienet_set_mac_address() take a const void* address.

Follows commit b34296a9c047 ("net: ethoc: Utilize
of_get_mac_address()").

Cc: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tobias Klauser and committed by
David S. Miller
da90e380 8b7b707a

+7 -6
+7 -6
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 25 25 #include <linux/module.h> 26 26 #include <linux/netdevice.h> 27 27 #include <linux/of_mdio.h> 28 + #include <linux/of_net.h> 28 29 #include <linux/of_platform.h> 29 30 #include <linux/of_irq.h> 30 31 #include <linux/of_address.h> ··· 293 292 * This function is called to initialize the MAC address of the Axi Ethernet 294 293 * core. It writes to the UAW0 and UAW1 registers of the core. 295 294 */ 296 - static void axienet_set_mac_address(struct net_device *ndev, void *address) 295 + static void axienet_set_mac_address(struct net_device *ndev, 296 + const void *address) 297 297 { 298 298 struct axienet_local *lp = netdev_priv(ndev); 299 299 ··· 1458 1456 struct device_node *np; 1459 1457 struct axienet_local *lp; 1460 1458 struct net_device *ndev; 1461 - u8 mac_addr[6]; 1459 + const void *mac_addr; 1462 1460 struct resource *ethres, dmares; 1463 1461 u32 value; 1464 1462 ··· 1569 1567 } 1570 1568 1571 1569 /* Retrieve the MAC address */ 1572 - ret = of_property_read_u8_array(pdev->dev.of_node, 1573 - "local-mac-address", mac_addr, 6); 1574 - if (ret) { 1570 + mac_addr = of_get_mac_address(pdev->dev.of_node); 1571 + if (!mac_addr) { 1575 1572 dev_err(&pdev->dev, "could not find MAC address\n"); 1576 1573 goto free_netdev; 1577 1574 } 1578 - axienet_set_mac_address(ndev, (void *)mac_addr); 1575 + axienet_set_mac_address(ndev, mac_addr); 1579 1576 1580 1577 lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD; 1581 1578 lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD;