From patchwork Sun Oct 11 17:21:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 54741 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 2453D2304F for ; Sun, 11 Oct 2015 17:21:42 +0000 (UTC) Received: by wibzt1 with SMTP id zt1sf5589235wib.0 for ; Sun, 11 Oct 2015 10:21:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=eNO3Is+LxoF0ib9DL4NvTBhhpY7iKiEDyl9+tCuxrg8=; b=iobh2fQjb9qi/LSCnTlU77j7nv9MR0ghdoJnG1E8VHqLEKQVb7XnuUyI+9Z/jadkAY xYEc7y7m2mMktLjkQrq65OM/ovk+JRyz8u+Tof8qfdMJtqv0Dk2f79eqrSTRsiyBbdAS OljtQ+2G+Pyk8XHEaUSPv9XVUHu2BbeSQb5FP4Wr7DeMJM47XSeJTvnr34E8SRCQ1Fex wy3PrixEgZOqmHQ0GnRNALm8n5ZKhMK1CdWx2zh4imH2kTFqavtRpk4X8HKyTMqorEN5 eHw7QmIsONnQSncbrZfV+V+Gw2EN4HpbVma4OLPq1niCU62dXvYaL+ihIJi6/kbMqJf0 RzjA== X-Gm-Message-State: ALoCoQk4GcEX1XpY4LIe1YGvbdXTjCzr2sDzt6f56VgZcKcrAhpS9V3ee7EN+vszGt9CKFM5MFFP X-Received: by 10.180.106.197 with SMTP id gw5mr1926055wib.7.1444584101472; Sun, 11 Oct 2015 10:21:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.141.74 with SMTP id p71ls452500lfd.77.gmail; Sun, 11 Oct 2015 10:21:41 -0700 (PDT) X-Received: by 10.25.43.80 with SMTP id r77mr5742036lfr.120.1444584101321; Sun, 11 Oct 2015 10:21:41 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id s71si8390763lfd.169.2015.10.11.10.21.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Oct 2015 10:21:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbk10 with SMTP id k10so11211915lbb.0 for ; Sun, 11 Oct 2015 10:21:41 -0700 (PDT) X-Received: by 10.25.211.201 with SMTP id k192mr7167147lfg.32.1444584101004; Sun, 11 Oct 2015 10:21:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1143975lbq; Sun, 11 Oct 2015 10:21:40 -0700 (PDT) X-Received: by 10.66.254.101 with SMTP id ah5mr29427095pad.10.1444584099952; Sun, 11 Oct 2015 10:21:39 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tl10si19574981pbc.253.2015.10.11.10.21.39; Sun, 11 Oct 2015 10:21:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752135AbbJKRVf (ORCPT + 12 others); Sun, 11 Oct 2015 13:21:35 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:32977 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751839AbbJKRVd (ORCPT ); Sun, 11 Oct 2015 13:21:33 -0400 Received: by pacex6 with SMTP id ex6so4411054pac.0 for ; Sun, 11 Oct 2015 10:21:33 -0700 (PDT) X-Received: by 10.68.243.99 with SMTP id wx3mr29266365pbc.33.1444584092936; Sun, 11 Oct 2015 10:21:32 -0700 (PDT) Received: from localhost ([120.59.64.42]) by smtp.gmail.com with ESMTPSA id of1sm13705966pbc.11.2015.10.11.10.21.31 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 11 Oct 2015 10:21:32 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, skannan@codeaurora.org, Viresh Kumar , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/5] cpufreq: create cpu/cpufreq at boot time Date: Sun, 11 Oct 2015 22:51:11 +0530 Message-Id: <6085eff28ecfa9af572739844cce24e4e7f190a2.1444583718.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Later patches will need to create policy specific directories in /sys/devices/system/cpu/cpufreq/ directory and so the cpufreq directory wouldn't be ever empty. And so no fun creating/destroying it on need basis anymore. Create it once on system boot. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 32 ++------------------------------ drivers/cpufreq/cpufreq_governor.c | 20 +++++--------------- include/linux/cpufreq.h | 2 -- 3 files changed, 7 insertions(+), 47 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b32521432db4..db688d18a189 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -883,43 +883,15 @@ static struct kobj_type ktype_cpufreq = { struct kobject *cpufreq_global_kobject; EXPORT_SYMBOL(cpufreq_global_kobject); -static int cpufreq_global_kobject_usage; - -int cpufreq_get_global_kobject(void) -{ - if (!cpufreq_global_kobject_usage++) - return kobject_add(cpufreq_global_kobject, - &cpu_subsys.dev_root->kobj, "%s", "cpufreq"); - - return 0; -} -EXPORT_SYMBOL(cpufreq_get_global_kobject); - -void cpufreq_put_global_kobject(void) -{ - if (!--cpufreq_global_kobject_usage) - kobject_del(cpufreq_global_kobject); -} -EXPORT_SYMBOL(cpufreq_put_global_kobject); - int cpufreq_sysfs_create_file(const struct attribute *attr) { - int ret = cpufreq_get_global_kobject(); - - if (!ret) { - ret = sysfs_create_file(cpufreq_global_kobject, attr); - if (ret) - cpufreq_put_global_kobject(); - } - - return ret; + return sysfs_create_file(cpufreq_global_kobject, attr); } EXPORT_SYMBOL(cpufreq_sysfs_create_file); void cpufreq_sysfs_remove_file(const struct attribute *attr) { sysfs_remove_file(cpufreq_global_kobject, attr); - cpufreq_put_global_kobject(); } EXPORT_SYMBOL(cpufreq_sysfs_remove_file); @@ -2589,7 +2561,7 @@ static int __init cpufreq_core_init(void) if (cpufreq_disabled()) return -ENODEV; - cpufreq_global_kobject = kobject_create(); + cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj); BUG_ON(!cpufreq_global_kobject); register_syscore_ops(&cpufreq_syscore_ops); diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 750626d8fb03..11258c4c1b17 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -348,29 +348,21 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy, set_sampling_rate(dbs_data, max(dbs_data->min_sampling_rate, latency * LATENCY_MULTIPLIER)); - if (!have_governor_per_policy()) { - if (WARN_ON(cpufreq_get_global_kobject())) { - ret = -EINVAL; - goto cdata_exit; - } + if (!have_governor_per_policy()) cdata->gdbs_data = dbs_data; - } ret = sysfs_create_group(get_governor_parent_kobj(policy), get_sysfs_attr(dbs_data)); if (ret) - goto put_kobj; + goto reset_gdbs_data; policy->governor_data = dbs_data; return 0; -put_kobj: - if (!have_governor_per_policy()) { +reset_gdbs_data: + if (!have_governor_per_policy()) cdata->gdbs_data = NULL; - cpufreq_put_global_kobject(); - } -cdata_exit: cdata->exit(dbs_data, !policy->governor->initialized); free_common_dbs_info: free_common_dbs_info(policy, cdata); @@ -394,10 +386,8 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy, sysfs_remove_group(get_governor_parent_kobj(policy), get_sysfs_attr(dbs_data)); - if (!have_governor_per_policy()) { + if (!have_governor_per_policy()) cdata->gdbs_data = NULL; - cpufreq_put_global_kobject(); - } cdata->exit(dbs_data, policy->governor->initialized == 1); kfree(dbs_data); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index dca22de98d94..338bf0e59bb8 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -149,8 +149,6 @@ static inline bool policy_is_shared(struct cpufreq_policy *policy) /* /sys/devices/system/cpu/cpufreq: entry point for global variables */ extern struct kobject *cpufreq_global_kobject; -int cpufreq_get_global_kobject(void); -void cpufreq_put_global_kobject(void); int cpufreq_sysfs_create_file(const struct attribute *attr); void cpufreq_sysfs_remove_file(const struct attribute *attr);