Skip to contentSkip to conversation

net: phy: micrel: Code clean-up

PATCH In review Christophe JAILLET 3 participants 9 messages May 15 – May 19

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net: phy: micrel: Code clean-up

This serie is only some clean-up related to
drivers/net/mdio/mdio-mscc-miim.c

It depends on a patch called "[PATCH net-next] net: phy: micrel: use dev_err_probe()" that has been sent recently.

Note that in the 2nd patch, the order of the calls in the remove function is changed. I don't think that it matters, but I'm always relunctent to change such things.

The patches are compile tested only.

Christophe JAILLET (3):
net: mdio: mscc-miim: Remove some redundant code
net: mdio: mscc-miim: Use devm_clk_get_optional_enabled()
net: mdio: mscc-miim: Use devm_of_mdiobus_register()

 drivers/net/mdio/mdio-mscc-miim.c | 34 +++++--------------------------
 1 file changed, 5 insertions(+), 29 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/3 net: mdio: mscc-miim: Remove some redundant code

*pbus is assign twice with the same value. Remove one of the redundant assignment.

---
 drivers/net/mdio/mdio-mscc-miim.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/mdio/mdio-mscc-miim.c +0 -2
index 259944d37fbd..03878bd9091d 100644
@@ -233,8 +233,6 @@ int mscc_miim_setup(struct device *dev, struct mii_bus **pbus, const char *name,
 
 	miim = bus->priv;
 
-	*pbus = bus;
-
 	miim->regs = mii_regmap;
 	miim->mii_status_offset = status_offset;
 	miim->ignore_read_errors = ignore_read_errors;
Signature · 1 line
2.54.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3 net-next] net: mdio: mscc-miim: Remove some redundant code

Hi,

Quoted 4 lines · Christophe JAILLET

*pbus is assign twice with the same value. Remove one of the redundant assignment.

Quoted 17 lines
---
  drivers/net/mdio/mdio-mscc-miim.c | 2 --
  1 file changed, 2 deletions(-)
drivers/net/mdio/mdio-mscc-miim.c +0 -2
index 259944d37fbd..03878bd9091d 100644
@@ -233,8 +233,6 @@ int mscc_miim_setup(struct device *dev, struct mii_bus **pbus, const char *name,
 
  	miim = bus->priv;
 
-	*pbus = bus;
-
  	miim->regs = mii_regmap;
  	miim->mii_status_offset = status_offset;
  	miim->ignore_read_errors = ignore_read_errors;
#3 lore raw

PATCH 2/3 net: mdio: mscc-miim: Use devm_clk_get_optional_enabled()

In reply to Christophe JAILLET

Use devm_clk_get_optional_enabled() instead of clk_prepare_enable() and clk_disable_unprepare().

This saves some lines of code and simplifies error handling in the probe.

---
Compile tested only.

In the remove sequence, clk_disable_unprepare() and mdiobus_unregister() are not called with the same order anymore. I don't think that it matters.

---
 drivers/net/mdio/mdio-mscc-miim.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/net/mdio/mdio-mscc-miim.c +4 -16
index 03878bd9091d..4d8f60d458b8 100644
@@ -307,7 +307,7 @@ static int mscc_miim_probe(struct platform_device *pdev)
 	if (!miim->info)
 		return -EINVAL;
 
-	miim->clk = devm_clk_get_optional(dev, NULL);
+	miim->clk = devm_clk_get_optional_enabled(dev, NULL);
 	if (IS_ERR(miim->clk))
 		return PTR_ERR(miim->clk);
 
@@ -318,35 +318,23 @@ static int mscc_miim_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	ret = clk_prepare_enable(miim->clk);
-	if (ret)
-		return ret;
-
 	ret = mscc_miim_clk_set(bus);
 	if (ret)
-		goto out_disable_clk;
+		return ret;
 
 	ret = of_mdiobus_register(bus, np);
-	if (ret < 0) {
-		dev_err_probe(dev, ret, "Cannot register MDIO bus\n");
-		goto out_disable_clk;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot register MDIO bus\n");
 
 	platform_set_drvdata(pdev, bus);
 
 	return 0;
-
-out_disable_clk:
-	clk_disable_unprepare(miim->clk);
-	return ret;
 }
 
 static void mscc_miim_remove(struct platform_device *pdev)
 {
 	struct mii_bus *bus = platform_get_drvdata(pdev);
-	struct mscc_miim_dev *miim = bus->priv;
 
-	clk_disable_unprepare(miim->clk);
 	mdiobus_unregister(bus);
 }
 
Signature · 1 line
2.54.0
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3 net-next] net: mdio: mscc-miim: Use devm_clk_get_optional_enabled()

Hi,

Quoted 11 lines · Christophe JAILLET

Use devm_clk_get_optional_enabled() instead of clk_prepare_enable() and clk_disable_unprepare().

This saves some lines of code and simplifies error handling in the probe.

---
Compile tested only.

In the remove sequence, clk_disable_unprepare() and mdiobus_unregister() are not called with the same order anymore. I don't think that it matters.

If anything, I'd say this is better as the original ordering, as the remove path now mirrors the probe one.

Maxime

Quoted 56 lines
---
  drivers/net/mdio/mdio-mscc-miim.c | 20 ++++----------------
  1 file changed, 4 insertions(+), 16 deletions(-)
drivers/net/mdio/mdio-mscc-miim.c +4 -16
index 03878bd9091d..4d8f60d458b8 100644
@@ -307,7 +307,7 @@ static int mscc_miim_probe(struct platform_device *pdev)
  	if (!miim->info)
  		return -EINVAL;
 
-	miim->clk = devm_clk_get_optional(dev, NULL);
+	miim->clk = devm_clk_get_optional_enabled(dev, NULL);
  	if (IS_ERR(miim->clk))
  		return PTR_ERR(miim->clk);
 
@@ -318,35 +318,23 @@ static int mscc_miim_probe(struct platform_device *pdev)
  		return -EINVAL;
  	}
 
-	ret = clk_prepare_enable(miim->clk);
-	if (ret)
-		return ret;
-
  	ret = mscc_miim_clk_set(bus);
  	if (ret)
-		goto out_disable_clk;
+		return ret;
 
  	ret = of_mdiobus_register(bus, np);
-	if (ret < 0) {
-		dev_err_probe(dev, ret, "Cannot register MDIO bus\n");
-		goto out_disable_clk;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot register MDIO bus\n");
 
  	platform_set_drvdata(pdev, bus);
 
  	return 0;
-
-out_disable_clk:
-	clk_disable_unprepare(miim->clk);
-	return ret;
  }
 
  static void mscc_miim_remove(struct platform_device *pdev)
  {
  	struct mii_bus *bus = platform_get_drvdata(pdev);
-	struct mscc_miim_dev *miim = bus->priv;
 
-	clk_disable_unprepare(miim->clk);
  	mdiobus_unregister(bus);
  }
 
#5 lore raw

PATCH 3/3 net: mdio: mscc-miim: Use devm_of_mdiobus_register()

In reply to Christophe JAILLET

Use devm_of_mdiobus_register() instead of hand writing it. This saves some lines of code.

The remove function can be removed completely and the platform_set_drvdata() call at the end of the probe is now also useless and can be removed as-well.

---
Compile tested only.

---
 drivers/net/mdio/mdio-mscc-miim.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/net/mdio/mdio-mscc-miim.c +1 -11
index 4d8f60d458b8..7bdcf3e9baa0 100644
@@ -322,22 +322,13 @@ static int mscc_miim_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	ret = of_mdiobus_register(bus, np);
+	ret = devm_of_mdiobus_register(dev, bus, np);
 	if (ret < 0)
 		return dev_err_probe(dev, ret, "Cannot register MDIO bus\n");
 
-	platform_set_drvdata(pdev, bus);
-
 	return 0;
 }
 
-static void mscc_miim_remove(struct platform_device *pdev)
-{
-	struct mii_bus *bus = platform_get_drvdata(pdev);
-
-	mdiobus_unregister(bus);
-}
-
 static const struct mscc_miim_info mscc_ocelot_miim_info = {
 	.phy_reset_offset = MSCC_PHY_REG_PHY_CFG,
 	.phy_reset_bits = PHY_CFG_PHY_ENA | PHY_CFG_PHY_COMMON_RESET |
@@ -363,7 +354,6 @@ MODULE_DEVICE_TABLE(of, mscc_miim_match);
 
 static struct platform_driver mscc_miim_driver = {
 	.probe = mscc_miim_probe,
-	.remove = mscc_miim_remove,
 	.driver = {
 		.name = "mscc-miim",
 		.of_match_table = mscc_miim_match,
Signature · 1 line
2.54.0
Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3 net-next] net: mdio: mscc-miim: Use devm_of_mdiobus_register()

Hi,

Quoted 8 lines · Christophe JAILLET

Use devm_of_mdiobus_register() instead of hand writing it. This saves some lines of code.

The remove function can be removed completely and the platform_set_drvdata() call at the end of the probe is now also useless and can be removed as-well.

Maxime

Quoted 42 lines

---
Compile tested only.

---
  drivers/net/mdio/mdio-mscc-miim.c | 12 +-----------
  1 file changed, 1 insertion(+), 11 deletions(-)
drivers/net/mdio/mdio-mscc-miim.c +1 -11
index 4d8f60d458b8..7bdcf3e9baa0 100644
@@ -322,22 +322,13 @@ static int mscc_miim_probe(struct platform_device *pdev)
  	if (ret)
  		return ret;
 
-	ret = of_mdiobus_register(bus, np);
+	ret = devm_of_mdiobus_register(dev, bus, np);
  	if (ret < 0)
  		return dev_err_probe(dev, ret, "Cannot register MDIO bus\n");
 
-	platform_set_drvdata(pdev, bus);
-
  	return 0;
  }
 
-static void mscc_miim_remove(struct platform_device *pdev)
-{
-	struct mii_bus *bus = platform_get_drvdata(pdev);
-
-	mdiobus_unregister(bus);
-}
-
  static const struct mscc_miim_info mscc_ocelot_miim_info = {
  	.phy_reset_offset = MSCC_PHY_REG_PHY_CFG,
  	.phy_reset_bits = PHY_CFG_PHY_ENA | PHY_CFG_PHY_COMMON_RESET |
@@ -363,7 +354,6 @@ MODULE_DEVICE_TABLE(of, mscc_miim_match);
 
  static struct platform_driver mscc_miim_driver = {
  	.probe = mscc_miim_probe,
-	.remove = mscc_miim_remove,
  	.driver = {
  		.name = "mscc-miim",
  		.of_match_table = mscc_miim_match,
maintainer
#7 lore raw
In reply to Christophe JAILLET
Quoted 11 lines · On Fri, 15 May 2026 16:50:23 +0200 Christophe JAILLET wrote:

This serie is only some clean-up related to
drivers/net/mdio/mdio-mscc-miim.c

It depends on a patch called "[PATCH net-next] net: phy: micrel: use dev_err_probe()" that has been sent recently.

Note that in the 2nd patch, the order of the calls in the remove function is changed. I don't think that it matters, but I'm always relunctent to change such things.

The patches are compile tested only.

... against the wrong base tree I suspect? :S

Applying: net: mdio: mscc-miim: Remove some redundant code
Applying: net: mdio: mscc-miim: Use devm_clk_get_optional_enabled()
error: patch failed: drivers/net/mdio/mdio-mscc-miim.c:318
error: drivers/net/mdio/mdio-mscc-miim.c: patch does not apply Patch failed at 0002 net: mdio: mscc-miim: Use devm_clk_get_optional_enabled()
hint: Use 'git am --show-current-patch=diff' to see the failed patch

Signature · 1 line
pw-bot: cr
maintainer
#8 lore raw
Quoted 6 lines · On Mon, 18 May 2026 17:15:51 -0700 Jakub Kicinski wrote:
Quoted 5 lines · On Fri, 15 May 2026 16:50:23 +0200 Christophe JAILLET wrote:

This serie is only some clean-up related to
drivers/net/mdio/mdio-mscc-miim.c

It depends on a patch called "[PATCH net-next] net: phy: micrel: use dev_err_probe()" that has been sent recently.

Oh, missed this of course. No auto-tester will get this sort of note. Posting patches with dependencies is not "supported".
I've have expected you to know better..

Quoted 14 lines
Quoted 5 lines

Note that in the 2nd patch, the order of the calls in the remove function is changed. I don't think that it matters, but I'm always relunctent to change such things.

The patches are compile tested only.

... against the wrong base tree I suspect? :S

Applying: net: mdio: mscc-miim: Remove some redundant code
Applying: net: mdio: mscc-miim: Use devm_clk_get_optional_enabled()
error: patch failed: drivers/net/mdio/mdio-mscc-miim.c:318
error: drivers/net/mdio/mdio-mscc-miim.c: patch does not apply Patch failed at 0002 net: mdio: mscc-miim: Use devm_clk_get_optional_enabled()
hint: Use 'git am --show-current-patch=diff' to see the failed patch