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: 7869321 Return-Path: X-Original-To: patchwork-linux-omap@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 84AC09F32E for ; Thu, 17 Dec 2015 04:03:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF0E7203EC for ; Thu, 17 Dec 2015 04:03:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD221203E3 for ; Thu, 17 Dec 2015 04:03:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932244AbbLQEDD (ORCPT ); Wed, 16 Dec 2015 23:03:03 -0500 Received: from mail-qg0-f46.google.com ([209.85.192.46]:33670 "EHLO mail-qg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755642AbbLQECq (ORCPT ); Wed, 16 Dec 2015 23:02:46 -0500 Received: by mail-qg0-f46.google.com with SMTP id k90so19156306qge.0; 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 Cc: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, David Miller , Markus Brunner , Mugunthan V N , Pascal Speck , Daniel Trautmann 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> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 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 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;