Commit 1eaf18e3 authored by Sudeep Holla's avatar Sudeep Holla

firmware: arm_scmi: Move scmi protocols registration into the driver

In preparation to enable building SCMI as a single module, let us move
the SCMI protocol registration call into the driver. This enables us
to also add unregistration of the SCMI protocols.

The main reason for this is to keep it simple instead of maintaining
it as separate modules and dealing with all possible initcall races
and deferred probe handling. We can move it as separate modules if
needed in future.

Link: https://lore.kernel.org/r/20200907195046.56615-4-sudeep.holla@arm.comTested-by: default avatarCristian Marussi <cristian.marussi@arm.com>
Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
parent 5a2f0a0b
...@@ -364,9 +364,4 @@ static int scmi_clock_protocol_init(struct scmi_handle *handle) ...@@ -364,9 +364,4 @@ static int scmi_clock_protocol_init(struct scmi_handle *handle)
return 0; return 0;
} }
static int __init scmi_clock_init(void) DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_CLOCK, clock)
{
return scmi_protocol_register(SCMI_PROTOCOL_CLOCK,
&scmi_clock_protocol_init);
}
subsys_initcall(scmi_clock_init);
...@@ -159,6 +159,27 @@ int scmi_base_protocol_init(struct scmi_handle *h); ...@@ -159,6 +159,27 @@ int scmi_base_protocol_init(struct scmi_handle *h);
int __init scmi_bus_init(void); int __init scmi_bus_init(void);
void __exit scmi_bus_exit(void); void __exit scmi_bus_exit(void);
#define DECLARE_SCMI_REGISTER_UNREGISTER(func) \
int __init scmi_##func##_register(void); \
void __exit scmi_##func##_unregister(void)
DECLARE_SCMI_REGISTER_UNREGISTER(clock);
DECLARE_SCMI_REGISTER_UNREGISTER(perf);
DECLARE_SCMI_REGISTER_UNREGISTER(power);
DECLARE_SCMI_REGISTER_UNREGISTER(reset);
DECLARE_SCMI_REGISTER_UNREGISTER(sensors);
DECLARE_SCMI_REGISTER_UNREGISTER(system);
#define DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(id, name) \
int __init scmi_##name##_register(void) \
{ \
return scmi_protocol_register((id), &scmi_##name##_protocol_init); \
} \
\
void __exit scmi_##name##_unregister(void) \
{ \
scmi_protocol_unregister((id)); \
}
/* SCMI Transport */ /* SCMI Transport */
/** /**
* struct scmi_chan_info - Structure representing a SCMI channel information * struct scmi_chan_info - Structure representing a SCMI channel information
......
...@@ -933,14 +933,28 @@ static int __init scmi_driver_init(void) ...@@ -933,14 +933,28 @@ static int __init scmi_driver_init(void)
{ {
scmi_bus_init(); scmi_bus_init();
scmi_clock_register();
scmi_perf_register();
scmi_power_register();
scmi_reset_register();
scmi_sensors_register();
scmi_system_register();
return platform_driver_register(&scmi_driver); return platform_driver_register(&scmi_driver);
} }
module_init(scmi_driver_init); subsys_initcall(scmi_driver_init);
static void __exit scmi_driver_exit(void) static void __exit scmi_driver_exit(void)
{ {
scmi_bus_exit(); scmi_bus_exit();
scmi_clock_unregister();
scmi_perf_unregister();
scmi_power_unregister();
scmi_reset_unregister();
scmi_sensors_unregister();
scmi_system_unregister();
platform_driver_unregister(&scmi_driver); platform_driver_unregister(&scmi_driver);
} }
module_exit(scmi_driver_exit); module_exit(scmi_driver_exit);
......
...@@ -890,9 +890,4 @@ static int scmi_perf_protocol_init(struct scmi_handle *handle) ...@@ -890,9 +890,4 @@ static int scmi_perf_protocol_init(struct scmi_handle *handle)
return 0; return 0;
} }
static int __init scmi_perf_init(void) DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_PERF, perf)
{
return scmi_protocol_register(SCMI_PROTOCOL_PERF,
&scmi_perf_protocol_init);
}
subsys_initcall(scmi_perf_init);
...@@ -301,9 +301,4 @@ static int scmi_power_protocol_init(struct scmi_handle *handle) ...@@ -301,9 +301,4 @@ static int scmi_power_protocol_init(struct scmi_handle *handle)
return 0; return 0;
} }
static int __init scmi_power_init(void) DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_POWER, power)
{
return scmi_protocol_register(SCMI_PROTOCOL_POWER,
&scmi_power_protocol_init);
}
subsys_initcall(scmi_power_init);
...@@ -313,9 +313,4 @@ static int scmi_reset_protocol_init(struct scmi_handle *handle) ...@@ -313,9 +313,4 @@ static int scmi_reset_protocol_init(struct scmi_handle *handle)
return 0; return 0;
} }
static int __init scmi_reset_init(void) DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_RESET, reset)
{
return scmi_protocol_register(SCMI_PROTOCOL_RESET,
&scmi_reset_protocol_init);
}
subsys_initcall(scmi_reset_init);
...@@ -365,9 +365,4 @@ static int scmi_sensors_protocol_init(struct scmi_handle *handle) ...@@ -365,9 +365,4 @@ static int scmi_sensors_protocol_init(struct scmi_handle *handle)
return 0; return 0;
} }
static int __init scmi_sensors_init(void) DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_SENSOR, sensors)
{
return scmi_protocol_register(SCMI_PROTOCOL_SENSOR,
&scmi_sensors_protocol_init);
}
subsys_initcall(scmi_sensors_init);
...@@ -128,9 +128,4 @@ static int scmi_system_protocol_init(struct scmi_handle *handle) ...@@ -128,9 +128,4 @@ static int scmi_system_protocol_init(struct scmi_handle *handle)
return 0; return 0;
} }
static int __init scmi_system_init(void) DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_SYSTEM, system)
{
return scmi_protocol_register(SCMI_PROTOCOL_SYSTEM,
&scmi_system_protocol_init);
}
subsys_initcall(scmi_system_init);
Markdown is supported
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