static uint32_t cur_idle_nums;
static unsigned int core_parking_cpunum[NR_CPUS] = {[0 ... NR_CPUS-1] = -1};
-static const struct cp_policy {
+struct cp_policy {
char name[30];
unsigned int (*next)(unsigned int event);
-} *__read_mostly core_parking_policy;
+};
+static struct cp_policy __ro_after_init core_parking_policy;
static enum core_parking_controller {
POWER_FIRST,
unsigned int cpu;
int ret = 0;
- if ( !core_parking_policy )
+ if ( !core_parking_policy.next )
return -EINVAL;
while ( cur_idle_nums < idle_nums )
{
- cpu = core_parking_policy->next(CORE_PARKING_INCREMENT);
+ cpu = alternative_call(core_parking_policy.next,
+ CORE_PARKING_INCREMENT);
ret = cpu_down(cpu);
if ( ret )
return ret;
while ( cur_idle_nums > idle_nums )
{
- cpu = core_parking_policy->next(CORE_PARKING_DECREMENT);
+ cpu = alternative_call(core_parking_policy.next,
+ CORE_PARKING_DECREMENT);
ret = cpu_up(cpu);
if ( ret )
return ret;
return cur_idle_nums;
}
-static const struct cp_policy power_first = {
+static const struct cp_policy __initconst_cf_clobber power_first = {
.name = "power",
.next = core_parking_power,
};
-static const struct cp_policy performance_first = {
+static const struct cp_policy __initconst_cf_clobber performance_first = {
.name = "performance",
.next = core_parking_performance,
};
if ( !policy || !policy->next )
return -EINVAL;
- core_parking_policy = policy;
+ core_parking_policy = *policy;
return 0;
}
return ret;
}
-__initcall(core_parking_init);
+presmp_initcall(core_parking_init);