syscore: Pass context data to callbacks

Several drivers can benefit from registering per-instance data along
with the syscore operations. To achieve this, move the modifiable fields
out of the syscore_ops structure and into a separate struct syscore that
can be registered with the framework. Add a void * driver data field for
drivers to store contextual data that will be passed to the syscore ops.

Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
This commit is contained in:
Thierry Reding
2025-10-29 17:33:30 +01:00
parent 3a86608788
commit a97fbc3ee3
109 changed files with 899 additions and 471 deletions

View File

@@ -3639,12 +3639,13 @@ static bool legacy_kthread_create(void)
/**
* printk_kthreads_shutdown - shutdown all threaded printers
* @data: syscore context
*
* On system shutdown all threaded printers are stopped. This allows printk
* to transition back to atomic printing, thus providing a robust mechanism
* for the final shutdown/reboot messages to be output.
*/
static void printk_kthreads_shutdown(void)
static void printk_kthreads_shutdown(void *data)
{
struct console *con;
@@ -3666,10 +3667,14 @@ static void printk_kthreads_shutdown(void)
console_list_unlock();
}
static struct syscore_ops printk_syscore_ops = {
static const struct syscore_ops printk_syscore_ops = {
.shutdown = printk_kthreads_shutdown,
};
static struct syscore printk_syscore = {
.ops = &printk_syscore_ops,
};
/*
* If appropriate, start nbcon kthreads and set @printk_kthreads_running.
* If any kthreads fail to start, those consoles are unregistered.
@@ -3737,7 +3742,7 @@ static void printk_kthreads_check_locked(void)
static int __init printk_set_kthreads_ready(void)
{
register_syscore_ops(&printk_syscore_ops);
register_syscore(&printk_syscore);
console_list_lock();
printk_kthreads_ready = true;