lkml.org 
[lkml]   [2021]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 09/12] drivers: base: reintroduce find_bus()
Date
---
drivers/base/bus.c | 14 ++++++++++----
include/linux/device/bus.h | 2 ++
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 450d3ed6cf1f..a06ae2786092 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -754,13 +754,19 @@ EXPORT_SYMBOL_GPL(device_reprobe);
*
* Note that kset_find_obj increments bus' reference count.
*/
-#if 0
-struct bus_type *find_bus(char *name)
+struct bus_type *find_bus(const char *name)
{
struct kobject *k = kset_find_obj(bus_kset, name);
- return k ? to_bus(k) : NULL;
+ struct subsys_private *subsys_priv;
+
+ if (!k)
+ return NULL;
+
+ subsys_priv = container_of(to_kset(k), struct subsys_private, subsys);
+
+ return subsys_priv->bus;
}
-#endif /* 0 */
+EXPORT_SYMBOL_GPL(find_bus);

static int bus_add_groups(struct bus_type *bus,
const struct attribute_group **groups)
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index 36a1dae26c95..b4cbcfe176c5 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -254,6 +254,8 @@ void bus_sort_breadthfirst(struct bus_type *bus,
int (*compare)(const struct device *a,
const struct device *b));

+struct bus_type *find_bus(const char *name);
+
/**
* bus_unregister_device_by_name - remove device by bus id from specific bus
* and unregister it from device core
--
2.11.0
\
 
 \ /
  Last update: 2021-02-08 23:28    [W:0.332 / U:24.768 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site