From patchwork Wed Dec 7 12:24:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Klauser X-Patchwork-Id: 703557 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3tYd4v45Cbz9t1L for ; Wed, 7 Dec 2016 23:25:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752625AbcLGMZe (ORCPT ); Wed, 7 Dec 2016 07:25:34 -0500 Received: from mail.zhinst.com ([212.126.164.98]:33092 "EHLO mail.zhinst.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751884AbcLGMZd (ORCPT ); Wed, 7 Dec 2016 07:25:33 -0500 Received: from ziws08.zhinst.com ([10.42.0.7]) by mail.zhinst.com (Kerio Connect 9.2.1) with ESMTP; Wed, 7 Dec 2016 13:24:45 +0100 From: Tobias Klauser To: netdev@vger.kernel.org Cc: anirudh@xilinx.com, John.Linn@xilinx.com, michal.simek@xilinx.com, soren.brinkmann@xilinx.com, Florian Fainelli Subject: [PATCH] net: axienet: Utilize of_get_mac_address() Date: Wed, 7 Dec 2016 13:24:44 +0100 Message-Id: <20161207122444.29306-1-tklauser@distanz.ch> X-Mailer: git-send-email 2.11.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Signed-off-by: Tobias Klauser --- 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 #include #include +#include #include #include #include @@ -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;