From patchwork Fri Oct 19 09:51:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12362 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C4B1F23EFE for ; Fri, 19 Oct 2012 09:51:43 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6E635A19798 for ; Fri, 19 Oct 2012 09:51:43 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so316502iej.11 for ; Fri, 19 Oct 2012 02:51:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=+zMNSL4DpCNGVeJrApHrfnIoHqOOyOCE+qjGt92rLDY=; b=p0IPgIQAj6fYC5j1dIzmMsQZAXTKsRb54orcnMTnMXKxqHlBACGqsoQm0jBcL6OZFg /xNRt7g7uAheeSdKBD6xCijfG0+bBFxA/xhy9NAskhLyYYxn0pioDGxm9RpwTG0yTanX xFPpJZYcVW7NvMW+IMsbjpFsUb8UAoI04zUt7GVQ4lo0sUk7Djo2XZ+e0UvKt4Rs/K9N dme5+bYsv1pAOSzAWnOAbjuUozH0Dd/rK/BAyhflpSbOSUJkW+isHdeMMBZ1VLnX1gH2 C4zBWoR0DUNm9ZVUWRXauaEhj8qdcnVKera4ggeZrJE4/LmsEIGwiSxez328tZgiHC9G ZA2g== Received: by 10.50.168.37 with SMTP id zt5mr560357igb.57.1350640303219; Fri, 19 Oct 2012 02:51:43 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp53895igt; Fri, 19 Oct 2012 02:51:42 -0700 (PDT) Received: by 10.216.136.31 with SMTP id v31mr516157wei.104.1350640301554; Fri, 19 Oct 2012 02:51:41 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id q79si1289781wen.24.2012.10.19.02.51.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Oct 2012 02:51:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=209.85.212.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: by mail-wi0-f178.google.com with SMTP id hr7so20967wib.13 for ; Fri, 19 Oct 2012 02:51:41 -0700 (PDT) Received: by 10.216.227.101 with SMTP id c79mr538627weq.31.1350640301055; Fri, 19 Oct 2012 02:51:41 -0700 (PDT) Received: from localhost.localdomain (AToulouse-654-1-1-158.w90-5.abo.wanadoo.fr. [90.5.56.158]) by mx.google.com with ESMTPS id dt9sm33952821wib.1.2012.10.19.02.51.39 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Oct 2012 02:51:40 -0700 (PDT) From: Daniel Lezcano To: lenb@kernel.org, rjw@sisk.pl Cc: linux-acpi@vger.kernel.org, linaro-dev@lists.linaro.org, patches@linaro.org Subject: [PATCH 4/5] cpuidle / ACPI : change indentation logic Date: Fri, 19 Oct 2012 11:51:31 +0200 Message-Id: <1350640292-22468-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1350640292-22468-1-git-send-email-daniel.lezcano@linaro.org> References: <1350640292-22468-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQl5gGnRiyrEdNdrg1zanEYJ0tyzjDPfIBUO0LnGnS8YEGt+pf50xGUEsfgIVGNffNk7pA4U This patch changes the indentation by returning from the function if pr->flags.power is not set. That allows to have the remaining code out of a 'if' section. Even if the patch does not fix anything, it makes the code a bit more readable for the future cleanups. Signed-off-by: Daniel Lezcano --- drivers/acpi/processor_idle.c | 112 +++++++++++++++++++++-------------------- 1 files changed, 58 insertions(+), 54 deletions(-) diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 5c4330f..f87cb2e 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -1164,40 +1164,39 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) * system instead of once per-cpu. This condition is a hack * to make the code that updates C-States be called once. */ + if (pr->id != 0 || cpuidle_get_driver() != &acpi_idle_driver) + return 0; - if (pr->id == 0 && cpuidle_get_driver() == &acpi_idle_driver) { - - cpuidle_pause_and_lock(); - /* Protect against cpu-hotplug */ - get_online_cpus(); + cpuidle_pause_and_lock(); + /* Protect against cpu-hotplug */ + get_online_cpus(); - /* Disable all cpuidle devices */ - for_each_online_cpu(cpu) { - _pr = per_cpu(processors, cpu); - if (!_pr || !_pr->flags.power_setup_done) - continue; - dev = per_cpu(acpi_cpuidle_device, cpu); - cpuidle_disable_device(dev); - } + /* Disable all cpuidle devices */ + for_each_online_cpu(cpu) { + _pr = per_cpu(processors, cpu); + if (!_pr || !_pr->flags.power_setup_done) + continue; + dev = per_cpu(acpi_cpuidle_device, cpu); + cpuidle_disable_device(dev); + } - /* Populate Updated C-state information */ - acpi_processor_setup_cpuidle_states(pr); + /* Populate Updated C-state information */ + acpi_processor_setup_cpuidle_states(pr); - /* Enable all cpuidle devices */ - for_each_online_cpu(cpu) { - _pr = per_cpu(processors, cpu); - if (!_pr || !_pr->flags.power_setup_done) - continue; - acpi_processor_get_power_info(_pr); - if (_pr->flags.power) { - dev = per_cpu(acpi_cpuidle_device, cpu); - acpi_processor_setup_cpuidle_cx(_pr, dev); - cpuidle_enable_device(dev); - } + /* Enable all cpuidle devices */ + for_each_online_cpu(cpu) { + _pr = per_cpu(processors, cpu); + if (!_pr || !_pr->flags.power_setup_done) + continue; + acpi_processor_get_power_info(_pr); + if (_pr->flags.power) { + dev = per_cpu(acpi_cpuidle_device, cpu); + acpi_processor_setup_cpuidle_cx(_pr, dev); + cpuidle_enable_device(dev); } - put_online_cpus(); - cpuidle_resume_and_unlock(); } + put_online_cpus(); + cpuidle_resume_and_unlock(); return 0; } @@ -1229,7 +1228,8 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr) if (acpi_gbl_FADT.cst_control && !nocst) { status = - acpi_os_write_port(acpi_gbl_FADT.smi_command, acpi_gbl_FADT.cst_control, 8); + acpi_os_write_port(acpi_gbl_FADT.smi_command, + acpi_gbl_FADT.cst_control, 8); if (ACPI_FAILURE(status)) { ACPI_EXCEPTION((AE_INFO, status, "Notifying BIOS of _CST ability failed")); @@ -1239,40 +1239,44 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr) acpi_processor_get_power_info(pr); pr->flags.power_setup_done = 1; + if (!pr->flags.power) + return 0; + /* * Install the idle handler if processor power management is supported. * Note that we use previously set idle handler will be used on * platforms that only support C1. */ - if (pr->flags.power) { - /* Register acpi_idle_driver if not already registered */ - if (!acpi_processor_registered) { - acpi_processor_setup_cpuidle_states(pr); - retval = cpuidle_register_driver(&acpi_idle_driver); - if (retval) - return retval; - printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n", - acpi_idle_driver.name); - } - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) - return -ENOMEM; - per_cpu(acpi_cpuidle_device, pr->id) = dev; + /* Register acpi_idle_driver if not already registered */ + if (!acpi_processor_registered) { + acpi_processor_setup_cpuidle_states(pr); + retval = cpuidle_register_driver(&acpi_idle_driver); + if (retval) + return retval; + printk(KERN_DEBUG "ACPI: %s registered with cpuidle\n", + acpi_idle_driver.name); + } - acpi_processor_setup_cpuidle_cx(pr, dev); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + per_cpu(acpi_cpuidle_device, pr->id) = dev; - /* Register per-cpu cpuidle_device. Cpuidle driver - * must already be registered before registering device - */ - retval = cpuidle_register_device(dev); - if (retval) { - if (acpi_processor_registered == 0) - cpuidle_unregister_driver(&acpi_idle_driver); - return retval; - } - acpi_processor_registered++; + acpi_processor_setup_cpuidle_cx(pr, dev); + + /* Register per-cpu cpuidle_device. Cpuidle driver + * must already be registered before registering device + */ + retval = cpuidle_register_device(dev); + if (retval) { + if (acpi_processor_registered == 0) + cpuidle_unregister_driver(&acpi_idle_driver); + return retval; } + + acpi_processor_registered++; + return 0; }