linux-sunxi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Corentin Labbe <clabbe@baylibre.com>
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
Date: Wed, 16 Nov 2022 02:51:23 +0100	[thread overview]
Message-ID: <Y3RCG/Xt4y3OfisD@lunn.ch> (raw)
In-Reply-To: <20221115073603.3425396-3-clabbe@baylibre.com>

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 <clabbe@baylibre.com>
> ---
>  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 <linux/fwnode_mdio.h>
>  #include <linux/of.h>
>  #include <linux/phy.h>
> +#include <linux/regulator/consumer.h>
>  #include <linux/pse-pd/pse.h>

These headers are sorted, so please add regulator after pse.

>  
>  MODULE_AUTHOR("Calvin Johnson <calvin.johnson@oss.nxp.com>");
> @@ -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", &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

  reply	other threads:[~2022-11-16  1:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15  7:36 [PATCH v4 0/3] arm64: add ethernet to orange pi 3 Corentin Labbe
2022-11-15  7:36 ` [PATCH v4 1/3] regulator: Add of_regulator_bulk_get_all Corentin Labbe
2022-11-15 10:03   ` Mark Brown
2022-11-15 10:18     ` Corentin LABBE
2022-11-15 10:34       ` Mark Brown
2022-11-15 10:42         ` Russell King (Oracle)
2022-11-15 11:16           ` Mark Brown
2022-11-15 11:38             ` Russell King (Oracle)
2022-11-15 13:48             ` Andrew Lunn
2022-11-18 16:14   ` Mark Brown
2022-11-15  7:36 ` [PATCH v4 2/3] phy: handle optional regulator for PHY Corentin Labbe
2022-11-16  1:51   ` Andrew Lunn [this message]
2022-11-16  1:58   ` Andrew Lunn
2022-11-15  7:36 ` [PATCH v4 3/3] arm64: dts: allwinner: orange-pi-3: Enable ethernet Corentin Labbe
2022-11-16  1:39 ` [PATCH v4 0/3] arm64: add ethernet to orange pi 3 Andrew Lunn
2022-11-18 16:11 ` (subset) " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y3RCG/Xt4y3OfisD@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=broonie@kernel.org \
    --cc=calvin.johnson@oss.nxp.com \
    --cc=clabbe@baylibre.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh+dt@kernel.org \
    --cc=samuel@sholland.org \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).