phy: core: Fixup return value of phy_exit when !pm_runtime_enabled
PATCH 1/1 phy: core: Fixup return value of phy_exit when !pm_runtime_enabled
When phy_pm_runtime_get_sync() returns -ENOTSUPP, phy_exit() also returns -ENOTSUPP if !phy->ops->exit. Fix it.
Also move the code to override ret close to the code we got ret. I think it is less error prone this way.
Signed-off-by Axel Lin <[email protected]>
--- drivers/phy/phy-core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/phy/phy-core.c +3 -4
@@ -223,6 +223,7 @@ int phy_init(struct phy *phy) ret =phy_pm_runtime_get_sync (phy);if (ret <0 && ret != -ENOTSUPP )return ret; + ret =0 ;/* Override possible ret == -ENOTSUPP */ mutex_lock (&phy->mutex);if (phy->init_count ==0 && phy->ops->init) {
@@ -231,8 +232,6 @@ int phy_init(struct phy *phy)dev_err (&phy->dev,"phy init failed --> %d\n" , ret); goto out; } - }else { - ret =0 ;/* Override possible ret == -ENOTSUPP */ } ++phy->init_count;
@@ -253,6 +252,7 @@ int phy_exit(struct phy *phy) ret =phy_pm_runtime_get_sync (phy);if (ret <0 && ret != -ENOTSUPP )return ret; + ret =0 ;/* Override possible ret == -ENOTSUPP */ mutex_lock (&phy->mutex);if (phy->init_count ==1 && phy->ops->exit) {
@@ -287,6 +287,7 @@ int phy_power_on(struct phy *phy) ret =phy_pm_runtime_get_sync (phy);if (ret <0 && ret != -ENOTSUPP )return ret; + ret =0 ;/* Override possible ret == -ENOTSUPP */ mutex_lock (&phy->mutex);if (phy->power_count ==0 && phy->ops->power_on) {
@@ -295,8 +296,6 @@ int phy_power_on(struct phy *phy)dev_err (&phy->dev,"phy poweron failed --> %d\n" , ret); goto out; } - }else { - ret =0 ;/* Override possible ret == -ENOTSUPP */ } ++phy->power_count;mutex_unlock (&phy->mutex);
Signature · 1 line
1.9.1
Quoted 6 lines · Axel Lin
When
phy_pm_runtime_get_sync()returns-ENOTSUPP,phy_exit()also returns-ENOTSUPPif !phy->ops->exit. Fix it.
Also move the code to override ret close to the code we got ret. I think it is less error prone this way.Signed-off-by Axel Lin <[email protected]>
Acked-by Roger Quadros <[email protected]>
cheers,
-roger
Quoted 51 lines
--- drivers/phy/phy-core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/phy/phy-core.c +3
-4@@ -223,6 +223,7 @@ int phy_init(struct phy *phy) ret =phy_pm_runtime_get_sync (phy);if (ret <0 && ret != -ENOTSUPP )return ret; + ret =0 ;/* Override possible ret == -ENOTSUPP */ mutex_lock (&phy->mutex);if (phy->init_count ==0 && phy->ops->init) {@@ -231,8 +232,6 @@ int phy_init(struct phy *phy)dev_err (&phy->dev,"phy init failed --> %d\n" , ret); goto out; } - }else { - ret =0 ;/* Override possible ret == -ENOTSUPP */ } ++phy->init_count;@@ -253,6 +252,7 @@ int phy_exit(struct phy *phy) ret =phy_pm_runtime_get_sync (phy);if (ret <0 && ret != -ENOTSUPP )return ret; + ret =0 ;/* Override possible ret == -ENOTSUPP */ mutex_lock (&phy->mutex);if (phy->init_count ==1 && phy->ops->exit) {@@ -287,6 +287,7 @@ int phy_power_on(struct phy *phy) ret =phy_pm_runtime_get_sync (phy);if (ret <0 && ret != -ENOTSUPP )return ret; + ret =0 ;/* Override possible ret == -ENOTSUPP */ mutex_lock (&phy->mutex);if (phy->power_count ==0 && phy->ops->power_on) {@@ -295,8 +296,6 @@ int phy_power_on(struct phy *phy)dev_err (&phy->dev,"phy poweron failed --> %d\n" , ret); goto out; } - }else { - ret =0 ;/* Override possible ret == -ENOTSUPP */ } ++phy->power_count;mutex_unlock (&phy->mutex);