From patchwork Thu Feb 11 16:20:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 8282351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EF1E59F1C0 for ; Thu, 11 Feb 2016 16:20:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2311A203AD for ; Thu, 11 Feb 2016 16:20:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 498C7203B0 for ; Thu, 11 Feb 2016 16:20:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTtxZ-00012c-MB; Thu, 11 Feb 2016 16:19:13 +0000 Received: from mail-pa0-x241.google.com ([2607:f8b0:400e:c03::241]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTtwn-0000GD-ME for linux-arm-kernel@lists.infradead.org; Thu, 11 Feb 2016 16:18:27 +0000 Received: by mail-pa0-x241.google.com with SMTP id gc2so648206pab.0 for ; Thu, 11 Feb 2016 08:18:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JaudRbDu9zw1UehmjQDkZtWHswG0+4Mwu0BMHqvCJrM=; b=vTzqmLyFk4RK0myOnzxej9IWuIcIsywrii/7eTs0wXtdP3vcJdUT8gI1VmysfWG+cs qDcWLH6MSvQe5un5VJuaqnUNMSQBdhoXV1UvL+t1xccPnq0GYhRydMO5ZBlO9OIbvo/6 zkmeuH4QTLKrLReLlTq0cNmgiDNVz6Z+FhnYQRTG79GMn5Mwq3BOU1jtFbP9IJSs6f54 dWhTWuP/LD5g98WnjnC4VinMXaeYW2grg45E2KA13638so7WEbXYew/27BCtFBv5HzIA /BaMkBYgjMGFOcW2tw1nooCNDrdFzJxVLajzjDClh1iUymQScRtRrUlQf6YvX17LzFza IErw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JaudRbDu9zw1UehmjQDkZtWHswG0+4Mwu0BMHqvCJrM=; b=mlTwv++EEMykk6arR7FAOBICYiV7qBrfrCerlNYDPgbwLetjlzphvhJiR1ZlgAq1b+ OKa1Zo7qoyRjqTyq1Z6Nl34f1po/W8iE733syRvTRj7mNzmUHpN2m6mxX/H7aBS74l71 eH2aWc3MAbjhaB8onyWyuWgLaoo2tVT0rp5kSo6M3MT5Et2RUDpXLH8FNn2G74rilLmU E5P8PVd3RCiRtCI7ObAhyZb7ETa4jw27Ou4lMKkxOFDXa86FOX+kYHVVkOS2ckLoO18d nd1vGSzNhJeySYhC/0UNblAfwv+dWL34rjdROOi7VhiKThPs6hu+yPYGNV8xgP54vwq6 bxUw== X-Gm-Message-State: AG10YOTx7na9qBWDrf0yBT54jXpISBeazB8TErE2vtkYdl7E7roCpHjkfBoemEhR4yP7tA== X-Received: by 10.66.255.70 with SMTP id ao6mr67556868pad.64.1455207485311; Thu, 11 Feb 2016 08:18:05 -0800 (PST) Received: from localhost.localdomain ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id s90sm13355894pfa.49.2016.02.11.08.18.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2016 08:18:04 -0800 (PST) From: sunil.kovvuri@gmail.com To: netdev@vger.kernel.org Subject: [PATCH v2 4/6] net: thunderx: bgx: Use standard firmware node infrastructure. Date: Thu, 11 Feb 2016 21:50:24 +0530 Message-Id: <1455207626-35488-5-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1455207626-35488-1-git-send-email-sunil.kovvuri@gmail.com> References: <1455207626-35488-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160211_081826_013496_4EC75428 X-CRM114-Status: GOOD ( 15.67 ) X-Spam-Score: -1.4 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sgoutham@cavium.com, David Daney , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robert.richter@caviumnetworks.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Daney In the case of OF device tree, the firmware information is attached to the BGX device structure in the standard manner, so use the firmware iterators and accessors where possible. Signed-off-by: David Daney Signed-off-by: Sunil Goutham --- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 27 +++++++++++---------- 1 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index 9df26c2..111835b 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c @@ -968,26 +968,27 @@ static int bgx_init_acpi_phy(struct bgx *bgx) static int bgx_init_of_phy(struct bgx *bgx) { - struct device_node *np; - struct device_node *np_child; + struct fwnode_handle *fwn; u8 lmac = 0; - char bgx_sel[5]; const char *mac; - /* Get BGX node from DT */ - snprintf(bgx_sel, 5, "bgx%d", bgx->bgx_id); - np = of_find_node_by_name(NULL, bgx_sel); - if (!np) - return -ENODEV; + device_for_each_child_node(&bgx->pdev->dev, fwn) { + struct device_node *phy_np; + struct device_node *node = to_of_node(fwn); + + /* If it is not an OF node we cannot handle it yet, so + * exit the loop. + */ + if (!node) + break; - for_each_child_of_node(np, np_child) { - struct device_node *phy_np = of_parse_phandle(np_child, - "phy-handle", 0); + phy_np = of_parse_phandle(node, "phy-handle", 0); if (!phy_np) continue; + bgx->lmac[lmac].phydev = of_phy_find_device(phy_np); - mac = of_get_mac_address(np_child); + mac = of_get_mac_address(node); if (mac) ether_addr_copy(bgx->lmac[lmac].mac, mac); @@ -995,7 +996,7 @@ static int bgx_init_of_phy(struct bgx *bgx) bgx->lmac[lmac].lmacid = lmac; lmac++; if (lmac == MAX_LMAC_PER_BGX) { - of_node_put(np_child); + of_node_put(node); break; } }