From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D36FCC77B73 for ; Sun, 30 Apr 2023 11:43:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HENBRL9viTonKj0G4mw1qmVKcwD9e9vmZ5wZU65yIJo=; b=Qp/7DgLQkIDn5rthIZj+h/rVGG tIER/LDcJ+FKM9I56Yr/wtXbaEtstTriQPTNbCz6l1MCRY/uE63io7/WkLGphA8pRoXbJ877m5Kys jaI5NJLcLCY7n68qZFBbnwwPndD2h0pgScVOsxelWCyxvb4zyKJkTkohhxM4yl4NYN8flb9q0kGD6 gILlUvHtBInbukO1rCtmiqEj55Gn+S1PuLnSgXEhW9i6vwws/+9FeWq+A+8PVPw8UlJmIX98APut2 x0vaVMtVYgz0F+7XzI5zbc00K3DVxYyaQKYgNGrmuFUKc1Q/ipBmjOeHw+UO1i0g+CC+1KR5GPjcS bxWLnVXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pt5Sk-00E6FG-0r; Sun, 30 Apr 2023 11:43:30 +0000 Received: from fudo.makrotopia.org ([2a07:2ec0:3002::71]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pt5Sg-00E6E9-08; Sun, 30 Apr 2023 11:43:27 +0000 Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pt5SB-0002tz-1S; Sun, 30 Apr 2023 13:42:55 +0200 Date: Sun, 30 Apr 2023 12:42:46 +0100 From: Daniel Golle To: David Bauer Cc: Sean Wang , Landen Chao , DENG Qingfang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH 1/2] mt7530: register OF node for internal MDIO bus Message-ID: References: <20230430112834.11520-1-mail@david-bauer.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230430112834.11520-1-mail@david-bauer.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230430_044326_081155_3D5F7716 X-CRM114-Status: GOOD ( 21.33 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On Sun, Apr 30, 2023 at 01:28:32PM +0200, David Bauer wrote: > 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 Acked-by: Daniel Golle I've got a similar commit in my tree for a while, yours is better because you care to of_node_put(mnp) ;) And yes, this will be fine also if mnp is NULL, the MDIO bus will still be registered (just without the reference to the OF node) and also of_node_put is fine being called for NULL. > --- > 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 c680873819b0..7e8ea5b75c3e 100644 > --- a/drivers/net/dsa/mt7530.c > +++ b/drivers/net/dsa/mt7530.c > @@ -2119,10 +2119,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; > @@ -2141,7 +2144,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"); > + 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) > -- > 2.39.2 >