From patchwork Wed Jun 12 13:08:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 17832 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0163F25E4A for ; Wed, 12 Jun 2013 13:09:06 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id z20sf4244710yhz.3 for ; Wed, 12 Jun 2013 06:09:06 -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=biYYKqnMqRfxFSht/WGqcCsOPWYHpAo98quJzO9TZF4=; b=W6WqxPQz3Q4YsDDtAIct54VUY8WUsD8hn4bl74tJ31U8rtWyoPFK4QttN5ViEllldN oIsapVji/tRIbX40Qx2ts0xAAt1IYxuk3T86mcCC/unGFoE0gNYw4/8qRlrj4xQuYqPi F5c4JJnE9WDTv4MoIQ6NDMYkGfNrk7rXMFUbaaRGxXyAFL+O8JsldlSD6WDfV/LnVoca +FJLwdcBFKALAcwMAXqNcfSELmaGVD3xOMz0WPX/e2Y2gDcMgtfm3y9xOIg2gj3zlhLy a5o2rrdLEYHhPhVSKU/gJE9WyDuKMFnbyzZb5sDJIQblQpPaoZG6DSZZnS3ZQ0NoV2ft mwgA== X-Received: by 10.236.74.132 with SMTP id x4mr11144156yhd.34.1371042546669; Wed, 12 Jun 2013 06:09:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.26.137 with SMTP id l9ls614140qeg.35.gmail; Wed, 12 Jun 2013 06:09:06 -0700 (PDT) X-Received: by 10.52.0.198 with SMTP id 6mr8207823vdg.65.1371042546436; Wed, 12 Jun 2013 06:09:06 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id c5si8548713vcl.91.2013.06.12.06.09.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 06:09:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.172 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.172; Received: by mail-vc0-f172.google.com with SMTP id ib11so6188895vcb.17 for ; Wed, 12 Jun 2013 06:09:06 -0700 (PDT) X-Received: by 10.220.215.73 with SMTP id hd9mr9802391vcb.19.1371042546214; Wed, 12 Jun 2013 06:09:06 -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.58.191.99 with SMTP id gx3csp143395vec; Wed, 12 Jun 2013 06:09:05 -0700 (PDT) X-Received: by 10.194.63.229 with SMTP id j5mr11743433wjs.79.1371042545305; Wed, 12 Jun 2013 06:09:05 -0700 (PDT) Received: from mail-we0-x22e.google.com (mail-we0-x22e.google.com [2a00:1450:400c:c03::22e]) by mx.google.com with ESMTPS id ca2si7197729wjc.67.2013.06.12.06.09.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 06:09:05 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::22e is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=2a00:1450:400c:c03::22e; Received: by mail-we0-f174.google.com with SMTP id q58so6745864wes.5 for ; Wed, 12 Jun 2013 06:09:04 -0700 (PDT) X-Received: by 10.180.76.137 with SMTP id k9mr1123111wiw.62.1371042544784; Wed, 12 Jun 2013 06:09:04 -0700 (PDT) Received: from mai.home (AToulouse-654-1-404-219.w82-125.abo.wanadoo.fr. [82.125.3.219]) by mx.google.com with ESMTPSA id x13sm24555864wib.3.2013.06.12.06.09.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 06:09:04 -0700 (PDT) From: Daniel Lezcano 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 Message-Id: <1371042535-22630-7-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1371042535-22630-1-git-send-email-daniel.lezcano@linaro.org> References: <1371042535-22630-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQlbF4XGmhe4Rxj23ohfkbv3lbQ5uLn1neq3DrOpHacJbL2doCsbrY4y1TahfBgxC2CJS5WV X-Original-Sender: daniel.lezcano@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.172 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 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;