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 0BAD0C77B60 for ; Sun, 30 Apr 2023 11:44:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YrZnv4hENeQzj/uuCZvzPNk5tVit8WC4nsI9X/Etntk=; b=itGD6tEttEysjl 2psXQSX3qARl1vjuL53wWtcWqTSXTe1YFasMp5eobK/9t+q3ou42AyGyX+J/sb3DVFogds5g9JIeL 8/5iCkqH9s+cSnQtIg5k/hP1GYdqEnxf77KPCj3YdOBY9LnuRgEdSeBzf8jWitOaciL7Y+i8kgkKK MBaaLRaxqGd5H1davO/MyntUu7ZSD0rBgTvVFLAHwaWODjC4/+yxf1CIMal/SAe4+1UPqS+uEBWAn yNTZ5lmwGlNpIkPuoMwhG+WoUdGbk97a0cA9gwMD48QARtxEcZtg8OGsUcNPxHM2XoSDxiVFXwxeF SAKW7RsFNaunVom+0O/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pt5Sj-00E6F6-1F; Sun, 30 Apr 2023 11:43:29 +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-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-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel