diff mbox series

[net-next,07/10] net: dsa: qca8k: consolidate calls to a single devm_of_mdiobus_register()

Message ID 20240104140037.374166-8-vladimir.oltean@nxp.com (mailing list archive)
State Accepted
Commit 5c5d6b34b683c044a5d61dc0ace94e5c20f32bcf
Delegated to: Netdev Maintainers
Headers show
Series ds->user_mii_bus cleanup (part 1) | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1113 this patch: 1113
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 1140 this patch: 1140
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1140 this patch: 1140
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Vladimir Oltean Jan. 4, 2024, 2 p.m. UTC
__of_mdiobus_register() already calls __mdiobus_register() if the
OF node provided as argument is NULL. We can take advantage of that
and simplify the 2 code path, calling devm_of_mdiobus_register() only
once for both cases.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/dsa/qca/qca8k-8xxx.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

Comments

Alvin Šipraga Jan. 4, 2024, 3:49 p.m. UTC | #1
On Thu, Jan 04, 2024 at 04:00:34PM +0200, Vladimir Oltean wrote:
> __of_mdiobus_register() already calls __mdiobus_register() if the
> OF node provided as argument is NULL. We can take advantage of that
> and simplify the 2 code path, calling devm_of_mdiobus_register() only
> once for both cases.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Much neater!

Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>

> ---
>  drivers/net/dsa/qca/qca8k-8xxx.c | 24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)
Florian Fainelli Jan. 4, 2024, 5:34 p.m. UTC | #2
On 1/4/24 06:00, Vladimir Oltean wrote:
> __of_mdiobus_register() already calls __mdiobus_register() if the
> OF node provided as argument is NULL. We can take advantage of that
> and simplify the 2 code path, calling devm_of_mdiobus_register() only
> once for both cases.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Christian Marangi Jan. 4, 2024, 11:07 p.m. UTC | #3
On Thu, Jan 04, 2024 at 04:00:34PM +0200, Vladimir Oltean wrote:
> __of_mdiobus_register() already calls __mdiobus_register() if the
> OF node provided as argument is NULL. We can take advantage of that
> and simplify the 2 code path, calling devm_of_mdiobus_register() only
> once for both cases.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Christian Marangi <ansuelsmth@gmail.com>
Luiz Angelo Daros de Luca Jan. 5, 2024, 2:26 a.m. UTC | #4
> __of_mdiobus_register() already calls __mdiobus_register() if the
> OF node provided as argument is NULL. We can take advantage of that
> and simplify the 2 code path, calling devm_of_mdiobus_register() only
> once for both cases.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

I should have read all the series before... :-)

Reviewed-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c
index 8f69b95c894d..f12bdb30796f 100644
--- a/drivers/net/dsa/qca/qca8k-8xxx.c
+++ b/drivers/net/dsa/qca/qca8k-8xxx.c
@@ -967,25 +967,23 @@  qca8k_mdio_register(struct qca8k_priv *priv)
 		 ds->dst->index, ds->index);
 	bus->parent = ds->dev;
 
-	/* Check if the devicetree declare the port:phy mapping */
 	if (mdio) {
+		/* Check if the device tree declares the port:phy mapping */
 		bus->name = "qca8k user mii";
 		bus->read = qca8k_internal_mdio_read;
 		bus->write = qca8k_internal_mdio_write;
-		err = devm_of_mdiobus_register(priv->dev, bus, mdio);
-		goto out_put_node;
+	} else {
+		/* If a mapping can't be found, the legacy mapping is used,
+		 * using qca8k_port_to_phy()
+		 */
+		ds->user_mii_bus = bus;
+		bus->phy_mask = ~ds->phys_mii_mask;
+		bus->name = "qca8k-legacy user mii";
+		bus->read = qca8k_legacy_mdio_read;
+		bus->write = qca8k_legacy_mdio_write;
 	}
 
-	/* If a mapping can't be found the legacy mapping is used,
-	 * using the qca8k_port_to_phy function
-	 */
-	ds->user_mii_bus = bus;
-	bus->phy_mask = ~ds->phys_mii_mask;
-	bus->name = "qca8k-legacy user mii";
-	bus->read = qca8k_legacy_mdio_read;
-	bus->write = qca8k_legacy_mdio_write;
-
-	err = devm_mdiobus_register(priv->dev, bus);
+	err = devm_of_mdiobus_register(priv->dev, bus, mdio);
 
 out_put_node:
 	of_node_put(mdio);