Skip to content
Commit 884f8ce4 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

driver core: class: implement class_get/put without the private pointer.

Much like what was done in commit 273afac6

 ("driver core: bus:
implement bus_get/put() without the private pointer"), it is time to
move the driver core away from using the internal private pointer in
struct class in order to enable it to be always a constant and be placed
in read-only memory in the future.

First step in doing this is to create a helper function that turns a
'struct class' into 'struct subsys_private' called class_to_subsys().

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

Implement class_get() and class_put() using this new helper function.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230325194234.46588-1-gregkh@linuxfoundation.org
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 75a2d422
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