From patchwork Wed Oct 10 22:21:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12158 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 8F10223EFB for ; Wed, 10 Oct 2012 22:21:42 +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 3B196A18451 for ; Wed, 10 Oct 2012 22:21:42 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so1864232iej.11 for ; Wed, 10 Oct 2012 15:21:42 -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=HkUSpOUIW1ntb6CkCIpKe3hSdHBgYKSBLCtBoLFpy04=; b=Bx2Sk4vqxftipSJYzQnymOVXJ3fYY92UuILAi7ADl01dpDDg2CEr2j5dqOX8pgmuqa Z5edYXl26X2FPydsQvOMPtQjf0DLV6MRjF8TP2DVLVfJjOvmH6/ahV8KUibts9VAAiZj oE3b2MXm0krWmP3JQclA/1ROXALglt2eAr2VxK/YXZ0HaiCOXT1FLklR1gHtuk6vJA6i fafpyYfT8fKduxvcwotOCp+KOMI/qcJqdB8goRDmVT3YqPEkCNsK4l34rbdupEmcOjaB a4ymkcV79/ULl3re9yNIt808BRhVLO2ZlpjvOzsM4V88iaW/41xaH/EvRAtFspiI18tc UeRg== Received: by 10.50.236.72 with SMTP id us8mr6752079igc.70.1349907702037; Wed, 10 Oct 2012 15:21:42 -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 n20csp302324igt; Wed, 10 Oct 2012 15:21:41 -0700 (PDT) Received: by 10.180.83.101 with SMTP id p5mr16063966wiy.2.1349907700448; Wed, 10 Oct 2012 15:21:40 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id g6si32259618wie.42.2012.10.10.15.21.39 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 10 Oct 2012 15:21:40 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 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-wg0-f50.google.com with SMTP id 16so829815wgi.31 for ; Wed, 10 Oct 2012 15:21:39 -0700 (PDT) Received: by 10.180.87.34 with SMTP id u2mr16045901wiz.3.1349907699844; Wed, 10 Oct 2012 15:21:39 -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.36 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 10 Oct 2012 15:21:39 -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 2/4] cpuidle - sysfs : move kobj initialization in the syfs file Date: Thu, 11 Oct 2012 00:21:29 +0200 Message-Id: <1349907691-6002-3-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: ALoCoQlzQmEE3pJDm3A6V9g3CW59W6cm98xedsNa+27ys32KW1jie42uM947O0nuKe2a2xJGnaGL Move the kobj initialization and completion in the sysfs.c and encapsulate the code more. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 4 ---- drivers/cpuidle/sysfs.c | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 07c6637..7cf8388 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -399,8 +399,6 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) if (!try_module_get(cpuidle_driver->owner)) return -EINVAL; - init_completion(&dev->kobj_unregister); - per_cpu(cpuidle_devices, dev->cpu) = dev; list_add(&dev->device_list, &cpuidle_detected_devices); ret = cpuidle_add_sysfs(dev); @@ -416,7 +414,6 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) err_coupled: cpuidle_remove_sysfs(dev); - wait_for_completion(&dev->kobj_unregister); err_sysfs: list_del(&dev->device_list); per_cpu(cpuidle_devices, dev->cpu) = NULL; @@ -470,7 +467,6 @@ void cpuidle_unregister_device(struct cpuidle_device *dev) cpuidle_remove_sysfs(dev); list_del(&dev->device_list); - wait_for_completion(&dev->kobj_unregister); per_cpu(cpuidle_devices, dev->cpu) = NULL; cpuidle_coupled_unregister_device(dev); diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 84e6285..ed87399 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -374,8 +374,8 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device) kobj->state_usage = &device->states_usage[i]; init_completion(&kobj->kobj_unregister); - ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj, - "state%d", i); + ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, + &device->kobj, "state%d", i); if (ret) { kfree(kobj); goto error_state; @@ -413,6 +413,8 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev) struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); int error; + init_completion(&dev->kobj_unregister); + error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &cpu_dev->kobj, "cpuidle"); if (!error) @@ -427,4 +429,5 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev) void cpuidle_remove_sysfs(struct cpuidle_device *dev) { kobject_put(&dev->kobj); + wait_for_completion(&dev->kobj_unregister); }