Skip to content

Commit da90e38

Browse files
tklauserdavem330
authored andcommitted
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 b34296a ("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>
1 parent 8b7b707 commit da90e38

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/net/ethernet/xilinx/xilinx_axienet_main.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/module.h>
2626
#include <linux/netdevice.h>
2727
#include <linux/of_mdio.h>
28+
#include <linux/of_net.h>
2829
#include <linux/of_platform.h>
2930
#include <linux/of_irq.h>
3031
#include <linux/of_address.h>
@@ -292,7 +293,8 @@ static int axienet_dma_bd_init(struct net_device *ndev)
292293
* This function is called to initialize the MAC address of the Axi Ethernet
293294
* core. It writes to the UAW0 and UAW1 registers of the core.
294295
*/
295-
static void axienet_set_mac_address(struct net_device *ndev, void *address)
296+
static void axienet_set_mac_address(struct net_device *ndev,
297+
const void *address)
296298
{
297299
struct axienet_local *lp = netdev_priv(ndev);
298300

@@ -1456,7 +1458,7 @@ static int axienet_probe(struct platform_device *pdev)
14561458
struct device_node *np;
14571459
struct axienet_local *lp;
14581460
struct net_device *ndev;
1459-
u8 mac_addr[6];
1461+
const void *mac_addr;
14601462
struct resource *ethres, dmares;
14611463
u32 value;
14621464

@@ -1567,13 +1569,12 @@ static int axienet_probe(struct platform_device *pdev)
15671569
}
15681570

15691571
/* Retrieve the MAC address */
1570-
ret = of_property_read_u8_array(pdev->dev.of_node,
1571-
"local-mac-address", mac_addr, 6);
1572-
if (ret) {
1572+
mac_addr = of_get_mac_address(pdev->dev.of_node);
1573+
if (!mac_addr) {
15731574
dev_err(&pdev->dev, "could not find MAC address\n");
15741575
goto free_netdev;
15751576
}
1576-
axienet_set_mac_address(ndev, (void *)mac_addr);
1577+
axienet_set_mac_address(ndev, mac_addr);
15771578

15781579
lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD;
15791580
lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD;

0 commit comments

Comments
 (0)