ARM: tegra2: cpuidle: change driver initialization
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 3 Apr 2013 12:15:17 +0000 (12:15 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 8 Apr 2013 20:20:06 +0000 (22:20 +0200)
Initialize the idle states directly in the driver structure.

That prevents extra structure declaration and memcpy at init time.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Joseph Lo <josephl@nvidia.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
arch/arm/mach-tegra/cpuidle-tegra20.c

index 825ced4f7a404a48adc8861e35930a024aff30b2..1ad1a67890eb8205cd85e05f1a040e1998af5c42 100644 (file)
@@ -43,28 +43,32 @@ static atomic_t abort_barrier;
 static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
                                    struct cpuidle_driver *drv,
                                    int index);
+#define TEGRA20_MAX_STATES 2
+#else
+#define TEGRA20_MAX_STATES 1
 #endif
 
-static struct cpuidle_state tegra_idle_states[] = {
-       [0] = ARM_CPUIDLE_WFI_STATE_PWR(600),
-#ifdef CONFIG_PM_SLEEP
-       [1] = {
-               .enter                  = tegra20_idle_lp2_coupled,
-               .exit_latency           = 5000,
-               .target_residency       = 10000,
-               .power_usage            = 0,
-               .flags                  = CPUIDLE_FLAG_TIME_VALID |
-                                         CPUIDLE_FLAG_COUPLED,
-               .name                   = "powered-down",
-               .desc                   = "CPU power gated",
-       },
-#endif
-};
-
 static struct cpuidle_driver tegra_idle_driver = {
        .name = "tegra_idle",
        .owner = THIS_MODULE,
        .en_core_tk_irqen = 1,
+       .states = {
+               ARM_CPUIDLE_WFI_STATE_PWR(600),
+#ifdef CONFIG_PM_SLEEP
+               {
+                       .enter            = tegra20_idle_lp2_coupled,
+                       .exit_latency     = 5000,
+                       .target_residency = 10000,
+                       .power_usage      = 0,
+                       .flags            = CPUIDLE_FLAG_TIME_VALID |
+                       CPUIDLE_FLAG_COUPLED,
+                       .name             = "powered-down",
+                       .desc             = "CPU power gated",
+               },
+#endif
+       },
+       .state_count = TEGRA20_MAX_STATES,
+       .safe_state_index = 0,
 };
 
 static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
@@ -226,10 +230,6 @@ int __init tegra20_cpuidle_init(void)
        tegra_tear_down_cpu = tegra20_tear_down_cpu;
 #endif
 
-       drv->state_count = ARRAY_SIZE(tegra_idle_states);
-       memcpy(drv->states, tegra_idle_states,
-                       drv->state_count * sizeof(drv->states[0]));
-
        ret = cpuidle_register_driver(&tegra_idle_driver);
        if (ret) {
                pr_err("CPUidle driver registration failed\n");