[PATCH 09/21] driver core: bus: bus_get_kset() cleanup

Greg Kroah-Hartman
2023-02-08T11:15:38Z

Convert the bus_get_kset() function function to use bus_to_subsys() and
not use the back-pointer to the private structure.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/base/bus.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index deed62509a62..90627c68d02b 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -956,7 +956,16 @@ void bus_notify(struct device *dev, enum bus_notifier_event value)

struct kset *bus_get_kset(struct bus_type *bus)
{
- return &bus->p->subsys;
+ struct subsys_private *sp = bus_to_subsys(bus);
+ struct kset *kset;
+
+ if (!sp)
+ return NULL;
+
+ kset = &sp->subsys;
+ subsys_put(sp);
+
+ return kset;
}
EXPORT_SYMBOL_GPL(bus_get_kset);

--
2.39.1