From patchwork Thu Sep 20 12:41:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 11570 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 9E1241B4E37 for ; Thu, 20 Sep 2012 12:41:33 +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 209E73D0990C for ; Thu, 20 Sep 2012 12:41:32 +0000 (UTC) Received: by ieje10 with SMTP id e10so2765252iej.11 for ; Thu, 20 Sep 2012 05:41:32 -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:x-gm-message-state; bh=PtECQ4EL3902pnlMdXcMVzl6zwh7jPUswQfwhJ3TEfw=; b=iO45db8XYAuhKBhL8tkqfK0Z2ezK2m59D9FsOViqlmL3Gz8lcMMWYTdsvKxjg+DLps hQLt/CE3/C0uRNFVV18t8/hj87mflqYuJXsqQXAjv8cRpel3k+rV1Hmc934n6qjDNNgt 1Mou6LoX3GE0b3V9jK9dtfTutZlXxg8tu/j5ESOMysV1oaAlY3Yg22KQrZ7/PeCie5dI oekNTZfmLF8yv/BLuP242GVdDUE0a64HjVtcTnO94HL/KTkD+89g6wmjmd989NiyiC/K FgjrurY34QAwz1Ep16GXYhNSftHYnyMBpYWeKKQMD68ke4oxrOiHtcaWPfSbLGZOUNJu oUmA== Received: by 10.50.0.193 with SMTP id 1mr1590510igg.0.1348144892421; Thu, 20 Sep 2012 05:41:32 -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.184.232 with SMTP id ex8csp72659igc; Thu, 20 Sep 2012 05:41:31 -0700 (PDT) Received: by 10.204.152.207 with SMTP id h15mr624272bkw.5.1348144889256; Thu, 20 Sep 2012 05:41:29 -0700 (PDT) Received: from mail-bk0-f50.google.com (mail-bk0-f50.google.com [209.85.214.50]) by mx.google.com with ESMTPS id fw13si5069492bkc.22.2012.09.20.05.41.28 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Sep 2012 05:41:29 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=209.85.214.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: by bkwq16 with SMTP id q16so195910bkw.37 for ; Thu, 20 Sep 2012 05:41:28 -0700 (PDT) Received: by 10.204.130.212 with SMTP id u20mr579351bks.121.1348144888245; Thu, 20 Sep 2012 05:41:28 -0700 (PDT) Received: from localhost.localdomain (AToulouse-651-1-259-252.w109-214.abo.wanadoo.fr. [109.214.174.252]) by mx.google.com with ESMTPS id f7sm4179689bkv.1.2012.09.20.05.41.26 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Sep 2012 05:41:27 -0700 (PDT) From: Daniel Lezcano To: rjw@sisk.pl, lenb@kernel.org Cc: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, patches@linaro.org, linaro-dev@lists.linaro.org Subject: [PATCH][V2] cpuidle : rename function name "__cpuidle_register_driver" Date: Thu, 20 Sep 2012 14:41:24 +0200 Message-Id: <1348144884-14911-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.5.4 X-Gm-Message-State: ALoCoQlWbNuUtWnh5LkSQoyOj7PMSCfW57tcX8gXKFCfnQMmw+8QBFhU4mZ5ETnHpXjvlCGYmcNI The function __cpuidle_register_driver name is confusing because it suggests, conforming to the coding style of the kernel, it registers the driver without taking a lock. Actually, it just fill the different power field states with a decresing value if the power has not been specified. Clarify the purpose of the function by changing its name and move the condition out of this function. This patch fix nothing and does not change the behavior of the function. It is just for the sake of clarity. IHMO, reading in the code: + if (!drv->power_specified) + set_power_states(drv); is much more explicit than: - __cpuidle_register_driver(drv); Signed-off-by: Daniel Lezcano --- drivers/cpuidle/driver.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 424bc81..87db387 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c @@ -18,9 +18,10 @@ static struct cpuidle_driver *cpuidle_curr_driver; DEFINE_SPINLOCK(cpuidle_driver_lock); int cpuidle_driver_refcount; -static void __cpuidle_register_driver(struct cpuidle_driver *drv) +static void set_power_states(struct cpuidle_driver *drv) { int i; + /* * cpuidle driver should set the drv->power_specified bit * before registering if the driver provides @@ -35,10 +36,8 @@ static void __cpuidle_register_driver(struct cpuidle_driver *drv) * an power value of -1. So we use -2, -3, etc, for other * c-states. */ - if (!drv->power_specified) { - for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) - drv->states[i].power_usage = -1 - i; - } + for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) + drv->states[i].power_usage = -1 - i; } /** @@ -58,8 +57,12 @@ int cpuidle_register_driver(struct cpuidle_driver *drv) spin_unlock(&cpuidle_driver_lock); return -EBUSY; } - __cpuidle_register_driver(drv); + + if (!drv->power_specified) + set_power_states(drv); + cpuidle_curr_driver = drv; + spin_unlock(&cpuidle_driver_lock); return 0;