From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EACD6210F8; Thu, 21 Dec 2023 08:57:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="EOiQtYjb" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3BL8uVRa014634; Thu, 21 Dec 2023 02:56:31 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1703148991; bh=16IxcBEYZK9twQ1G/yQmRxe1As8IXBcEe8yradY/0k8=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=EOiQtYjbdl2KdH+EqJDqJOwxPYmI0wE86tJ4Tnkq8/vVJSZUFOmfo4lpTPaWuPq5n 3QijJeWBLHvfBjtlGFYHgFyDfYNTVn0nbchvNpw0A2PKGb5wZjMGQuEF7tc/fDfRd8 qh5RE1qqwq39c49MQzZM0+Nmrlzj95WReElkv5OE= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3BL8uVCH063030 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 21 Dec 2023 02:56:31 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 21 Dec 2023 02:56:31 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 21 Dec 2023 02:56:31 -0600 Received: from [172.24.227.247] (uda0500640.dhcp.ti.com [172.24.227.247]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3BL8uORk081324; Thu, 21 Dec 2023 02:56:25 -0600 Message-ID: Date: Thu, 21 Dec 2023 14:26:24 +0530 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH net-next] net: dsa: mt7530: register OF node for internal MDIO bus Content-Language: en-US To: =?UTF-8?B?QXLEsW7DpyDDnE5BTA==?= , Daniel Golle , Landen Chao , DENG Qingfang , Sean Wang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno CC: David Bauer , , , , , , , Ravi Gunasekaran References: <20231220173539.59071-1-arinc.unal@arinc9.com> From: Ravi Gunasekaran In-Reply-To: <20231220173539.59071-1-arinc.unal@arinc9.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 On 12/20/23 11:05 PM, Arınç ÜNAL wrote: > From: David Bauer > > The MT753x switches provide a switch-internal MDIO bus for the embedded > PHYs. > > Register a OF sub-node on the switch OF-node for this internal MDIO bus. > This allows to configure the embedded PHYs using device-tree. > > Signed-off-by: David Bauer > Signed-off-by: Daniel Golle > Signed-off-by: Arınç ÜNAL > --- > drivers/net/dsa/mt7530.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c > index 391c4dbdff42..f8ecc354630b 100644 > --- a/drivers/net/dsa/mt7530.c > +++ b/drivers/net/dsa/mt7530.c > @@ -2155,10 +2155,13 @@ mt7530_setup_mdio(struct mt7530_priv *priv) > { > struct dsa_switch *ds = priv->ds; > struct device *dev = priv->dev; > + struct device_node *np, *mnp; > struct mii_bus *bus; > static int idx; > int ret; > > + np = priv->dev->of_node; > + > bus = devm_mdiobus_alloc(dev); > if (!bus) > return -ENOMEM; > @@ -2177,7 +2180,9 @@ mt7530_setup_mdio(struct mt7530_priv *priv) > if (priv->irq) > mt7530_setup_mdio_irq(priv); > > - ret = devm_mdiobus_register(dev, bus); > + mnp = of_get_child_by_name(np, "mdio"); If the node is not found, then the return value would be NULL. Though devm_of_mdiobus_register() and of_node_put() take care of NULL references, other drivers that use devm_of_mdiobus_register() mostly perform a early exit if the node is NULL. > + ret = devm_of_mdiobus_register(dev, bus, mnp); > + of_node_put(mnp); > if (ret) { > dev_err(dev, "failed to register MDIO bus: %d\n", ret); > if (priv->irq) -- Regards, Ravi