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

@@ -1944,7 +1944,7 @@ static void mpic_suspend_one(struct mpic *mpic)
}
}
static int mpic_suspend(void)
static int mpic_suspend(void *data)
{
struct mpic *mpic = mpics;
@@ -1986,7 +1986,7 @@ static void mpic_resume_one(struct mpic *mpic)
} /* end for loop */
}
static void mpic_resume(void)
static void mpic_resume(void *data)
{
struct mpic *mpic = mpics;
@@ -1996,19 +1996,23 @@ static void mpic_resume(void)
}
}
static struct syscore_ops mpic_syscore_ops = {
static const struct syscore_ops mpic_syscore_ops = {
.resume = mpic_resume,
.suspend = mpic_suspend,
};
static struct syscore mpic_syscore = {
.ops = &mpic_syscore_ops,
};
static int mpic_init_sys(void)
{
int rc;
register_syscore_ops(&mpic_syscore_ops);
register_syscore(&mpic_syscore);
rc = subsys_system_register(&mpic_subsys, NULL);
if (rc) {
unregister_syscore_ops(&mpic_syscore_ops);
unregister_syscore(&mpic_syscore);
pr_err("mpic: Failed to register subsystem!\n");
return rc;
}