From patchwork Wed Feb 12 15:55:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 319658 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 A8B9A2C00A5 for ; Thu, 13 Feb 2014 02:59:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753189AbaBLP5Y (ORCPT ); Wed, 12 Feb 2014 10:57:24 -0500 Received: from mail-ea0-f178.google.com ([209.85.215.178]:40604 "EHLO mail-ea0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753177AbaBLP5U (ORCPT ); Wed, 12 Feb 2014 10:57:20 -0500 Received: by mail-ea0-f178.google.com with SMTP id a15so4487904eae.37 for ; Wed, 12 Feb 2014 07:57:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references:content-type; bh=5CzWv+BDPIc9ughh9hA5ve4UiJaDZBkoJQDUmzAQsYo=; b=JMAAj0rFrJZSWpbWco9ZNu2OfMU4afZpUQv0VvZOy1NOYAlbHWKIm2d0UtnT+rHwOp RCho2D1H4U6MJxd1KuUO5NJy+mYP6K//l9BW/0HXgTuz3UdDCaEL4IwJqO2N2njmA7Sq dPjh8U34ZdoFnbT4hGNmWUM+pig+IUXVp8an6Jk8RR6b+8oN5Cq7m6KjcEutzl8gKrXJ 9fvDcAMi/Bnmo1bAcy0WkJunZYLO+AA7Cw1Q2/GvD4JXHgeuE1nmYWJWstHbbbOBDMGD of8MgbBCx+ALBXMnx7QyFT3hMHotfxfMmde55YreMANs+JwkL6TeFe9GPwLR/2S8oNgd bNtg== X-Gm-Message-State: ALoCoQk+qyxQZm4RZYdIrWbErslofnxzH5s5vG+WwjEbqb4vvyMo5mCEF88jgtQoJi5T/yKf73Lg X-Received: by 10.15.23.194 with SMTP id h42mr4926727eeu.32.1392220639166; Wed, 12 Feb 2014 07:57:19 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id g1sm82275177eet.6.2014.02.12.07.57.16 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Wed, 12 Feb 2014 07:57:17 -0800 (PST) From: Michal Simek To: netdev@vger.kernel.org Cc: Srikanth Thokala , Srikanth Thokala , Michal Simek , Anirudha Sarangi , John Linn , Grant Likely , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 12/14] net: axienet: Use of_property_* calls Date: Wed, 12 Feb 2014 16:55:46 +0100 Message-Id: <77b9c5c033a54916c3e5be6f67dbd59c0155bc4c.1392220536.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Srikanth Thokala Use of_property_* calls Signed-off-by: Srikanth Thokala Signed-off-by: Michal Simek --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 41 ++++++++++------------- 1 file changed, 17 insertions(+), 24 deletions(-) -- 1.8.2.3 diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 936a14c..9a9ffbc 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -1493,13 +1493,13 @@ static void axienet_dma_err_handler(unsigned long data) */ static int axienet_of_probe(struct platform_device *pdev) { - __be32 *p; - int size, ret = 0; + int ret; struct device_node *np; struct axienet_local *lp; struct net_device *ndev; - const void *addr; + u8 mac_addr[6]; struct resource *ethres, dmares; + u32 value; ndev = alloc_etherdev(sizeof(*lp)); if (!ndev) @@ -1530,9 +1530,9 @@ static int axienet_of_probe(struct platform_device *pdev) /* Setup checksum offload, but default to off if not specified */ lp->features = 0; - p = (__be32 *) of_get_property(pdev->dev.of_node, "xlnx,txcsum", NULL); - if (p) { - switch (be32_to_cpup(p)) { + ret = of_property_read_u32(pdev->dev.of_node, "xlnx,txcsum", &value); + if (!ret) { + switch (value) { case 1: lp->csum_offload_on_tx_path = XAE_FEATURE_PARTIAL_TX_CSUM; @@ -1551,9 +1551,9 @@ static int axienet_of_probe(struct platform_device *pdev) lp->csum_offload_on_tx_path = XAE_NO_CSUM_OFFLOAD; } } - p = (__be32 *) of_get_property(pdev->dev.of_node, "xlnx,rxcsum", NULL); - if (p) { - switch (be32_to_cpup(p)) { + ret = of_property_read_u32(pdev->dev.of_node, "xlnx,rxcsum", &value); + if (!ret) { + switch (value) { case 1: lp->csum_offload_on_rx_path = XAE_FEATURE_PARTIAL_RX_CSUM; @@ -1574,17 +1574,10 @@ static int axienet_of_probe(struct platform_device *pdev) * Here we check for memory allocated for Rx/Tx in the hardware from * the device-tree and accordingly set flags. */ - p = (__be32 *) of_get_property(pdev->dev.of_node, "xlnx,rxmem", NULL); - if (p) - lp->rxmem = be32_to_cpup(p); - p = (__be32 *) of_get_property(pdev->dev.of_node, "xlnx,temac-type", - NULL); - if (p) - lp->temac_type = be32_to_cpup(p); - p = (__be32 *) of_get_property(pdev->dev.of_node, - "xlnx,phy-type", NULL); - if (p) - lp->phy_type = be32_to_cpup(p); + of_property_read_u32(pdev->dev.of_node, "xlnx,rxmem", &lp->rxmem); + of_property_read_u32(pdev->dev.of_node, "xlnx,temac-type", + &lp->temac_type); + of_property_read_u32(pdev->dev.of_node, "xlnx,phy-type", &lp->phy_type); /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0); @@ -1614,13 +1607,13 @@ static int axienet_of_probe(struct platform_device *pdev) } /* Retrieve the MAC address */ - addr = of_get_property(pdev->dev.of_node, "local-mac-address", &size); - if ((!addr) || (size != 6)) { + ret = of_property_read_u8_array(pdev->dev.of_node, + "local-mac-address", mac_addr, 6); + if (ret) { dev_err(&pdev->dev, "could not find MAC address\n"); - ret = -ENODEV; goto free_netdev; } - axienet_set_mac_address(ndev, (void *) addr); + axienet_set_mac_address(ndev, (void *) mac_addr); lp->coalesce_count_rx = XAXIDMA_DFT_RX_THRESHOLD; lp->coalesce_count_tx = XAXIDMA_DFT_TX_THRESHOLD;