]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
driver core: faux: Add sysfs groups after probing
authorKurt Borja <kuurtb@gmail.com>
Thu, 27 Mar 2025 23:19:37 +0000 (20:19 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Apr 2025 12:16:08 +0000 (14:16 +0200)
commitd487858ebffaab9acd8945f19ef400ec6eda11f1
treef6628cbde04a4a9ab6351cb9db80b25a9da6bb40
parent0af2f6be1b4281385b618cb86ad946eded089ac8
driver core: faux: Add sysfs groups after probing

Manually add sysfs groups after the faux_device_ops's probe succeeds.
Likewise remove these groups just before calling the faux_devices_ops's
remove callback. This approach approximates the order in which the
driver core adds and removes the driver's .dev_groups of a device to
avoid lifetime issues.

This is done specifically to avoid using the device's .groups member,
which adds groups before the device is even registered to the bus.

This lets consumers of this API, initialize resources on the .probe
callback and then use them inside is_visible/show/store methods, through
dev_get_drvdata() without races.

Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
Link: https://lore.kernel.org/r/20250327-faux-groups-v2-1-745a3cf0bc16@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/faux.c