From patchwork Wed May 29 17:43:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 17276 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gh0-f197.google.com (mail-gh0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5AE2525D81 for ; Wed, 29 May 2013 17:43:50 +0000 (UTC) Received: by mail-gh0-f197.google.com with SMTP id r20sf10408473ghr.4 for ; Wed, 29 May 2013 10:43:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=rU4VwuQUHs795KSGAdET5m2Akyzsfdw+QPmVdWQEbCY=; b=IIu6WE7KSFg9kKQQDE5Je81DAD5FBLkNBnBtRiaLzgaQDzOBkFE6xIdxS1z6NbBnns WEGAJg8OT9jSC3yTPRx/2i9ZPUbPfTLnSj/fQUvkccU0/cg81KLYYeLu75ecPUgQt0Vi ZtkInNIunmbcEePSDq9l5Oi9VUyftidUASnRPE0X7lf2SXT6cdRasn2npa45l7KTbXcX eNkA08eWU//TsdwRMfx2U/BDdhYXLK3TU7sTx7px8apmjT6N7wrUXE/K3LtTs/4Mljyb Iiu7PZ9JmEdIpvj4nTofVGAdqFwHDJ+dfbVP0Gttx6SygRWI24aGTEK6l0lYk03x+2Ry 75Kg== X-Received: by 10.236.192.131 with SMTP id i3mr1841440yhn.29.1369849430111; Wed, 29 May 2013 10:43:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.86.202 with SMTP id r10ls3977759qez.86.gmail; Wed, 29 May 2013 10:43:49 -0700 (PDT) X-Received: by 10.52.164.163 with SMTP id yr3mr1954463vdb.76.1369849429935; Wed, 29 May 2013 10:43:49 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id ef7si22209715vdc.150.2013.05.29.10.43.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 May 2013 10:43:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hv10so6637294vcb.34 for ; Wed, 29 May 2013 10:43:49 -0700 (PDT) X-Received: by 10.220.246.8 with SMTP id lw8mr2340822vcb.8.1369849429780; Wed, 29 May 2013 10:43:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.229.199 with SMTP id jj7csp22134vcb; Wed, 29 May 2013 10:43:49 -0700 (PDT) X-Received: by 10.14.98.194 with SMTP id v42mr5126739eef.61.1369849428781; Wed, 29 May 2013 10:43:48 -0700 (PDT) Received: from mail-wi0-x22e.google.com (mail-wi0-x22e.google.com [2a00:1450:400c:c05::22e]) by mx.google.com with ESMTPS id r44si21618142eep.105.2013.05.29.10.43.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 May 2013 10:43:48 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c05::22e is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=2a00:1450:400c:c05::22e; Received: by mail-wi0-f174.google.com with SMTP id c10so3789351wiw.7 for ; Wed, 29 May 2013 10:43:48 -0700 (PDT) X-Received: by 10.194.171.65 with SMTP id as1mr2053657wjc.40.1369849428190; Wed, 29 May 2013 10:43:48 -0700 (PDT) Received: from mai.home (AToulouse-654-1-324-164.w86-199.abo.wanadoo.fr. [86.199.211.164]) by mx.google.com with ESMTPSA id cw8sm32657116wib.7.2013.05.29.10.43.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 May 2013 10:43:46 -0700 (PDT) From: Daniel Lezcano To: rjw@sisk.pl Cc: linux-pm@lists.linux-foundation.org, patches@linaro.org, linaro-kernel@lists.linaro.org Subject: [PATCH 6/7] cpuidle: add a cpuidle_device init function Date: Wed, 29 May 2013 19:43:33 +0200 Message-Id: <1369849414-7761-6-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1369849414-7761-1-git-send-email-daniel.lezcano@linaro.org> References: <1369849414-7761-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQn8PqDcxGws8Rde1eycCDYTQ0KWA/DtwfN8eNtSTjL8mA6sexS8jrwB5/g8yGXMXTgm8THk X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Create a specific function to initialize the cpuidle_device structure. Signed-off-by: Daniel Lezcano --- 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 8957ca5..a4f5ae6 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;