driver core: bus: implement bus_get/put() without the private pointer
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Feb 2023 11:13:11 +0000 (12:13 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2023 09:43:07 +0000 (10:43 +0100)
commit273afac615adccf97bd4e70ebfb27074f1ff22b9
tree1625597d52c9e18ac1570579f22a8b973215f711
parent789be03a600842ef461968cc5a2d458f51f319b2
driver core: bus: implement bus_get/put() without the private pointer

In the quest to make 'struct bus_type' constant and in read-only memory,
we need to stop using the private pointer to the subsys_private
structure.  First step in doing this is to create a helper function that
turns a 'struct bus_type' into 'struct subsys_private' called
bus_to_subsys().

bus_to_subsys() walks the list of registered busses in the system and
finds the matching one based on the pointer to the bus_type itself.  As
this is a short list, and this function is not on any fast path, it
should not be noticable.

Implement bus_get() and bus_put() using this new helper function.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230208111330.439504-3-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/bus.c