From patchwork Wed Apr 17 13:32:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 2453821 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C5FE8DF23A for ; Wed, 17 Apr 2013 13:33:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966335Ab3DQNdL (ORCPT ); Wed, 17 Apr 2013 09:33:11 -0400 Received: from mail-we0-f171.google.com ([74.125.82.171]:54722 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966186Ab3DQNdK (ORCPT ); Wed, 17 Apr 2013 09:33:10 -0400 Received: by mail-we0-f171.google.com with SMTP id i48so1253810wef.16 for ; Wed, 17 Apr 2013 06:33:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=JN/mndBzEyuIxQgGu6s9eRSBxyA3Hh8oasYEd4yJvdY=; b=ZWtE8nensKpNU1HoVgvDi6z2EgrAzxDMVGUP7cyKEV4z9qXk+GOhxpwBzNAaTBgCh5 e6sWa/3LNGFDZ0bnJqs+JbiXNQ2ciAY3mKzPORc3Qt8yCIeUm7FVpWXGIGn6ZjpgqXmB 60T+tpA6Gc3KYKU9yfnKjLylE0WXMT+b109ngFw9PctfmI24To6Etewe/4GzeKN+NCAi dfHaP0xLHVIJWHeU0Kk9cT4/MIQTyW6vIdZzNiAL7x6rIYW9bzjgMAtLl4T/ZTqw0iTF 3gGb+ejFgMWjGZGIuHpnRmlKO2NtvyyH9By4BvJjaR7eGvxrhoi/T1nNJ8xcKXc4f8b6 VjRg== X-Received: by 10.180.90.70 with SMTP id bu6mr778541wib.34.1366205589222; Wed, 17 Apr 2013 06:33:09 -0700 (PDT) Received: from mai.home (AToulouse-654-1-349-85.w90-55.abo.wanadoo.fr. [90.55.188.85]) by mx.google.com with ESMTPS id ej8sm25556799wib.9.2013.04.17.06.33.04 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Apr 2013 06:33:05 -0700 (PDT) From: Daniel Lezcano To: lethal@linux-sh.org, rjw@sisk.pl Cc: linux-sh@vger.kernel.org, linux-pm@vger.kernel.org, patches@linaro.org Subject: [PATCH 3/4] SH: cpuidle: initialize the driver's states directly Date: Wed, 17 Apr 2013 15:32:56 +0200 Message-Id: <1366205577-11632-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1366205577-11632-1-git-send-email-daniel.lezcano@linaro.org> References: <1366205577-11632-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQnEiAHPJEMQXdzDNCzuPa9zhEmpwxG38FilujdGWtVfc7wcx5/khxfCRAFbA33ZQ3PRWf5j Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org 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 --- arch/sh/kernel/cpu/shmobile/cpuidle.c | 90 +++++++++++++++------------------ 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/arch/sh/kernel/cpu/shmobile/cpuidle.c b/arch/sh/kernel/cpu/shmobile/cpuidle.c index 36374cc..f024acf 100644 --- a/arch/sh/kernel/cpu/shmobile/cpuidle.c +++ b/arch/sh/kernel/cpu/shmobile/cpuidle.c @@ -53,59 +53,51 @@ static int cpuidle_sleep_enter(struct cpuidle_device *dev, static struct cpuidle_device cpuidle_dev; static struct cpuidle_driver cpuidle_driver = { - .name = "sh_idle", - .owner = THIS_MODULE, + .name = "sh_idle", + .owner = THIS_MODULE, + .states = { + { + .exit_latency = 1, + .target_residency = 1 * 2, + .power_usage = 3, + .flags = CPUIDLE_FLAG_TIME_VALID, + .enter = cpuidle_sleep_enter, + .name = "C1", + .desc = "SuperH Sleep Mode", + }, + { + .exit_latency = 100, + .target_residency = 1 * 2, + .power_usage = 1, + .flags = CPUIDLE_FLAG_TIME_VALID, + .enter = cpuidle_sleep_enter, + .name = "C2", + .desc = "SuperH Sleep Mode [SF]", + .disabled = true, + }, + { + .exit_latency = 2300, + .target_residency = 1 * 2, + .power_usage = 1, + .flags = CPUIDLE_FLAG_TIME_VALID, + .enter = cpuidle_sleep_enter, + .name = "C3", + .desc = "SuperH Mobile Standby Mode [SF]", + .disabled = true, + }, + }, + .safe_state_index = 0, + .state_count = 3, }; void sh_mobile_setup_cpuidle(void) { - struct cpuidle_device *dev = &cpuidle_dev; - struct cpuidle_driver *drv = &cpuidle_driver; - struct cpuidle_state *state; - int i = 0; + if (sh_mobile_sleep_supported & SUSP_SH_SF) + cpuidle_driver.states[1].disabled = false; - state = &drv->states[i++]; - snprintf(state->name, CPUIDLE_NAME_LEN, "C1"); - strncpy(state->desc, "SuperH Sleep Mode", CPUIDLE_DESC_LEN); - state->exit_latency = 1; - state->target_residency = 1 * 2; - state->power_usage = 3; - state->flags = 0; - state->flags |= CPUIDLE_FLAG_TIME_VALID; - state->enter = cpuidle_sleep_enter; + if (sh_mobile_sleep_supported & SUSP_SH_STANDBY) + cpuidle_driver.states[2].disabled = false; - drv->safe_state_index = 0; - - if (sh_mobile_sleep_supported & SUSP_SH_SF) { - state = &drv->states[i++]; - snprintf(state->name, CPUIDLE_NAME_LEN, "C2"); - strncpy(state->desc, "SuperH Sleep Mode [SF]", - CPUIDLE_DESC_LEN); - state->exit_latency = 100; - state->target_residency = 1 * 2; - state->power_usage = 1; - state->flags = 0; - state->flags |= CPUIDLE_FLAG_TIME_VALID; - state->enter = cpuidle_sleep_enter; - } - - if (sh_mobile_sleep_supported & SUSP_SH_STANDBY) { - state = &drv->states[i++]; - snprintf(state->name, CPUIDLE_NAME_LEN, "C3"); - strncpy(state->desc, "SuperH Mobile Standby Mode [SF]", - CPUIDLE_DESC_LEN); - state->exit_latency = 2300; - state->target_residency = 1 * 2; - state->power_usage = 1; - state->flags = 0; - state->flags |= CPUIDLE_FLAG_TIME_VALID; - state->enter = cpuidle_sleep_enter; - } - - drv->state_count = i; - dev->state_count = i; - - cpuidle_register_driver(&cpuidle_driver); - - cpuidle_register_device(dev); + if (!cpuidle_register_driver(&cpuidle_driver)) + cpuidle_register_device(&cpuidle_dev); }