phy: core: Add *release* phy_ops invoked when the consumer relinquishes PHY
authorKishon Vijay Abraham I <kishon@ti.com>
Fri, 5 Apr 2019 11:08:30 +0000 (16:38 +0530)
committerKishon Vijay Abraham I <kishon@ti.com>
Wed, 17 Apr 2019 08:43:17 +0000 (14:13 +0530)
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>
drivers/phy/phy-core.c
include/linux/phy/phy.h

index cb38f6e8614c9b7f864c080fd41fd10891f8430f..b9a4ebf35dd3bfb48f864b8b79544d380f2b800b 100644 (file)
@@ -564,6 +564,11 @@ void phy_put(struct phy *phy)
        if (!phy || IS_ERR(phy))
                return;
 
+       mutex_lock(&phy->mutex);
+       if (phy->ops->release)
+               phy->ops->release(phy);
+       mutex_unlock(&phy->mutex);
+
        module_put(phy->ops->owner);
        put_device(&phy->dev);
 }
index 3f350e2749fe4982b1f728ce6b8dee007cb8ead6..ef13aea1d3701aa34efa2ad37035cab0860f31f7 100644 (file)
@@ -64,6 +64,7 @@ union phy_configure_opts {
  * @set_mode: set the mode of the phy
  * @reset: resetting the phy
  * @calibrate: calibrate the phy
+ * @release: ops to be performed while the consumer relinquishes the PHY
  * @owner: the module owner containing the ops
  */
 struct phy_ops {
@@ -105,6 +106,7 @@ struct phy_ops {
                            union phy_configure_opts *opts);
        int     (*reset)(struct phy *phy);
        int     (*calibrate)(struct phy *phy);
+       void    (*release)(struct phy *phy);
        struct module *owner;
 };