aboutsummaryrefslogtreecommitdiff
path: root/drivers/phy/phy-uclass.c
diff options
context:
space:
mode:
authorJonas Karlman2023-08-31 23:07:11 +0000
committerTom Rini2023-09-13 15:52:21 -0400
commit565f556d0ba7f36def70dc36422d8730ff70f7a9 (patch)
treee44e6637e47d41e4f3926fa14c81785bc92ac76a /drivers/phy/phy-uclass.c
parent1a4293e001d1063401b6f94104684e38d6e401c9 (diff)
phy: Refactor generic_{setup, shutdown}_phy() to reduce complexity
Refactor generic_{setup,shutdown}_phy() to reduce complexity and indentation. This have no intended functional change. Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Diffstat (limited to 'drivers/phy/phy-uclass.c')
-rw-r--r--drivers/phy/phy-uclass.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index 343c23cead0..190108e04c7 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -510,44 +510,35 @@ int generic_phy_power_off_bulk(struct phy_bulk *bulk)
int generic_setup_phy(struct udevice *dev, struct phy *phy, int index)
{
- int ret = 0;
-
- if (!phy)
- return 0;
+ int ret;
ret = generic_phy_get_by_index(dev, index, phy);
- if (ret) {
- if (ret == -ENOENT)
- return 0;
- } else {
- ret = generic_phy_init(phy);
- if (ret)
- return ret;
+ if (ret)
+ return ret == -ENOENT ? 0 : ret;
- ret = generic_phy_power_on(phy);
- if (ret)
- generic_phy_exit(phy);
- }
+ ret = generic_phy_init(phy);
+ if (ret)
+ return ret;
+
+ ret = generic_phy_power_on(phy);
+ if (ret)
+ generic_phy_exit(phy);
return ret;
}
int generic_shutdown_phy(struct phy *phy)
{
- int ret = 0;
+ int ret;
- if (!phy)
+ if (!generic_phy_valid(phy))
return 0;
- if (generic_phy_valid(phy)) {
- ret = generic_phy_power_off(phy);
- if (ret)
- return ret;
-
- ret = generic_phy_exit(phy);
- }
+ ret = generic_phy_power_off(phy);
+ if (ret)
+ return ret;
- return ret;
+ return generic_phy_exit(phy);
}
UCLASS_DRIVER(phy) = {