* [PATCH] net: axienet: Utilize of_get_mac_address()
@ 2016-12-07 12:25 Tobias Klauser
2016-12-07 12:25 ` [PATCH] net: ll_temac: " Tobias Klauser
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Tobias Klauser @ 2016-12-07 12:25 UTC (permalink / raw)
To: netdev; +Cc: michal.simek, soren.brinkmann, Florian Fainelli
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>
---
drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index c9c8a3be9f1b..b96e96919e31 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -25,6 +25,7 @@
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/of_mdio.h>
+#include <linux/of_net.h>
#include <linux/of_platform.h>
#include <linux/of_irq.h>
#include <linux/of_address.h>
@@ -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
* 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);
@@ -1456,7 +1458,7 @@ static int axienet_probe(struct platform_device *pdev)
struct device_node *np;
struct axienet_local *lp;
struct net_device *ndev;
- u8 mac_addr[6];
+ const void *mac_addr;
struct resource *ethres, dmares;
u32 value;
@@ -1567,13 +1569,12 @@ static int axienet_probe(struct platform_device *pdev)
}
/* Retrieve the MAC address */
- ret = of_property_read_u8_array(pdev->dev.of_node,
- "local-mac-address", mac_addr, 6);
- if (ret) {
+ mac_addr = of_get_mac_address(pdev->dev.of_node);
+ if (!mac_addr) {
dev_err(&pdev->dev, "could not find MAC address\n");
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_tx = XAXIDMA_DFT_TX_THRESHOLD;
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] net: ll_temac: Utilize of_get_mac_address()
2016-12-07 12:25 [PATCH] net: axienet: Utilize of_get_mac_address() Tobias Klauser
@ 2016-12-07 12:25 ` Tobias Klauser
2016-12-08 16:34 ` David Miller
2016-12-07 12:31 ` [PATCH] net: axienet: " Tobias Klauser
2016-12-08 16:34 ` David Miller
2 siblings, 1 reply; 5+ messages in thread
From: Tobias Klauser @ 2016-12-07 12:25 UTC (permalink / raw)
To: netdev; +Cc: michal.simek, soren.brinkmann, Florian Fainelli
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>
---
drivers/net/ethernet/xilinx/ll_temac_main.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index bcd7b76dde9f..d73da8afe08e 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -37,6 +37,7 @@
#include <linux/of_device.h>
#include <linux/of_irq.h>
#include <linux/of_mdio.h>
+#include <linux/of_net.h>
#include <linux/of_platform.h>
#include <linux/of_address.h>
#include <linux/skbuff.h>
@@ -332,7 +333,7 @@ static void temac_do_set_mac_address(struct net_device *ndev)
mutex_unlock(&lp->indirect_mutex);
}
-static int temac_init_mac_address(struct net_device *ndev, void *address)
+static int temac_init_mac_address(struct net_device *ndev, const void *address)
{
memcpy(ndev->dev_addr, address, ETH_ALEN);
if (!is_valid_ether_addr(ndev->dev_addr))
@@ -982,7 +983,7 @@ static int temac_of_probe(struct platform_device *op)
struct net_device *ndev;
const void *addr;
__be32 *p;
- int size, rc = 0;
+ int rc = 0;
/* Init network device structure */
ndev = alloc_etherdev(sizeof(*lp));
@@ -1074,13 +1075,13 @@ static int temac_of_probe(struct platform_device *op)
/* Retrieve the MAC address */
- addr = of_get_property(op->dev.of_node, "local-mac-address", &size);
- if ((!addr) || (size != 6)) {
+ addr = of_get_mac_address(op->dev.of_node);
+ if (!addr) {
dev_err(&op->dev, "could not find MAC address\n");
rc = -ENODEV;
goto err_iounmap_2;
}
- temac_init_mac_address(ndev, (void *)addr);
+ temac_init_mac_address(ndev, addr);
rc = temac_mdio_setup(lp, op->dev.of_node);
if (rc)
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net: ll_temac: Utilize of_get_mac_address()
2016-12-07 12:25 ` [PATCH] net: ll_temac: " Tobias Klauser
@ 2016-12-08 16:34 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2016-12-08 16:34 UTC (permalink / raw)
To: tklauser; +Cc: netdev, michal.simek, soren.brinkmann, f.fainelli
From: Tobias Klauser <tklauser@distanz.ch>
Date: Wed, 7 Dec 2016 13:25:29 +0100
> 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>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: axienet: Utilize of_get_mac_address()
2016-12-07 12:25 [PATCH] net: axienet: Utilize of_get_mac_address() Tobias Klauser
2016-12-07 12:25 ` [PATCH] net: ll_temac: " Tobias Klauser
@ 2016-12-07 12:31 ` Tobias Klauser
2016-12-08 16:34 ` David Miller
2 siblings, 0 replies; 5+ messages in thread
From: Tobias Klauser @ 2016-12-07 12:31 UTC (permalink / raw)
To: netdev; +Cc: michal.simek, soren.brinkmann, Florian Fainelli
On 2016-12-07 at 13:25:28 +0100, Tobias Klauser <tklauser@distanz.ch> wrote:
> 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>
Sorry for the duplicate, please disregard this patch.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: axienet: Utilize of_get_mac_address()
2016-12-07 12:25 [PATCH] net: axienet: Utilize of_get_mac_address() Tobias Klauser
2016-12-07 12:25 ` [PATCH] net: ll_temac: " Tobias Klauser
2016-12-07 12:31 ` [PATCH] net: axienet: " Tobias Klauser
@ 2016-12-08 16:34 ` David Miller
2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2016-12-08 16:34 UTC (permalink / raw)
To: tklauser; +Cc: netdev, michal.simek, soren.brinkmann, f.fainelli
From: Tobias Klauser <tklauser@distanz.ch>
Date: Wed, 7 Dec 2016 13:25:28 +0100
> 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>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-12-08 16:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-07 12:25 [PATCH] net: axienet: Utilize of_get_mac_address() Tobias Klauser
2016-12-07 12:25 ` [PATCH] net: ll_temac: " Tobias Klauser
2016-12-08 16:34 ` David Miller
2016-12-07 12:31 ` [PATCH] net: axienet: " Tobias Klauser
2016-12-08 16:34 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).