Skip to content

Commit 0620547

Browse files
tklauserdavem330
authored andcommitted
net: ll_temac: 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 temac_init_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 da90e38 commit 0620547

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/net/ethernet/xilinx/ll_temac_main.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/of_device.h>
3838
#include <linux/of_irq.h>
3939
#include <linux/of_mdio.h>
40+
#include <linux/of_net.h>
4041
#include <linux/of_platform.h>
4142
#include <linux/of_address.h>
4243
#include <linux/skbuff.h>
@@ -332,7 +333,7 @@ static void temac_do_set_mac_address(struct net_device *ndev)
332333
mutex_unlock(&lp->indirect_mutex);
333334
}
334335

335-
static int temac_init_mac_address(struct net_device *ndev, void *address)
336+
static int temac_init_mac_address(struct net_device *ndev, const void *address)
336337
{
337338
memcpy(ndev->dev_addr, address, ETH_ALEN);
338339
if (!is_valid_ether_addr(ndev->dev_addr))
@@ -982,7 +983,7 @@ static int temac_of_probe(struct platform_device *op)
982983
struct net_device *ndev;
983984
const void *addr;
984985
__be32 *p;
985-
int size, rc = 0;
986+
int rc = 0;
986987

987988
/* Init network device structure */
988989
ndev = alloc_etherdev(sizeof(*lp));
@@ -1074,13 +1075,13 @@ static int temac_of_probe(struct platform_device *op)
10741075

10751076

10761077
/* Retrieve the MAC address */
1077-
addr = of_get_property(op->dev.of_node, "local-mac-address", &size);
1078-
if ((!addr) || (size != 6)) {
1078+
addr = of_get_mac_address(op->dev.of_node);
1079+
if (!addr) {
10791080
dev_err(&op->dev, "could not find MAC address\n");
10801081
rc = -ENODEV;
10811082
goto err_iounmap_2;
10821083
}
1083-
temac_init_mac_address(ndev, (void *)addr);
1084+
temac_init_mac_address(ndev, addr);
10841085

10851086
rc = temac_mdio_setup(lp, op->dev.of_node);
10861087
if (rc)

0 commit comments

Comments
 (0)