Commit 32a8121a authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent beea7892
...@@ -936,22 +936,40 @@ EXPORT_SYMBOL_GPL(bus_unregister); ...@@ -936,22 +936,40 @@ EXPORT_SYMBOL_GPL(bus_unregister);
int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb) 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); EXPORT_SYMBOL_GPL(bus_register_notifier);
int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb) 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); EXPORT_SYMBOL_GPL(bus_unregister_notifier);
void bus_notify(struct device *dev, enum bus_notifier_event value) 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) if (!sp)
blocking_notifier_call_chain(&bus->p->bus_notifier, value, dev); return;
blocking_notifier_call_chain(&sp->bus_notifier, value, dev);
subsys_put(sp);
} }
struct kset *bus_get_kset(struct bus_type *bus) struct kset *bus_get_kset(struct bus_type *bus)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment