linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: rjw@sisk.pl
Cc: linux-pm@vger.kernel.org, linaro-kernel@lists.linaro.org,
	patches@linaro.org
Subject: [PATCH 7/8] cpuidle: Add a cpuidle_device init function
Date: Wed, 12 Jun 2013 15:08:54 +0200	[thread overview]
Message-ID: <1371042535-22630-7-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1371042535-22630-1-git-send-email-daniel.lezcano@linaro.org>

Create a specific function to initialize the cpuidle_device structure.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpuidle/cpuidle.c |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index bdb7180..7c3f625 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -276,7 +276,7 @@ static void poll_idle_init(struct cpuidle_driver *drv) {}
  */
 int cpuidle_enable_device(struct cpuidle_device *dev)
 {
-	int ret, i;
+	int ret;
 	struct cpuidle_driver *drv;
 
 	if (!dev)
@@ -306,12 +306,6 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
 	    (ret = cpuidle_curr_governor->enable(drv, dev)))
 		goto fail_sysfs;
 
-	for (i = 0; i < dev->state_count; i++) {
-		dev->states_usage[i].usage = 0;
-		dev->states_usage[i].time = 0;
-	}
-	dev->last_residency = 0;
-
 	smp_wmb();
 
 	dev->enabled = 1;
@@ -364,6 +358,14 @@ static void __cpuidle_unregister_device(struct cpuidle_device *dev)
 	module_put(drv->owner);
 }
 
+static int __cpuidle_device_init(struct cpuidle_device *dev)
+{
+	memset(dev->states_usage, 0, sizeof(dev->states_usage));
+	dev->last_residency = 0;
+
+	return 0;
+}
+
 /**
  * __cpuidle_register_device - internal register function called before register
  * and enable routines
@@ -405,6 +407,10 @@ int cpuidle_register_device(struct cpuidle_device *dev)
 
 	mutex_lock(&cpuidle_lock);
 
+	ret = __cpuidle_device_init(dev);
+	if (ret)
+		goto out_unlock;
+
 	ret = __cpuidle_register_device(dev);
 	if (ret)
 		goto out_unlock;
-- 
1.7.9.5


  parent reply	other threads:[~2013-06-12 13:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-12 13:08 [PATCH 1/8] cpuidle: Remove governor module format Daniel Lezcano
2013-06-12 13:08 ` [PATCH 2/8] cpuidle: Check cpuidle_enable_device succeed Daniel Lezcano
2013-06-12 13:08 ` [PATCH 3/8] cpuidle: Fix indentation and conform to Coding Style Daniel Lezcano
2013-06-12 13:08 ` [PATCH 4/8] cpuidle: Make cpuidle's sysfs directory dynamically allocated Daniel Lezcano
2013-06-12 13:08 ` [PATCH 5/8] cpuidle: Add missing forward declaration Daniel Lezcano
2013-06-12 13:08 ` [PATCH 6/8] cpuidle: Encapsulate code in __cpuidle_unregister_device Daniel Lezcano
2013-06-12 13:08 ` Daniel Lezcano [this message]
2013-06-12 13:08 ` [PATCH 8/8] cpuidle: Check the device is not already registered Daniel Lezcano
2013-06-12 22:53 ` [PATCH 1/8] cpuidle: Remove governor module format Rafael J. Wysocki
2013-06-13 11:57   ` Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1371042535-22630-7-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=rjw@sisk.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).