Skip to content

driver core: bus: remove private "backpointer" from struct bus_type

Greg Kroah-Hartman linux-renesas-soc lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest21 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21driver core: add local subsys_get and subsys_put functionsdrivers/base/base.h+13 -00 replies
2/21driver core: bus: implement bus_get/put() without the private pointerdrivers/base/bus.c+53 -80 replies
3/21driver core: bus: constantify the bus_find_* functionsdrivers/base/bus.c include/linux/device/bus.h+13 -130 replies
4/21driver core: bus: convert bus_create/remove_file to be constantdrivers/base/bus.c include/linux/device/bus.h+19 -140 replies
5/21driver core: bus: sysfs function cleanupsdrivers/base/bus.c+29 -60 replies
6/21driver core: bus: bus_add/probe/remove_device() cleanupsdrivers/base/bus.c+54 -330 replies
7/21driver core: bus: bus_register/unregister() cleanupsdrivers/base/bus.c+26 -280 replies
8/21driver core: bus: subsys_interface_register/unregister() cleanupsdrivers/base/bus.c+29 -160 replies
9/21driver core: bus: bus_get_kset() cleanupdrivers/base/bus.c+10 -10 replies
10/21driver core: bus: bus_register/unregister_notifier() cleanupsdrivers/base/bus.c+23 -50 replies
11/21driver core: bus: bus_add/remove_driver() cleanupsdrivers/base/bus.c+26 -130 replies
12/21driver core: bus: bus iterator cleanupsdrivers/base/bus.c+12 -61 reply
13/21driver core: bus: clean up bus_sort_breadthfirst()drivers/base/bus.c+5 -60 replies
14/21driver core: move driver_find() to bus.cdrivers/base/bus.c drivers/base/driver.c+27 -270 replies
15/21driver core: bus: clean up driver_find()drivers/base/bus.c+15 -80 replies
16/21driver core: create bus_is_registered()drivers/base/base.h drivers/base/bus.c drivers/base/driver.c+18 -10 replies
17/21driver core: remove private pointer from struct bus_typedrivers/base/bus.c include/linux/device/bus.h+0 -80 replies
18/21driver core: bus: constify bus_register/unregister_notifier()drivers/base/bus.c include/linux/device/bus.h+4 -40 replies
19/21driver core: bus: constify bus_get_kset()drivers/base/bus.c include/linux/device/bus.h+2 -20 replies
20/21driver core: bus: constify some internal functionsdrivers/base/bus.c+2 -20 replies
21/21driver core: bus: constify bus_unregister()drivers/base/bus.c include/linux/device/bus.h+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/21] driver core: bus: remove private "backpointer" from struct bus_type

In the quest to make all struct bus_type constant in the kernel, allowing them to move into read-only memory, this patch series goes through the steps in getting rid of the "private" pointer in struct bus_type. It does so primarily by relying on the already-present list of subsystems in the driver core and looking up the struct bus_type from that list when needed, or looking up the private structure from the bus pointer, depending on what is needed.

Overall, more lines of code are added, but we now have the additional safely that the internal subsystem private type is properly reference counted. We "got away" with not incrementing reference counts because we relied on the caller of functions to have a valid reference when calling into the core. That's not really the proper way to handle reference counts, so as part of the conversion, reference counts are now correctly handled.

There are still some remaining steps to be able to have bus_type be constant everywhere in the kernel, but this series is a great first step and is the "hard part" of the work. The rest involves changing the callback sysfs file functions and handling the dev_root pointer properly. Those changes will be forthcoming after these as they involve lots more minor driver changes all over the kernel.

This has been build-tested by the 0-day bot for a while, and is being used by me right now to send this series out, so it "works for me!"

This series is based against my current driver-core-next branch that is in linux-next.

Greg Kroah-Hartman (21):
driver core: add local subsys_get and subsys_put functions driver core: bus: implement bus_get/put() without the private pointer driver core: bus: constantify the bus_find_* functions driver core: bus: convert bus_create/remove_file to be constant driver core: bus: sysfs function cleanups
driver core: bus: bus_add/probe/remove_device() cleanups driver core: bus: bus_register/unregister() cleanups driver core: bus: subsys_interface_register/unregister() cleanups driver core: bus: bus_get_kset() cleanup
driver core: bus: bus_register/unregister_notifier() cleanups driver core: bus: bus_add/remove_driver() cleanups
driver core: bus: bus iterator cleanups
driver core: bus: clean up bus_sort_breadthfirst()
driver core: move driver_find() to bus.c
driver core: bus: clean up driver_find()
driver core: create bus_is_registered()
driver core: remove private pointer from struct bus_type driver core: bus: constify bus_register/unregister_notifier() driver core: bus: constify bus_get_kset()
driver core: bus: constify some internal functions
driver core: bus: constify bus_unregister()

 drivers/base/base.h        |  14 ++
 drivers/base/bus.c         | 491 ++++++++++++++++++++++++++-----------
 drivers/base/driver.c      |  29 +--
 include/linux/device/bus.h |  37 ++-
 4 files changed, 375 insertions(+), 196 deletions(-)
Signature · 1 line
2.39.1