From patchwork Thu Dec 17 04:02:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "David Rivshin (Allworx)" X-Patchwork-Id: 7869351 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 6BE3D9F32E for ; Thu, 17 Dec 2015 04:05:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91C7A203E3 for ; Thu, 17 Dec 2015 04:05:36 +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 CA8E82022D for ; Thu, 17 Dec 2015 04:05:35 +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 1a9Pnf-00033Y-Uk; Thu, 17 Dec 2015 04:04:19 +0000 Received: from mail-qg0-x22d.google.com ([2607:f8b0:400d:c04::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a9PmU-0002MW-OS for linux-arm-kernel@lists.infradead.org; Thu, 17 Dec 2015 04:03:07 +0000 Received: by mail-qg0-x22d.google.com with SMTP id 21so52427191qgx.1 for ; Wed, 16 Dec 2015 20:02:46 -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=ODL1IX3Iu7ZF9FFWSMZHF+ZGG4Oa8H2R8R1xwwZ0Tz8=; b=wuaYELV94Ady+UF2zMRjgXA7Ehdah0gO+uvfAk+zLoeXyHzN9qPnBAzoKGlxuy+VQH y5jfQAFDLCzjngD9l67goaO9Ov2zonxGRsq390OtmJj0mtv9VLzaDdM447mm7zCLo6u7 E8D+ZE193bMmey8gaZri93a9IaMhFsyfTGKx/EO3hGEtGdnZuT53whybF/ABa254XimY GTul7KR/7PIrh12jHqbji+4s5yF7qEdddEbI5r25Eka2YV6UxxU5pjPtL7JYgtT5UWhw s+IrpnbG2mybVpB09VktiJTyJzK0WjnVcE5Pes2QcoYjHIk2u2TdGuoaazgc5tfK4/fm lIHg== X-Received: by 10.140.102.35 with SMTP id v32mr66721021qge.72.1450324965810; Wed, 16 Dec 2015 20:02:45 -0800 (PST) Received: from drivshin-linux.crosskeys.inscitek.com ([24.213.148.66]) by smtp.gmail.com with ESMTPSA id a15sm3944731qkj.42.2015.12.16.20.02.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2015 20:02:45 -0800 (PST) From: "David Rivshin (Allworx)" To: netdev@vger.kernel.org Subject: [PATCH v2 3/3] drivers: net: cpsw: increment reference count on fixed-link PHY node Date: Wed, 16 Dec 2015 23:02:11 -0500 Message-Id: <9a0128ebbc20ca9b911d24205408a38d8474725c.1450309613.git.drivshin@allworx.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: <20151209223115.6c5a400f.drivshin.allworx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151216_200306_963381_C521FD2A X-CRM114-Status: GOOD ( 13.27 ) 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: Markus Brunner , Daniel Trautmann , Mugunthan V N , Pascal Speck , linux-omap@vger.kernel.org, David Miller , linux-arm-kernel@lists.infradead.org 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.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Rivshin When a fixed-link sub-node exists in a slave node, the slave node is also the PHY node. Since this is a separate use of the slave node, of_node_get() should be used to increment the reference count. Fixes: 1f71e8c96fc6 ("drivers: net: cpsw: Add support for fixed-link PHY") Signed-off-by: David Rivshin --- 'pd' was renamed to 'phy_dev' to better fit the naming convention in the function/file. drivers/net/ethernet/ti/cpsw.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.5.0 diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index bc6d20d..3b489ca 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -2036,16 +2036,21 @@ static int cpsw_probe_dt(struct cpsw_priv *priv, priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0); parp = of_get_property(slave_node, "phy_id", &lenp); if (of_phy_is_fixed_link(slave_node)) { - struct phy_device *pd; + struct device_node *phy_node; + struct phy_device *phy_dev; + /* In the case of a fixed PHY, the DT node associated + * to the PHY is the Ethernet MAC DT node. + */ ret = of_phy_register_fixed_link(slave_node); if (ret) return ret; - pd = of_phy_find_device(slave_node); - if (!pd) + phy_node = of_node_get(slave_node); + phy_dev = of_phy_find_device(phy_node); + if (!phy_dev) return -ENODEV; snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), - PHY_ID_FMT, pd->bus->id, pd->addr); + PHY_ID_FMT, phy_dev->bus->id, phy_dev->addr); } else if (parp) { u32 phyid; struct device_node *mdio_node;