summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorAndrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>2021-01-28 09:41:02 +0000
committerAndrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>2021-01-28 09:41:02 +0000
commit6aa59e41d866e0e3f69a75db2c446befe402dcfc (patch)
tree37e3deff304f76ad82da22bec011b32a1b4bc14b /drivers/base
parent2d26ac7ea809b04c354b4ea966f44e4f6a480f00 (diff)
parent131f8d8a889a5ca66a835eea82bba043ac91a7cf (diff)
Merge tag 'v5.4.93' into 5.4-2.3.x-imx
This is the 5.4.93 stable release Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/core.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 61beed439d6a..1768c367e035 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -106,6 +106,16 @@ int device_links_read_lock_held(void)
#endif
#endif /* !CONFIG_SRCU */
+static bool device_is_ancestor(struct device *dev, struct device *target)
+{
+ while (target->parent) {
+ target = target->parent;
+ if (dev == target)
+ return true;
+ }
+ return false;
+}
+
/**
* device_is_dependent - Check if one device depends on another one
* @dev: Device to check dependencies for.
@@ -119,7 +129,12 @@ static int device_is_dependent(struct device *dev, void *target)
struct device_link *link;
int ret;
- if (dev == target)
+ /*
+ * The "ancestors" check is needed to catch the case when the target
+ * device has not been completely initialized yet and it is still
+ * missing from the list of children of its parent device.
+ */
+ if (dev == target || device_is_ancestor(dev, target))
return 1;
ret = device_for_each_child(dev, target, device_is_dependent);