summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorSaravana Kannan <saravanak@google.com>2020-11-21 05:02:24 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-09 21:10:21 +0300
commitac66c5bbb4371073dcace77e47c234d2e36a006b (patch)
tree0315572793edc57ce025fe775d43170053dd1654 /drivers/base
parent7b337cb3ebde384cba7405b61dfb84200bf623bf (diff)
downloadlinux-ac66c5bbb4371073dcace77e47c234d2e36a006b.tar.xz
driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links
SYNC_STATE_ONLY device links only affect the behavior of sync_state() callbacks. Specifically, they prevent sync_state() only callbacks from being called on a device if one or more of its consumers haven't probed. So, creating a SYNC_STATE_ONLY device link from an already probed consumer is useless. So, don't allow creating such device links. Signed-off-by: Saravana Kannan <saravanak@google.com> Link: https://lore.kernel.org/r/20201121020232.908850-10-saravanak@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/core.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 972d42dedfc8..edde79fc3d33 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -650,6 +650,17 @@ struct device_link *device_link_add(struct device *consumer,
}
/*
+ * SYNC_STATE_ONLY links are useless once a consumer device has probed.
+ * So, only create it if the consumer hasn't probed yet.
+ */
+ if (flags & DL_FLAG_SYNC_STATE_ONLY &&
+ consumer->links.status != DL_DEV_NO_DRIVER &&
+ consumer->links.status != DL_DEV_PROBING) {
+ link = NULL;
+ goto out;
+ }
+
+ /*
* DL_FLAG_AUTOREMOVE_SUPPLIER indicates that the link will be needed
* longer than for DL_FLAG_AUTOREMOVE_CONSUMER and setting them both
* together doesn't make sense, so prefer DL_FLAG_AUTOREMOVE_SUPPLIER.