Skip to content

Commit

Permalink
platform/surface: aggregator: Fix initialization order when compiling…
Browse files Browse the repository at this point in the history
… as builtin module

When building the Surface Aggregator Module (SAM) core, registry, and
other SAM client drivers as builtin modules (=y), proper initialization
order is not guaranteed. Due to this, client driver registration
(triggered by device registration in the registry) races against bus
initialization in the core.

If any attempt is made at registering the device driver before the bus
has been initialized (i.e. if bus initialization fails this race) driver
registration will fail with a message similar to:

    Driver surface_battery was unable to register with bus_type surface_aggregator because the bus was not initialized

Switch from module_init() to subsys_initcall() to resolve this issue.
Note that the serdev subsystem uses postcore_initcall() so we are still
able to safely register the serdev device driver for the core.

Fixes: c167b9c ("platform/surface: Add Surface Aggregator subsystem")
Reported-by: Blaž Hrastnik <blaz@mxxn.io>
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20220429195738.535751-1-luzmaximilian@gmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
Maximilian Luz authored and Hans de Goede committed May 6, 2022
1 parent 14048b9 commit 4555906
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/platform/surface/aggregator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ static int __init ssam_core_init(void)
err_bus:
return status;
}
module_init(ssam_core_init);
subsys_initcall(ssam_core_init);

static void __exit ssam_core_exit(void)
{
Expand Down

0 comments on commit 4555906

Please sign in to comment.