diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-02-08 12:13:19 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-02-09 10:43:24 +0100 |
commit | 32a8121a19c4936672440c96371f6a8c2b0c3d4d (patch) | |
tree | d9e1e4e41a7c3b07545a3026fbb182989519dc13 /drivers | |
parent | beea7892d4339e50f15e5131d51a95503678fdf6 (diff) | |
download | linux-32a8121a19c4936672440c96371f6a8c2b0c3d4d.tar.gz linux-32a8121a19c4936672440c96371f6a8c2b0c3d4d.tar.bz2 linux-32a8121a19c4936672440c96371f6a8c2b0c3d4d.zip |
driver core: bus: bus_register/unregister_notifier() cleanups
Convert the bus_register_notifier() and bus_unregister_notifier() public
functions to use bus_to_subsys() and not use the back-pointer to the
private structure as well as the bus_notify() function.
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230208111330.439504-11-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/bus.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 105b6af924af..81c0f7ff29a2 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -936,22 +936,40 @@ EXPORT_SYMBOL_GPL(bus_unregister); int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb) { - return blocking_notifier_chain_register(&bus->p->bus_notifier, nb); + struct subsys_private *sp = bus_to_subsys(bus); + int retval; + + if (!sp) + return -EINVAL; + + retval = blocking_notifier_chain_register(&sp->bus_notifier, nb); + subsys_put(sp); + return retval; } EXPORT_SYMBOL_GPL(bus_register_notifier); int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb) { - return blocking_notifier_chain_unregister(&bus->p->bus_notifier, nb); + struct subsys_private *sp = bus_to_subsys(bus); + int retval; + + if (!sp) + return -EINVAL; + retval = blocking_notifier_chain_unregister(&sp->bus_notifier, nb); + subsys_put(sp); + return retval; } EXPORT_SYMBOL_GPL(bus_unregister_notifier); void bus_notify(struct device *dev, enum bus_notifier_event value) { - struct bus_type *bus = dev->bus; + struct subsys_private *sp = bus_to_subsys(dev->bus); - if (bus) - blocking_notifier_call_chain(&bus->p->bus_notifier, value, dev); + if (!sp) + return; + + blocking_notifier_call_chain(&sp->bus_notifier, value, dev); + subsys_put(sp); } struct kset *bus_get_kset(struct bus_type *bus) |