summaryrefslogtreecommitdiff
path: root/drivers/base/bus.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-02-08 14:13:25 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-02-09 12:43:35 +0300
commit63b823d7d3cd275c3347233f95bdf966a595dbc8 (patch)
tree79235374903b70a2580bc2cd0b68fa63353a00ce /drivers/base/bus.c
parentfb451966ae7d7e6d6802de39bda5fa2f15781244 (diff)
downloadlinux-63b823d7d3cd275c3347233f95bdf966a595dbc8.tar.xz
driver core: create bus_is_registered()
A local function to the driver core to determine if a bus really is registered with the kernel or not. To be used only by the driver core code, as part of the driver registration path as it's not really "safe" because the bus could be unregistered instantly after being called. Cc: "Rafael J. Wysocki" <rafael@kernel.org> Link: https://lore.kernel.org/r/20230208111330.439504-17-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r--drivers/base/bus.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 98edc7aa4fc4..c82c65fde8a1 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -1322,6 +1322,22 @@ struct device_driver *driver_find(const char *name, struct bus_type *bus)
}
EXPORT_SYMBOL_GPL(driver_find);
+/*
+ * Warning, the value could go to "removed" instantly after calling this function, so be very
+ * careful when calling it...
+ */
+bool bus_is_registered(const struct bus_type *bus)
+{
+ struct subsys_private *sp = bus_to_subsys(bus);
+ bool is_initialized = false;
+
+ if (sp) {
+ is_initialized = true;
+ subsys_put(sp);
+ }
+ return is_initialized;
+}
+
int __init buses_init(void)
{
bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL);