From patchwork Mon Feb 8 12:07:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 8249161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 00C05BEEE5 for ; Mon, 8 Feb 2016 12:08:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18504202FF for ; Mon, 8 Feb 2016 12:08:39 +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 355A2202EC for ; Mon, 8 Feb 2016 12:08:38 +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 1aSkap-0000fG-F4; Mon, 08 Feb 2016 12:06:59 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aSkZO-00070P-SH for linux-arm-kernel@lists.infradead.org; Mon, 08 Feb 2016 12:05:36 +0000 Received: by mail-pf0-x242.google.com with SMTP id c10so8192255pfc.0 for ; Mon, 08 Feb 2016 04:05:10 -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=gFvfkID1PNkoG/UDxw0J14krZZVVVM2xTyTNxvRB75aZh+epf71FlYIBNwiyDrpCX9 xz44P3pcOBcSzD/4o8WS+/kyNVydIzXCAQWTAEdM7SkPZCFMqlCpfZkHNyCxXJtlRdM/ mMYmXXLIWy5RH25OjiWSLcDAMnt4ietMZ0B6XNqBN0nNyuLP8vgMPvgg08Z5mSfEtf5E PdRWnxWinRcL33LG8qyrFgLVcA+xEarf77V/50V/mtJtmQscV8ZVNcQ5VT6+wpPYhl16 zB07/3xxuxQkdteVOOrIWsOT75o6HnL0nyoB83E2NKHCDofw8sRraLvbuOZqBoyldaiK XhLg== 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=NdqPuAk95QxWViqxZIpY4HeEmW/6SOvfNMSVngqbDNUyFVrlagrSUQwcJR0Xqyqwrt g7onXP1VnOnkhA1rPcZty6SyJI+6YwsE9inmS2STN0aWemP+A1OufXE2SuTJ/tlYefPw O+Aohbw5oGhx0AgOAw15LbqfVYrT+Uif4xvrox57IjbB3zd8WzW/DlEzxmCwt12P5JMX CPDYxP/vNOjHVFsxxp6Q9PX+FW8ABMs3h4iFvCYKCZT/wz9iaDAOqptk5yZVpc7qy2Zb ++FrlnEHypgNZoE2wuA7GchXNqxr+Ozi8EAGYFnb2PBkUxWtvG4a7bk36ZU4Rcby9sjo yMUw== X-Gm-Message-State: AG10YOQNxeEd+Jn1ughHB0a/8hBPjUUP5+6W5R+BfF8HKkowsZQTdsLhzmLXO19UR/7FyA== X-Received: by 10.98.64.202 with SMTP id f71mr41782002pfd.113.1454933110100; Mon, 08 Feb 2016 04:05:10 -0800 (PST) Received: from localhost.localdomain ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id 17sm43082945pfq.51.2016.02.08.04.05.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 04:05:08 -0800 (PST) From: sunil.kovvuri@gmail.com To: netdev@vger.kernel.org Subject: [PATCH 4/6] net: thunderx: bgx: Use standard firmware node infrastructure. Date: Mon, 8 Feb 2016 17:37:50 +0530 Message-Id: <1454933272-45005-5-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1454933272-45005-1-git-send-email-sunil.kovvuri@gmail.com> References: <1454933272-45005-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160208_040531_567807_B49333BD X-CRM114-Status: GOOD ( 16.00 ) X-Spam-Score: -2.7 (--) 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=-4.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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; } }