diff mbox series

[09/12] net: phy: nxp-tja11xx: make use of phy_device_atomic_register()

Message ID 20230405-net-next-topic-net-phy-reset-v1-9-7e5329f08002@pengutronix.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Rework PHY reset handling | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next, async
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: 25 this patch: 18
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 28 this patch: 18
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: 25 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Marco Felsch April 5, 2023, 9:27 a.m. UTC
Use the new atomic API to setup and register the phy accordingly.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/net/phy/nxp-tja11xx.c | 31 +++++++------------------------
 1 file changed, 7 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c
index 2a4c0f6d74eb..af9cb5e1a7ee 100644
--- a/drivers/net/phy/nxp-tja11xx.c
+++ b/drivers/net/phy/nxp-tja11xx.c
@@ -561,6 +561,8 @@  static void tja1102_p1_register(struct work_struct *work)
 			/* Real PHY ID of Port 1 is 0 */
 			.phy_id = PHY_ID_TJA1102,
 			.phy_id_broken = true,
+			.parent_mdiodev = dev,
+			.fwnode = of_fwnode_handle(child),
 		};
 		struct phy_device *phy;
 
@@ -583,30 +585,11 @@  static void tja1102_p1_register(struct work_struct *work)
 			continue;
 		}
 
-		phy = phy_device_create(&config);
-		if (IS_ERR(phy)) {
-			dev_err(dev, "Can't create PHY device for Port 1: %i\n",
-				config.phy_addr);
-			continue;
-		}
-
-		/* Overwrite parent device. phy_device_create() set parent to
-		 * the mii_bus->dev, which is not correct in case.
-		 */
-		phy->mdio.dev.parent = dev;
-
-		ret = of_mdiobus_phy_device_register(bus, phy, child,
-						     config.phy_addr);
-		if (ret) {
-			/* All resources needed for Port 1 should be already
-			 * available for Port 0. Both ports use the same
-			 * interrupt line, so -EPROBE_DEFER would make no sense
-			 * here.
-			 */
-			dev_err(dev, "Can't register Port 1. Unexpected error: %i\n",
-				ret);
-			phy_device_free(phy);
-		}
+		phy = phy_device_atomic_register(&config);
+		if (IS_ERR(phy))
+			dev_err_probe(dev, PTR_ERR(phy),
+				      "Can't create PHY device for Port 1: %i\n",
+				      config.phy_addr);
 	}
 }