Skip to content

Commit

Permalink
phy: core: Add *release* phy_ops invoked when the consumer relinquish…
Browse files Browse the repository at this point in the history
…es 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 <[email protected]>
  • Loading branch information
kishon committed Apr 17, 2019
1 parent 42c7cb7 commit fec06b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/phy/phy-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions include/linux/phy/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
};

Expand Down

0 comments on commit fec06b2

Please sign in to comment.