Skip to content

Commit 0a4f841

Browse files
dlezcanorafaeljw
authored andcommitted
SH: cpuidle: initialize the driver's states directly
Like all the other drivers, let's initialize the structure a compile time instead of init time. The states #1 and #2 are not enabled by default. The init function will check the features of the board in order to enable the state. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Simon Horman <horms+renesas@verge.net.au> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 194db92 commit 0a4f841

1 file changed

Lines changed: 42 additions & 50 deletions

File tree

arch/sh/kernel/cpu/shmobile/cpuidle.c

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -53,60 +53,52 @@ static int cpuidle_sleep_enter(struct cpuidle_device *dev,
5353

5454
static struct cpuidle_device cpuidle_dev;
5555
static struct cpuidle_driver cpuidle_driver = {
56-
.name = "sh_idle",
57-
.owner = THIS_MODULE,
58-
.en_core_tk_irqen = 1,
56+
.name = "sh_idle",
57+
.owner = THIS_MODULE,
58+
.en_core_tk_irqen = 1,
59+
.states = {
60+
{
61+
.exit_latency = 1,
62+
.target_residency = 1 * 2,
63+
.power_usage = 3,
64+
.flags = CPUIDLE_FLAG_TIME_VALID,
65+
.enter = cpuidle_sleep_enter,
66+
.name = "C1",
67+
.desc = "SuperH Sleep Mode",
68+
},
69+
{
70+
.exit_latency = 100,
71+
.target_residency = 1 * 2,
72+
.power_usage = 1,
73+
.flags = CPUIDLE_FLAG_TIME_VALID,
74+
.enter = cpuidle_sleep_enter,
75+
.name = "C2",
76+
.desc = "SuperH Sleep Mode [SF]",
77+
.disabled = true,
78+
},
79+
{
80+
.exit_latency = 2300,
81+
.target_residency = 1 * 2,
82+
.power_usage = 1,
83+
.flags = CPUIDLE_FLAG_TIME_VALID,
84+
.enter = cpuidle_sleep_enter,
85+
.name = "C3",
86+
.desc = "SuperH Mobile Standby Mode [SF]",
87+
.disabled = true,
88+
},
89+
},
90+
.safe_state_index = 0,
91+
.state_count = 3,
5992
};
6093

6194
void sh_mobile_setup_cpuidle(void)
6295
{
63-
struct cpuidle_device *dev = &cpuidle_dev;
64-
struct cpuidle_driver *drv = &cpuidle_driver;
65-
struct cpuidle_state *state;
66-
int i = 0;
96+
if (sh_mobile_sleep_supported & SUSP_SH_SF)
97+
cpuidle_driver.states[1].disabled = false;
6798

68-
state = &drv->states[i++];
69-
snprintf(state->name, CPUIDLE_NAME_LEN, "C1");
70-
strncpy(state->desc, "SuperH Sleep Mode", CPUIDLE_DESC_LEN);
71-
state->exit_latency = 1;
72-
state->target_residency = 1 * 2;
73-
state->power_usage = 3;
74-
state->flags = 0;
75-
state->flags |= CPUIDLE_FLAG_TIME_VALID;
76-
state->enter = cpuidle_sleep_enter;
99+
if (sh_mobile_sleep_supported & SUSP_SH_STANDBY)
100+
cpuidle_driver.states[2].disabled = false;
77101

78-
drv->safe_state_index = 0;
79-
80-
if (sh_mobile_sleep_supported & SUSP_SH_SF) {
81-
state = &drv->states[i++];
82-
snprintf(state->name, CPUIDLE_NAME_LEN, "C2");
83-
strncpy(state->desc, "SuperH Sleep Mode [SF]",
84-
CPUIDLE_DESC_LEN);
85-
state->exit_latency = 100;
86-
state->target_residency = 1 * 2;
87-
state->power_usage = 1;
88-
state->flags = 0;
89-
state->flags |= CPUIDLE_FLAG_TIME_VALID;
90-
state->enter = cpuidle_sleep_enter;
91-
}
92-
93-
if (sh_mobile_sleep_supported & SUSP_SH_STANDBY) {
94-
state = &drv->states[i++];
95-
snprintf(state->name, CPUIDLE_NAME_LEN, "C3");
96-
strncpy(state->desc, "SuperH Mobile Standby Mode [SF]",
97-
CPUIDLE_DESC_LEN);
98-
state->exit_latency = 2300;
99-
state->target_residency = 1 * 2;
100-
state->power_usage = 1;
101-
state->flags = 0;
102-
state->flags |= CPUIDLE_FLAG_TIME_VALID;
103-
state->enter = cpuidle_sleep_enter;
104-
}
105-
106-
drv->state_count = i;
107-
dev->state_count = i;
108-
109-
cpuidle_register_driver(&cpuidle_driver);
110-
111-
cpuidle_register_device(dev);
102+
if (!cpuidle_register_driver(&cpuidle_driver))
103+
cpuidle_register_device(&cpuidle_dev);
112104
}

0 commit comments

Comments
 (0)