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 10EDAC4332F for ; Wed, 16 Nov 2022 01:53:26 +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=Vqreo9kKZuaIS9gabNVEQmeCWflgor2B/DMaVUzh830=; b=x1cZd5B+Pg+N4A LjIOq9PL9Gpys4gCD97jzsZGGTDZ7JZcHU5/esaPPQZwqllfOpua3e42wKOmSb3iNxo0gc5lO8Zt1 uAMUKk7xN/4iNchZDwZXGXwNF+OlrPF0bRtVDbWvDbsrL7DnGGYtgWZuQAoEwgqqbQnj38Nlvtjkf mhLuy9eeX2QWb4UmAtARNVqlR4eSGmuaAGrqY2PjaKYpNd2YBnmZRm8J0x3Fo+XFw0iWQkt6FUZfa 8jVi9L7xykbPA1P65NQAFSAaIOo1ZIqtKy5y2bp4HKA5Lgjd1hIJw+2RQ2bNdecWH1JdW4m1cd9Ki fdCrTnnDhwwOhzlleVVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov7aq-00GJ09-OZ; Wed, 16 Nov 2022 01:52:01 +0000 Received: from vps0.lunn.ch ([156.67.10.101]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov7an-00GIys-8n for linux-arm-kernel@lists.infradead.org; Wed, 16 Nov 2022 01:51:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=Kuh/N0Wx2kjpMO629JuP6BcKFcPo/nef5LQjffP+jxk=; b=sxjxv8L6ye11bItWDh5pYym26x 4zn1UO3NmgBWEaKA6PHD4xgqMZlvSNiTA9Kf/1tm08wE52/R2mdNoHl5veW6ZldZkkAxe5JqI3zeI xaEuy8d9U6iVak7VssTEME0+wdtAH2U7CVFG/jtamNJSQYsMu2UoPuMKBgQEZanmAEcw=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1ov7aF-002WAO-AZ; Wed, 16 Nov 2022 02:51:23 +0100 Date: Wed, 16 Nov 2022 02:51:23 +0100 From: Andrew Lunn To: Corentin Labbe Cc: broonie@kernel.org, calvin.johnson@oss.nxp.com, davem@davemloft.net, edumazet@google.com, hkallweit1@gmail.com, jernej.skrabec@gmail.com, krzysztof.kozlowski+dt@linaro.org, kuba@kernel.org, lgirdwood@gmail.com, linux@armlinux.org.uk, pabeni@redhat.com, robh+dt@kernel.org, samuel@sholland.org, wens@csie.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, netdev@vger.kernel.org, linux-sunxi@googlegroups.com Subject: Re: [PATCH v4 2/3] phy: handle optional regulator for PHY Message-ID: References: <20221115073603.3425396-1-clabbe@baylibre.com> <20221115073603.3425396-3-clabbe@baylibre.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221115073603.3425396-3-clabbe@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221115_175157_335686_21286058 X-CRM114-Status: GOOD ( 20.69 ) 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 Tue, Nov 15, 2022 at 07:36:02AM +0000, Corentin Labbe wrote: > Add handling of optional regulators for PHY. > Regulators need to be enabled before PHY scanning, so MDIO bus > initiate this task. > > Signed-off-by: Corentin Labbe > --- > drivers/net/mdio/fwnode_mdio.c | 31 ++++++++++++++++++++++++++++++- > drivers/net/phy/phy_device.c | 10 ++++++++++ > include/linux/phy.h | 3 +++ > 3 files changed, 43 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c > index 689e728345ce..19a16072d4ca 100644 > --- a/drivers/net/mdio/fwnode_mdio.c > +++ b/drivers/net/mdio/fwnode_mdio.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include These headers are sorted, so please add regulator after pse. > > MODULE_AUTHOR("Calvin Johnson "); > @@ -116,7 +117,9 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus, > struct phy_device *phy; > bool is_c45 = false; > u32 phy_id; > - int rc; > + int rc, reg_cnt = 0; > + struct regulator_bulk_data *consumers = NULL; > + struct device_node __maybe_unused *nchild = NULL; Reverse Christmas tree. > > psec = fwnode_find_pse_control(child); > if (IS_ERR(psec)) > @@ -133,6 +136,26 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus, > if (rc >= 0) > is_c45 = true; > > +#ifdef CONFIG_OF Do you need this #ifdef ? Generally, all of_* functions should have stubs if CONFIG_OF is not enabled. It would be nice to remove this, so we get compile testing. And the __maybe_unused above is then probably not needed. > + for_each_child_of_node(bus->dev.of_node, nchild) { > + u32 reg; > + > + of_property_read_u32(nchild, "reg", ®); > + if (reg != addr) > + continue; > + reg_cnt = of_regulator_bulk_get_all(&bus->dev, nchild, &consumers); > + if (reg_cnt > 0) { > + rc = regulator_bulk_enable(reg_cnt, consumers); > + if (rc) > + return rc; > + } > + if (reg_cnt < 0) { > + dev_err(&bus->dev, "Fail to regulator_bulk_get_all err=%d\n", reg_cnt); > + return reg_cnt; > + } > + } > +#endif > + Andrew _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel