Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp11043rdb; Thu, 21 Dec 2023 00:57:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IEyx+XfDLFoeq4koTMNI5IfFoh075qQWmT+eraaF3EEL/EjSnEJDJaNnAtN4mpY9srQCSFr X-Received: by 2002:a05:620a:179e:b0:77d:783b:89b4 with SMTP id ay30-20020a05620a179e00b0077d783b89b4mr25247469qkb.69.1703149059843; Thu, 21 Dec 2023 00:57:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703149059; cv=none; d=google.com; s=arc-20160816; b=dCllEVs+hBZBAjwO+Ckw1rNtE3jcV+VHHuyh/Mi0CaE0rLYLzc0+cyNl6SAuLp13S3 Y2aKhBqTMDLoxwO78IZqI9PO+1K68XPukIt0E4mRVmXZNV9O6AL6WhTjjtNw4U0VutzG hHEWGdrsCa08lEsov3gogZGCF+iPK5x3y4KWHAH3TFvI3v77fW2dnPQMtIQRyghE43dB 1qC4p0aP/y3ChVt+OVj2GIBfrDoNTbO8z9QbejkWN7Hamjgp1JLfxhCe+K0/q5QN+DBN 778kCzEQ7fQH3AkYyz9H5ADEaryuwmEqfY/p/m49EeDeVccHFZOgxwq9W43qtMrc1+dy Y5cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=16IxcBEYZK9twQ1G/yQmRxe1As8IXBcEe8yradY/0k8=; fh=O9z4ZZdCGc5MolKF2+uXmOaW9HA9HPyd8RzRv07z3V8=; b=R9ZxkYrz435IsVP342smXptBj0fd4LfCzsQK3POih4FNx4nDWxMuZZjOfxPlwrRl5z rRnTfXlm0v38Mym6hwDvCSiGdQvBQJt262U1qvOxpOs/MzqJ6UFpZGrm033g7XrKKp5r 7lPF0OSi6rVzGFJkbR4OsykuKr+z2TaG/cLF7acl+v6nEWbEFM1dqNNXhCrDYmc4InMU Bj1cyw5vop8PxJwCBJLbUrRIZi+9EZfpmcMMU0vkhtny3aRYvVd1Q33vHIMp/u84R8xw rfxUd1sNOEooAdb8MZm+IKC6ax1u9MruVmeybpHWuMbKT1QcCaRrLMWnAkmDcqaEwF0U ahxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=EOiQtYjb; spf=pass (google.com: domain of linux-kernel+bounces-8030-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8030-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f17-20020a05620a15b100b0077f76453bcesi1741796qkk.30.2023.12.21.00.57.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 00:57:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8030-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=EOiQtYjb; spf=pass (google.com: domain of linux-kernel+bounces-8030-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8030-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 927261C23723 for ; Thu, 21 Dec 2023 08:57:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FA9C208C4; Thu, 21 Dec 2023 08:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="EOiQtYjb" X-Original-To: linux-kernel@vger.kernel.org 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 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: linux-kernel@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