diff mbox series

[net-next,03/10] net: dsa: lantiq_gswip: ignore MDIO buses disabled in OF

Message ID 20240104140037.374166-4-vladimir.oltean@nxp.com (mailing list archive)
State Accepted
Commit 7a898539391dccce00c3cb24d96a6ba80cef7f6d
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, 14 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
If the "lantiq,xrx200-mdio" child has status = "disabled", the MDIO bus
creation should be avoided. Use of_device_is_available() to check for
that, and take advantage of 2 facts:

- of_device_is_available(NULL) returns false
- of_node_put(NULL) is a no-op

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/dsa/lantiq_gswip.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Alvin Šipraga Jan. 4, 2024, 3:53 p.m. UTC | #1
On Thu, Jan 04, 2024 at 04:00:30PM +0200, Vladimir Oltean wrote:
> If the "lantiq,xrx200-mdio" child has status = "disabled", the MDIO bus
> creation should be avoided. Use of_device_is_available() to check for
> that, and take advantage of 2 facts:
> 
> - of_device_is_available(NULL) returns false
> - of_node_put(NULL) is a no-op
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

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

> ---
>  drivers/net/dsa/lantiq_gswip.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
Florian Fainelli Jan. 4, 2024, 5:36 p.m. UTC | #2
On 1/4/24 06:00, Vladimir Oltean wrote:
> If the "lantiq,xrx200-mdio" child has status = "disabled", the MDIO bus
> creation should be avoided. Use of_device_is_available() to check for
> that, and take advantage of 2 facts:
> 
> - of_device_is_available(NULL) returns false
> - of_node_put(NULL) is a no-op
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
diff mbox series

Patch

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index a514e6c78c38..de48b194048f 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -510,11 +510,11 @@  static int gswip_mdio(struct gswip_priv *priv)
 	struct device_node *mdio_np, *switch_np = priv->dev->of_node;
 	struct device *dev = priv->dev;
 	struct mii_bus *bus;
-	int err;
+	int err = 0;
 
 	mdio_np = of_get_compatible_child(switch_np, "lantiq,xrx200-mdio");
-	if (!mdio_np)
-		return 0;
+	if (!of_device_is_available(mdio_np))
+		goto out_put_node;
 
 	bus = devm_mdiobus_alloc(dev);
 	if (!bus) {