Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers: base: component: add function to query the bound status

The component helpers already expose the bound status in debugfs, but at
times it might be necessary to also check that state in the kernel and
act differently depending on the result.

For example the shutdown handler of a drm-driver might need to stop
a whole output pipeline if the drm device is up and running, but may
run into problems if that drm-device has never been set up before,
for example because the binding deferred.

So add a little helper that returns the bound status for a componet
device.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20250220234141.2788785-2-heiko@sntech.de

+17 -1
+14
drivers/base/component.c
··· 569 569 } 570 570 EXPORT_SYMBOL_GPL(component_master_del); 571 571 572 + bool component_master_is_bound(struct device *parent, 573 + const struct component_master_ops *ops) 574 + { 575 + struct aggregate_device *adev; 576 + 577 + guard(mutex)(&component_mutex); 578 + adev = __aggregate_find(parent, ops); 579 + if (!adev) 580 + return 0; 581 + 582 + return adev->bound; 583 + } 584 + EXPORT_SYMBOL_GPL(component_master_is_bound); 585 + 572 586 static void component_unbind(struct component *component, 573 587 struct aggregate_device *adev, void *data) 574 588 {
+3 -1
include/linux/component.h
··· 3 3 #define COMPONENT_H 4 4 5 5 #include <linux/stddef.h> 6 - 6 + #include <linux/types.h> 7 7 8 8 struct device; 9 9 ··· 90 90 91 91 void component_master_del(struct device *, 92 92 const struct component_master_ops *); 93 + bool component_master_is_bound(struct device *parent, 94 + const struct component_master_ops *ops); 93 95 94 96 struct component_match; 95 97