From patchwork Wed Oct 10 22:21:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12157 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 7C07023EFB for ; Wed, 10 Oct 2012 22:21:39 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 15D24A18451 for ; Wed, 10 Oct 2012 22:21:38 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so1864249iej.11 for ; Wed, 10 Oct 2012 15:21:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=e/ZOppkwcuCOXcINMSVfi5aZUkW4hN+jHKgaC3fLt9g=; b=oQF9ISXtWCYF0p/9u+TwLuzFR1YJ4WIK5NQjs234keOCHKMt6f/QfDoY0sREiNlj1Z ytj1o5G5P1box6qicFRZK+k/06ryNRLr1ATgqSF4bvIxXTk/Ftvr1hcJ511lm3659uv+ LNzkeXfnavrb93YlnIF/LYB+xkwXv8TOd+4wac/xkEj+lIJjmj5vevX02UrQxwzLSlCb BIo6u4qZgXPvknf2rvRf4qOZ2WNscsH6yDBbPYdSKQhmrUGnITCArm8/g6r8zELCTu4+ Exyr+0C0+Rn4zeP5Nmw59TH24XYRfMy1VD9RqAUiknGbZ/2PW7xPZC0olMXcuL8+Pifl 88tA== Received: by 10.50.46.226 with SMTP id y2mr6719398igm.62.1349907698461; Wed, 10 Oct 2012 15:21:38 -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.50.67.148 with SMTP id n20csp302315igt; Wed, 10 Oct 2012 15:21:37 -0700 (PDT) Received: by 10.180.99.133 with SMTP id eq5mr15968249wib.21.1349907696847; Wed, 10 Oct 2012 15:21:36 -0700 (PDT) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by mx.google.com with ESMTPS id c28si3156219wej.7.2012.10.10.15.21.36 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 10 Oct 2012 15:21:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.170 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=209.85.212.170; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.170 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: by mail-wi0-f170.google.com with SMTP id hm2so6479341wib.1 for ; Wed, 10 Oct 2012 15:21:36 -0700 (PDT) Received: by 10.180.91.71 with SMTP id cc7mr16059879wib.2.1349907696242; Wed, 10 Oct 2012 15:21:36 -0700 (PDT) Received: from localhost.localdomain (AToulouse-651-1-105-241.w109-222.abo.wanadoo.fr. [109.222.192.241]) by mx.google.com with ESMTPS id cu1sm32250748wib.6.2012.10.10.15.21.34 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 10 Oct 2012 15:21:35 -0700 (PDT) From: Daniel Lezcano To: rjw@sisk.pl Cc: linux-pm@vger.kernel.org, linaro-dev@lists.linaro.org, patches@linaro.org Subject: [PATCH 1/4] cpuidle - sysfs : change function parameter Date: Thu, 11 Oct 2012 00:21:28 +0200 Message-Id: <1349907691-6002-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1349907691-6002-1-git-send-email-daniel.lezcano@linaro.org> References: <1349907691-6002-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQlKA1OTZIZXIceqS3UwWqHTMMq/XVHrQn24UMC0SKPLWZfNtNeyO2ErN6P7BLQQ5lhraVPb The function needs the cpuidle_device which is initially passed to the caller. The current code gets the struct device from the struct cpuidle_device, pass it the cpuidle_add_sysfs function. This function calls per_cpu(cpuidle_devices, cpu) to get the cpuidle_device. This patch pass the cpuidle_device instead and simplify the code. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 8 +++----- drivers/cpuidle/cpuidle.h | 6 ++---- drivers/cpuidle/sysfs.c | 12 +++--------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index e28f6ea..07c6637 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -394,7 +394,6 @@ EXPORT_SYMBOL_GPL(cpuidle_disable_device); static int __cpuidle_register_device(struct cpuidle_device *dev) { int ret; - struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); if (!try_module_get(cpuidle_driver->owner)) @@ -404,7 +403,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) per_cpu(cpuidle_devices, dev->cpu) = dev; list_add(&dev->device_list, &cpuidle_detected_devices); - ret = cpuidle_add_sysfs(cpu_dev); + ret = cpuidle_add_sysfs(dev); if (ret) goto err_sysfs; @@ -416,7 +415,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) return 0; err_coupled: - cpuidle_remove_sysfs(cpu_dev); + cpuidle_remove_sysfs(dev); wait_for_completion(&dev->kobj_unregister); err_sysfs: list_del(&dev->device_list); @@ -460,7 +459,6 @@ EXPORT_SYMBOL_GPL(cpuidle_register_device); */ void cpuidle_unregister_device(struct cpuidle_device *dev) { - struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); if (dev->registered == 0) @@ -470,7 +468,7 @@ void cpuidle_unregister_device(struct cpuidle_device *dev) cpuidle_disable_device(dev); - cpuidle_remove_sysfs(cpu_dev); + cpuidle_remove_sysfs(dev); list_del(&dev->device_list); wait_for_completion(&dev->kobj_unregister); per_cpu(cpuidle_devices, dev->cpu) = NULL; diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h index 76e7f69..a5bbd1c 100644 --- a/drivers/cpuidle/cpuidle.h +++ b/drivers/cpuidle/cpuidle.h @@ -5,8 +5,6 @@ #ifndef __DRIVER_CPUIDLE_H #define __DRIVER_CPUIDLE_H -#include - /* For internal use only */ extern struct cpuidle_governor *cpuidle_curr_governor; extern struct list_head cpuidle_governors; @@ -29,8 +27,8 @@ extern int cpuidle_add_interface(struct device *dev); extern void cpuidle_remove_interface(struct device *dev); extern int cpuidle_add_state_sysfs(struct cpuidle_device *device); extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device); -extern int cpuidle_add_sysfs(struct device *dev); -extern void cpuidle_remove_sysfs(struct device *dev); +extern int cpuidle_add_sysfs(struct cpuidle_device *dev); +extern void cpuidle_remove_sysfs(struct cpuidle_device *dev); #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED bool cpuidle_state_is_coupled(struct cpuidle_device *dev, diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 5f809e3..84e6285 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -408,13 +408,11 @@ void cpuidle_remove_state_sysfs(struct cpuidle_device *device) * cpuidle_add_sysfs - creates a sysfs instance for the target device * @dev: the target device */ -int cpuidle_add_sysfs(struct device *cpu_dev) +int cpuidle_add_sysfs(struct cpuidle_device *dev) { - int cpu = cpu_dev->id; - struct cpuidle_device *dev; + struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); int error; - dev = per_cpu(cpuidle_devices, cpu); error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &cpu_dev->kobj, "cpuidle"); if (!error) @@ -426,11 +424,7 @@ int cpuidle_add_sysfs(struct device *cpu_dev) * cpuidle_remove_sysfs - deletes a sysfs instance on the target device * @dev: the target device */ -void cpuidle_remove_sysfs(struct device *cpu_dev) +void cpuidle_remove_sysfs(struct cpuidle_device *dev) { - int cpu = cpu_dev->id; - struct cpuidle_device *dev; - - dev = per_cpu(cpuidle_devices, cpu); kobject_put(&dev->kobj); }