diff mbox series

[2/6] net: stmmac: dwmac-sun8i: remove regulator

Message ID 20220509074857.195302-3-clabbe@baylibre.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series arm64: add ethernet to orange pi 3 | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: mcoquelin.stm32@gmail.com linux-stm32@st-md-mailman.stormreply.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 76 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Corentin LABBE May 9, 2022, 7:48 a.m. UTC
Now regulator is handled by phy core, there is no need to handle it in
stmmac driver.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 37 +------------------
 1 file changed, 2 insertions(+), 35 deletions(-)

Comments

Andre Przywara May 9, 2022, 2:09 p.m. UTC | #1
On Mon,  9 May 2022 07:48:53 +0000
Corentin Labbe <clabbe@baylibre.com> wrote:

Hi,

> Now regulator is handled by phy core, there is no need to handle it in
> stmmac driver.

I don't think you can do that, since we definitely need to maintain
compatibility with *older* DTs.
Is there a real need for this patch, or is it just a cleanup?
I mean we should be able to keep both approaches in, and the respective
board and DT version selects which it is using.

Cheers,
Andre

> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---
>  .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 37 +------------------
>  1 file changed, 2 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index f834472599f7..17888813c707 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> @@ -17,7 +17,6 @@
>  #include <linux/phy.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> -#include <linux/regulator/consumer.h>
>  #include <linux/regmap.h>
>  #include <linux/stmmac.h>
>  
> @@ -59,7 +58,6 @@ struct emac_variant {
>  
>  /* struct sunxi_priv_data - hold all sunxi private data
>   * @ephy_clk:	reference to the optional EPHY clock for the internal PHY
> - * @regulator:	reference to the optional regulator
>   * @rst_ephy:	reference to the optional EPHY reset for the internal PHY
>   * @variant:	reference to the current board variant
>   * @regmap:	regmap for using the syscon
> @@ -69,7 +67,6 @@ struct emac_variant {
>   */
>  struct sunxi_priv_data {
>  	struct clk *ephy_clk;
> -	struct regulator *regulator;
>  	struct reset_control *rst_ephy;
>  	const struct emac_variant *variant;
>  	struct regmap_field *regmap_field;
> @@ -568,29 +565,11 @@ static int sun8i_dwmac_init(struct platform_device *pdev, void *priv)
>  {
>  	struct net_device *ndev = platform_get_drvdata(pdev);
>  	struct sunxi_priv_data *gmac = priv;
> -	int ret;
>  
> -	if (gmac->regulator) {
> -		ret = regulator_enable(gmac->regulator);
> -		if (ret) {
> -			dev_err(&pdev->dev, "Fail to enable regulator\n");
> -			return ret;
> -		}
> -	}
> -
> -	if (gmac->use_internal_phy) {
> -		ret = sun8i_dwmac_power_internal_phy(netdev_priv(ndev));
> -		if (ret)
> -			goto err_disable_regulator;
> -	}
> +	if (gmac->use_internal_phy)
> +		return sun8i_dwmac_power_internal_phy(netdev_priv(ndev));
>  
>  	return 0;
> -
> -err_disable_regulator:
> -	if (gmac->regulator)
> -		regulator_disable(gmac->regulator);
> -
> -	return ret;
>  }
>  
>  static void sun8i_dwmac_core_init(struct mac_device_info *hw,
> @@ -1034,9 +1013,6 @@ static void sun8i_dwmac_exit(struct platform_device *pdev, void *priv)
>  
>  	if (gmac->variant->soc_has_internal_phy)
>  		sun8i_dwmac_unpower_internal_phy(gmac);
> -
> -	if (gmac->regulator)
> -		regulator_disable(gmac->regulator);
>  }
>  
>  static void sun8i_dwmac_set_mac_loopback(void __iomem *ioaddr, bool enable)
> @@ -1157,15 +1133,6 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	/* Optional regulator for PHY */
> -	gmac->regulator = devm_regulator_get_optional(dev, "phy");
> -	if (IS_ERR(gmac->regulator)) {
> -		if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -		dev_info(dev, "No regulator found\n");
> -		gmac->regulator = NULL;
> -	}
> -
>  	/* The "GMAC clock control" register might be located in the
>  	 * CCU address range (on the R40), or the system control address
>  	 * range (on most other sun8i and later SoCs).
Corentin LABBE May 9, 2022, 2:38 p.m. UTC | #2
Le Mon, May 09, 2022 at 03:09:07PM +0100, Andre Przywara a écrit :
> On Mon,  9 May 2022 07:48:53 +0000
> Corentin Labbe <clabbe@baylibre.com> wrote:
> 
> Hi,
> 
> > Now regulator is handled by phy core, there is no need to handle it in
> > stmmac driver.
> 
> I don't think you can do that, since we definitely need to maintain
> compatibility with *older* DTs.
> Is there a real need for this patch, or is it just a cleanup?
> I mean we should be able to keep both approaches in, and the respective
> board and DT version selects which it is using.
> 
> Cheers,
> Andre
> 

It is just a cleanup. But yes, probably keeping it will be necessary for easy compatibility.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index f834472599f7..17888813c707 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -17,7 +17,6 @@ 
 #include <linux/phy.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
-#include <linux/regulator/consumer.h>
 #include <linux/regmap.h>
 #include <linux/stmmac.h>
 
@@ -59,7 +58,6 @@  struct emac_variant {
 
 /* struct sunxi_priv_data - hold all sunxi private data
  * @ephy_clk:	reference to the optional EPHY clock for the internal PHY
- * @regulator:	reference to the optional regulator
  * @rst_ephy:	reference to the optional EPHY reset for the internal PHY
  * @variant:	reference to the current board variant
  * @regmap:	regmap for using the syscon
@@ -69,7 +67,6 @@  struct emac_variant {
  */
 struct sunxi_priv_data {
 	struct clk *ephy_clk;
-	struct regulator *regulator;
 	struct reset_control *rst_ephy;
 	const struct emac_variant *variant;
 	struct regmap_field *regmap_field;
@@ -568,29 +565,11 @@  static int sun8i_dwmac_init(struct platform_device *pdev, void *priv)
 {
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct sunxi_priv_data *gmac = priv;
-	int ret;
 
-	if (gmac->regulator) {
-		ret = regulator_enable(gmac->regulator);
-		if (ret) {
-			dev_err(&pdev->dev, "Fail to enable regulator\n");
-			return ret;
-		}
-	}
-
-	if (gmac->use_internal_phy) {
-		ret = sun8i_dwmac_power_internal_phy(netdev_priv(ndev));
-		if (ret)
-			goto err_disable_regulator;
-	}
+	if (gmac->use_internal_phy)
+		return sun8i_dwmac_power_internal_phy(netdev_priv(ndev));
 
 	return 0;
-
-err_disable_regulator:
-	if (gmac->regulator)
-		regulator_disable(gmac->regulator);
-
-	return ret;
 }
 
 static void sun8i_dwmac_core_init(struct mac_device_info *hw,
@@ -1034,9 +1013,6 @@  static void sun8i_dwmac_exit(struct platform_device *pdev, void *priv)
 
 	if (gmac->variant->soc_has_internal_phy)
 		sun8i_dwmac_unpower_internal_phy(gmac);
-
-	if (gmac->regulator)
-		regulator_disable(gmac->regulator);
 }
 
 static void sun8i_dwmac_set_mac_loopback(void __iomem *ioaddr, bool enable)
@@ -1157,15 +1133,6 @@  static int sun8i_dwmac_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	/* Optional regulator for PHY */
-	gmac->regulator = devm_regulator_get_optional(dev, "phy");
-	if (IS_ERR(gmac->regulator)) {
-		if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-		dev_info(dev, "No regulator found\n");
-		gmac->regulator = NULL;
-	}
-
 	/* The "GMAC clock control" register might be located in the
 	 * CCU address range (on the R40), or the system control address
 	 * range (on most other sun8i and later SoCs).