Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2166409pxu; Sat, 17 Oct 2020 14:09:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYn2U1iB6VlVEG4Gs0+B8BvgYmVo/P01m1Td2a1y0cWZrXD2d5aZup/IcXeiDaOoOOpbRG X-Received: by 2002:aa7:df0c:: with SMTP id c12mr11009582edy.234.1602968951987; Sat, 17 Oct 2020 14:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602968951; cv=none; d=google.com; s=arc-20160816; b=mDahQSdIrkgF+YJMKsY7a4U98rakSFgsWzZcx8UYr+/414gCdH/oUYJyhgNnql80lk ESO/hXTyIF7DIgLljqS7fete2lW7yCbuoEE5HsANwEgPLKSUCoKIyvSQYzOEDPTaKBYA 4D+RYwG4fcQbw6bsG3Gw4X8Ts5dA6zjXzbigQzTG6wlb4/tyAC8JPjuck5b0cZdH333K HW7n93PY1Ke68ROiyjvmhRWHUUlCOZDtCFSxda8n3Lgh27fkvtumFwq8POvmddZelXXZ +WfOBbuRoLmhGzlxd7FYtfbGszmCEkTXKCY2jw+plodQ1TWZw60ZuXxLG2CCbXqNwdrI L6Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=NRn0UCghwLQ/EXflWbFvCLdZcfhT08Ma9SK0yZ7zIhw=; b=KkrK9WS9mWVWBv04q2oQz7RWZq35lbljsktG5fMf6bPzFyeYhFy7gh7mKHVx8uP9Rt woEnGU7qA15gzLpZGKjwqmp7o/YVwbZ2IIcVCN0dYH53hJJQa86wRngRqQZ9bdubZIXX jREKZ9gQBBapBJN1Agbtw8JQctNKTbXXGrXOntOPdK3a0eyGjDFIxROVO7ZTD5lB9A/R 8GzsFQbSxiWLuMMscHw/5Wfc4r76N5KFr0StQsXejDP9QL5jZoOrTSkj1OzBRmhJvCdU XLMKTCGM55gplTcI2qrmSO2qqKrNyGqmt1XDS4B/wjKAXnMY/lSUOCT8spkV2m3w4csH 0oQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o15si4354765eds.367.2020.10.17.14.08.39; Sat, 17 Oct 2020 14:09:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438950AbgJQUjq (ORCPT + 99 others); Sat, 17 Oct 2020 16:39:46 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:32834 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438904AbgJQUjp (ORCPT ); Sat, 17 Oct 2020 16:39:45 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1kTszK-002BsT-N6; Sat, 17 Oct 2020 22:39:38 +0200 Date: Sat, 17 Oct 2020 22:39:38 +0200 From: Andrew Lunn To: Ivan Mikhaylov Cc: "David S . Miller" , Jakub Kicinski , Po-Yu Chuang , Joel Stanley , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org Subject: Re: [PATCH v1 2/2] net: ftgmac100: add handling of mdio/phy nodes for ast2400/2500 Message-ID: <20201017203938.GR456889@lunn.ch> References: <20201015124917.8168-1-i.mikhaylov@yadro.com> <20201015124917.8168-3-i.mikhaylov@yadro.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201015124917.8168-3-i.mikhaylov@yadro.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > - err = mdiobus_register(priv->mii_bus); > + mdio_np = of_get_child_by_name(np, "mdio"); > + if (mdio_np) > + err = of_mdiobus_register(priv->mii_bus, mdio_np); > + else > + err = mdiobus_register(priv->mii_bus); of_mdiobus_register() will do the right thing if passed a NULL pointer for mdio_np. > + > if (err) { > dev_err(priv->dev, "Cannot register MDIO bus!\n"); > goto err_register_mdiobus; > } > > + if (mdio_np) > + of_node_put(mdio_np); of_node_put() is also happy with a NULL pointer. > + > return 0; > > err_register_mdiobus: > @@ -1830,10 +1839,23 @@ static int ftgmac100_probe(struct platform_device *pdev) > } else if (np && of_get_property(np, "phy-handle", NULL)) { > struct phy_device *phy; > > + /* Support "mdio"/"phy" child nodes for ast2400/2500 with > + * an embedded MDIO controller. Automatically scan the DTS for > + * available PHYs and register them. > + */ > + if (of_device_is_compatible(np, "aspeed,ast2400-mac") || > + of_device_is_compatible(np, "aspeed,ast2500-mac")) { > + err = ftgmac100_setup_mdio(netdev); > + if (err) > + goto err_setup_mdio; > + } > + > phy = of_phy_get_and_connect(priv->netdev, np, > &ftgmac100_adjust_link); > if (!phy) { > dev_err(&pdev->dev, "Failed to connect to phy\n"); > + if (priv->mii_bus) > + mdiobus_unregister(priv->mii_bus); > goto err_setup_mdio; It would be nice if the tear down was symmetric to the setup. Add an ftgmac100_remove_mdio(), and call it on the same condition as ftgmac100_setup_mdio(). Andrew