summaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorVivek Gautam <vivek.gautam@codeaurora.org>2018-06-27 18:20:56 +0530
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-07-09 12:14:31 +0200
commit1689cac5b32a6db6f812e8063ea418a7cf023d03 (patch)
tree165be23752f68df71466619de2601bcc12d3714d /drivers/base/core.c
parente88728f46cfbb59cc7e7acf1d230c05ec093764e (diff)
downloadlinux-1689cac5b32a6db6f812e8063ea418a7cf023d03.tar.bz2
driver core: Add flag to autoremove device link on supplier unbind
Add a flag to autoremove the device links on supplier driver unbind. This obviates the need to explicitly delete the link in the remove path. We remove these links only when the supplier's link to its consumers has gone to DL_STATE_SUPPLIER_UNBIND state. Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> Suggested-by: Lukas Wunner <lukas@wunner.de> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 14c1e3151e08..e721218bf352 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -518,6 +518,16 @@ void device_links_driver_cleanup(struct device *dev)
WARN_ON(link->flags & DL_FLAG_AUTOREMOVE_CONSUMER);
WARN_ON(link->status != DL_STATE_SUPPLIER_UNBIND);
+
+ /*
+ * autoremove the links between this @dev and its consumer
+ * devices that are not active, i.e. where the link state
+ * has moved to DL_STATE_SUPPLIER_UNBIND.
+ */
+ if (link->status == DL_STATE_SUPPLIER_UNBIND &&
+ link->flags & DL_FLAG_AUTOREMOVE_SUPPLIER)
+ kref_put(&link->kref, __device_link_del);
+
WRITE_ONCE(link->status, DL_STATE_DORMANT);
}