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: 2710051 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 504A0C1459 for ; Wed, 12 Jun 2013 13:09:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F78F20243 for ; Wed, 12 Jun 2013 13:09:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E768120241 for ; Wed, 12 Jun 2013 13:09:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753243Ab3FLNJG (ORCPT ); Wed, 12 Jun 2013 09:09:06 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:38321 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751483Ab3FLNJF (ORCPT ); Wed, 12 Jun 2013 09:09:05 -0400 Received: by mail-wi0-f181.google.com with SMTP id hq4so457821wib.2 for ; Wed, 12 Jun 2013 06:09:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=biYYKqnMqRfxFSht/WGqcCsOPWYHpAo98quJzO9TZF4=; b=D3Q0axL9AWg1G10k1bvV2e6xvENctG/g2yRefxccUyLG7mST9Av/cU7zYRXI1zktAO cSYWuHnjpPEsNgkSZcBwRbzQ4MGNVxH4SbS/A3daVCf1gBscT6pciaKQtOOJSjwDM9PT SLdJVMQ5Vc/CuKmkW5grAWPEd7SwTIWtC9fEQkeBMWGSjtD05Gf4wvKv0qO7K/55j3+D Uii1kGIlJci1x8kXmEg5mUy/L0BrrEh+ApofDfIH23TM49/HeHjeDcwtJQQOX5FPvMKi Ut8E2QRk19fkZTeXB3l7S/9XZ3SEOCW9Do/Z25je8hSMZeVlUHA6IEzKVBnXPLZtTzgV 0jaw== 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: ALoCoQlNArCNtuP8PHXcRifwc+bRnGvVqY3NIO8jCMdxB1GZPuNQlNgWaCjmlk734j5ZvGJBgO5d Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;