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

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 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
06205472 da90e380

+6 -5
+6 -5
drivers/net/ethernet/xilinx/ll_temac_main.c
··· 37 37 #include <linux/of_device.h> 38 38 #include <linux/of_irq.h> 39 39 #include <linux/of_mdio.h> 40 + #include <linux/of_net.h> 40 41 #include <linux/of_platform.h> 41 42 #include <linux/of_address.h> 42 43 #include <linux/skbuff.h> ··· 333 332 mutex_unlock(&lp->indirect_mutex); 334 333 } 335 334 336 - static int temac_init_mac_address(struct net_device *ndev, void *address) 335 + static int temac_init_mac_address(struct net_device *ndev, const void *address) 337 336 { 338 337 memcpy(ndev->dev_addr, address, ETH_ALEN); 339 338 if (!is_valid_ether_addr(ndev->dev_addr)) ··· 983 982 struct net_device *ndev; 984 983 const void *addr; 985 984 __be32 *p; 986 - int size, rc = 0; 985 + int rc = 0; 987 986 988 987 /* Init network device structure */ 989 988 ndev = alloc_etherdev(sizeof(*lp)); ··· 1075 1074 1076 1075 1077 1076 /* Retrieve the MAC address */ 1078 - addr = of_get_property(op->dev.of_node, "local-mac-address", &size); 1079 - if ((!addr) || (size != 6)) { 1077 + addr = of_get_mac_address(op->dev.of_node); 1078 + if (!addr) { 1080 1079 dev_err(&op->dev, "could not find MAC address\n"); 1081 1080 rc = -ENODEV; 1082 1081 goto err_iounmap_2; 1083 1082 } 1084 - temac_init_mac_address(ndev, (void *)addr); 1083 + temac_init_mac_address(ndev, addr); 1085 1084 1086 1085 rc = temac_mdio_setup(lp, op->dev.of_node); 1087 1086 if (rc)