From patchwork Mon Mar 26 12:51:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 7464 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 9B2C423E12 for ; Mon, 26 Mar 2012 12:51:30 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 58087A1889E for ; Mon, 26 Mar 2012 12:51:30 +0000 (UTC) Received: by iage36 with SMTP id e36so10845518iag.11 for ; Mon, 26 Mar 2012 05:51:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-forwarded-to:x-forwarded-for:delivered-to :received-spf:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=9j+GiFFXHDfZ6Z6gywidGl4+mHcBdVUJ83GpVQSJ6Z4=; b=IrztJfEnuhZ1/b+GmtluZpyrI9JPqbZVBhdjvY7rBNros+hesqvckdDJqBTGsTmIV4 F2qTD6Qeu6sWIo62XDPz2T8jmFC/imBi0vM73KSB7dmTjw9JNbyuVnTbmaSRn5HsyKG5 5YMs7549Wv4iSN0GBDmq57Nr9K0X9eHqmfwpqrUZben75jNhNj12sO9v6hP98Bglw/hq 5hTj4AuHath/zh1Zw+fpPSwQkeN5enO1uGmWwFl8Bej7V5yZLj+hmmroEspnS3pJgJjA 7IMhCA/8wOol9Nzrgl6QzxM7hhOoH1emlgqoz35n2vadH7uQEewCLyEzUQQ1GRUrpWnS bD4Q== MIME-Version: 1.0 Received: by 10.50.194.226 with SMTP id hz2mr5358536igc.44.1332766289624; Mon, 26 Mar 2012 05:51:29 -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.231.5.205 with SMTP id 13csp18464ibw; Mon, 26 Mar 2012 05:51:28 -0700 (PDT) Received: by 10.180.78.225 with SMTP id e1mr18278261wix.0.1332766287443; Mon, 26 Mar 2012 05:51:27 -0700 (PDT) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by mx.google.com with ESMTPS id x8si17054927weq.7.2012.03.26.05.51.26 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Mar 2012 05:51:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=209.85.212.172; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: by wibhj6 with SMTP id hj6so3456514wib.13 for ; Mon, 26 Mar 2012 05:51:26 -0700 (PDT) Received: by 10.216.139.25 with SMTP id b25mr11944868wej.41.1332766286798; Mon, 26 Mar 2012 05:51:26 -0700 (PDT) Received: from localhost.localdomain (AToulouse-159-1-37-30.w92-134.abo.wanadoo.fr. [92.134.76.30]) by mx.google.com with ESMTPS id b3sm40713855wib.4.2012.03.26.05.51.25 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Mar 2012 05:51:26 -0700 (PDT) From: Daniel Lezcano To: lenb@kernel.org Cc: linaro-dev@lists.linaro.org, patches@linaro.org, linux-pm@lists.linux-foundation.org Subject: [PATCH 1/3] cpuidle: use the driver's state_count as default Date: Mon, 26 Mar 2012 14:51:26 +0200 Message-Id: <1332766288-30412-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.5.4 X-Gm-Message-State: ALoCoQlXXdCrnwof/FExE0urb11e85tQMRQkuWyc4h29HEZ+ZSX7K72Wn4klkc0EEPgmcIaOZ/kN If the state_count is not initialized for the device use the driver's state count as the default. That will prevent to add it manually in the cpuidle driver initialization routine and will save us from duplicate line of code. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 2 +- drivers/cpuidle/driver.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 27f77a4..b8a1faf 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -268,7 +268,7 @@ int cpuidle_enable_device(struct cpuidle_device *dev) if (!drv || !cpuidle_curr_governor) return -EIO; if (!dev->state_count) - return -EINVAL; + dev->state_count = drv->state_count; if (dev->registered == 0) { ret = __cpuidle_register_device(dev); diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 284d7af..40cd3f3 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c @@ -47,7 +47,7 @@ static void __cpuidle_register_driver(struct cpuidle_driver *drv) */ int cpuidle_register_driver(struct cpuidle_driver *drv) { - if (!drv) + if (!drv || !drv->state_count) return -EINVAL; if (cpuidle_disabled())