diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2019-04-05 07:08:30 -0400 |
---|---|---|
committer | Kishon Vijay Abraham I <kishon@ti.com> | 2019-04-17 04:43:17 -0400 |
commit | fec06b2bc436d1cbc3482becd40f656d46cd22b7 (patch) | |
tree | 87405f207d3eb80846221bc1297999714e953170 | |
parent | 42c7cb71b5c2b014caab7861f2434f3907900d7c (diff) |
phy: core: Add *release* phy_ops invoked when the consumer relinquishes PHY
Add a new phy_ops *release* invoked when the consumer relinquishes the
PHY using phy_put/devm_phy_put. The initializations done by the PHY
driver in of_xlate call back can be can be cleaned up here.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
-rw-r--r-- | drivers/phy/phy-core.c | 5 | ||||
-rw-r--r-- | include/linux/phy/phy.h | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index cb38f6e8614c..b9a4ebf35dd3 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c | |||
@@ -564,6 +564,11 @@ void phy_put(struct phy *phy) | |||
564 | if (!phy || IS_ERR(phy)) | 564 | if (!phy || IS_ERR(phy)) |
565 | return; | 565 | return; |
566 | 566 | ||
567 | mutex_lock(&phy->mutex); | ||
568 | if (phy->ops->release) | ||
569 | phy->ops->release(phy); | ||
570 | mutex_unlock(&phy->mutex); | ||
571 | |||
567 | module_put(phy->ops->owner); | 572 | module_put(phy->ops->owner); |
568 | put_device(&phy->dev); | 573 | put_device(&phy->dev); |
569 | } | 574 | } |
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 3f350e2749fe..ef13aea1d370 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h | |||
@@ -64,6 +64,7 @@ union phy_configure_opts { | |||
64 | * @set_mode: set the mode of the phy | 64 | * @set_mode: set the mode of the phy |
65 | * @reset: resetting the phy | 65 | * @reset: resetting the phy |
66 | * @calibrate: calibrate the phy | 66 | * @calibrate: calibrate the phy |
67 | * @release: ops to be performed while the consumer relinquishes the PHY | ||
67 | * @owner: the module owner containing the ops | 68 | * @owner: the module owner containing the ops |
68 | */ | 69 | */ |
69 | struct phy_ops { | 70 | struct phy_ops { |
@@ -105,6 +106,7 @@ struct phy_ops { | |||
105 | union phy_configure_opts *opts); | 106 | union phy_configure_opts *opts); |
106 | int (*reset)(struct phy *phy); | 107 | int (*reset)(struct phy *phy); |
107 | int (*calibrate)(struct phy *phy); | 108 | int (*calibrate)(struct phy *phy); |
109 | void (*release)(struct phy *phy); | ||
108 | struct module *owner; | 110 | struct module *owner; |
109 | }; | 111 | }; |
110 | 112 | ||