diff mbox series

[v1,06/12] driver core: expose device_is_ancestor() API

Message ID 20230119013602.607466-7-tianfei.zhang@intel.com (mailing list archive)
State New
Headers show
Series add FPGA hotplug manager driver | expand

Commit Message

Zhang, Tianfei Jan. 19, 2023, 1:35 a.m. UTC
Exposes device_is_ancestor() API which can be used
for check the device is the target device's ancestor or not.

Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
 drivers/base/core.c    | 3 ++-
 include/linux/device.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/drivers/base/core.c b/drivers/base/core.c
index a3e14143ec0c..597192b38198 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -262,7 +262,7 @@  static void device_link_remove_from_lists(struct device_link *link)
 #endif /* !CONFIG_SRCU */
-static bool device_is_ancestor(struct device *dev, struct device *target)
+bool device_is_ancestor(struct device *dev, struct device *target)
 	while (target->parent) {
 		target = target->parent;
@@ -271,6 +271,7 @@  static bool device_is_ancestor(struct device *dev, struct device *target)
 	return false;
  * device_is_dependent - Check if one device depends on another one
diff --git a/include/linux/device.h b/include/linux/device.h
index 44e3acae7b36..35e35982d9a5 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -909,6 +909,7 @@  int device_move(struct device *dev, struct device *new_parent,
 int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
 const char *device_get_devnode(struct device *dev, umode_t *mode, kuid_t *uid,
 			       kgid_t *gid, const char **tmp);
+bool device_is_ancestor(struct device *dev, struct device *target);
 int device_is_dependent(struct device *dev, void *target);
 static inline bool device_supports_offline(struct device *dev)