Commit da90e380 authored by Tobias Klauser's avatar Tobias Klauser Committed by David S. Miller

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 b34296a9 ("net: ethoc: Utilize
of_get_mac_address()").

Cc: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarTobias Klauser <tklauser@distanz.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8b7b707a
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/of_mdio.h> #include <linux/of_mdio.h>
#include <linux/of_net.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/of_address.h> #include <linux/of_address.h>
...@@ -292,7 +293,8 @@ static int axienet_dma_bd_init(struct net_device *ndev) ...@@ -292,7 +293,8 @@ static int axienet_dma_bd_init(struct net_device *ndev)
* This function is called to initialize the MAC address of the Axi Ethernet * This function is called to initialize the MAC address of the Axi Ethernet
* core. It writes to the UAW0 and UAW1 registers of the core. * core. It writes to the UAW0 and UAW1 registers of the core.
*/ */
static void axienet_set_mac_address(struct net_device *ndev, void *address) static void axienet_set_mac_address(struct net_device *ndev,
const void *address)
{ {
struct axienet_local *lp = netdev_priv(ndev); struct axienet_local *lp = netdev_priv(ndev);
...@@ -1456,7 +1458,7 @@ static int axienet_probe(struct platform_device *pdev) ...@@ -1456,7 +1458,7 @@ static int axienet_probe(struct platform_device *pdev)
struct device_node *np; struct device_node *np;
struct axienet_local *lp; struct axienet_local *lp;
struct net_device *ndev; struct net_device *ndev;
u8 mac_addr[6]; const void *mac_addr;
struct resource *ethres, dmares; struct resource *ethres, dmares;
u32 value; u32 value;
...@@ -1567,13 +1569,12 @@ static int axienet_probe(struct platform_device *pdev) ...@@ -1567,13 +1569,12 @@ static int axienet_probe(struct platform_device *pdev)
} }
/* Retrieve the MAC address */ /* Retrieve the MAC address */
ret = of_property_read_u8_array(pdev->dev.of_node, mac_addr = of_get_mac_address(pdev->dev.of_node);
"local-mac-address", mac_addr, 6); if (!mac_addr) {
if (ret) {
dev_err(&pdev->dev, "could not find MAC address\n"); dev_err(&pdev->dev, "could not find MAC address\n");
goto free_netdev; goto free_netdev;
} }
axienet_set_mac_address(ndev, (void *)mac_addr); axienet_set_mac_address(ndev, mac_addr);
lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD; lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD;
lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD; lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment