From patchwork Thu Oct 15 16:05:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 55046 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f70.google.com (mail-lf0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 713AA22FFA for ; Thu, 15 Oct 2015 16:05:59 +0000 (UTC) Received: by lfbe131 with SMTP id e131sf4752345lfb.3 for ; Thu, 15 Oct 2015 09:05:58 -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=8Cl3cPMe0bjQ2Zy0C5IOWVLB5t7rjTxG8IrAESnS+Fg=; b=lwhowAKDcS/6+20ZP0DmdcOd8C0Up+ZZbhLFeECApAfwtidaH/lsTlzNzX9zfqk+/6 RxWRO8b4E1OgDKS8bXYrsfa1R2Xsa6zuw3xIDDBc1xEuJIrZ1b5zU7AW+dLDjsK4mhg+ lGrdvxCyTsd72yE5zdc0tanSKX4rHuVf4DLTOcCqTEN6Y/6sNRJqs8Rb2AoLtQOP1Km2 82NHuH3Dg0utE1s5sS/oeYARp+yEs+PJoz2twTEdD3uMF50k5E04mEBSuSv5ZkGkxoJZ DqdgBDwh9UUgaRhElfXYibGtobm7cJz2tcp+rFuaQTlg+jVSih2clr6vAey+gsQcFzHT RyyQ== X-Gm-Message-State: ALoCoQkBO1qBohYbuUNYILRlzT0zn+M03xTUSeUCRC5ezpnCUeDN0xJwZgO8PfSWHaXyWOtAjIMT X-Received: by 10.112.136.99 with SMTP id pz3mr2410366lbb.11.1444925158372; Thu, 15 Oct 2015 09:05:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.20.202 with SMTP id 71ls150203lfu.95.gmail; Thu, 15 Oct 2015 09:05:57 -0700 (PDT) X-Received: by 10.112.55.99 with SMTP id r3mr5065524lbp.64.1444925157966; Thu, 15 Oct 2015 09:05:57 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id rb7si9599618lbb.4.2015.10.15.09.05.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Oct 2015 09:05:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbwr8 with SMTP id r8so74461429lbw.2 for ; Thu, 15 Oct 2015 09:05:57 -0700 (PDT) X-Received: by 10.112.163.131 with SMTP id yi3mr5045585lbb.36.1444925157628; Thu, 15 Oct 2015 09:05:57 -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 w3csp722076lbq; Thu, 15 Oct 2015 09:05:56 -0700 (PDT) X-Received: by 10.68.239.165 with SMTP id vt5mr10799155pbc.15.1444925156499; Thu, 15 Oct 2015 09:05:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rf6si22508296pab.241.2015.10.15.09.05.56; Thu, 15 Oct 2015 09:05:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 S1753643AbbJOQFy (ORCPT + 30 others); Thu, 15 Oct 2015 12:05:54 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:33958 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752347AbbJOQFw (ORCPT ); Thu, 15 Oct 2015 12:05:52 -0400 Received: by payp3 with SMTP id p3so43956522pay.1 for ; Thu, 15 Oct 2015 09:05:52 -0700 (PDT) X-Received: by 10.66.163.136 with SMTP id yi8mr10809775pab.124.1444925152072; Thu, 15 Oct 2015 09:05:52 -0700 (PDT) Received: from localhost ([223.227.130.246]) by smtp.gmail.com with ESMTPSA id pc8sm16219908pbc.27.2015.10.15.09.05.48 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 15 Oct 2015 09:05:51 -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 V2 2/5] cpufreq: create cpu/cpufreq at boot time Date: Thu, 15 Oct 2015 21:35:22 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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.177 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. Reviewed-by: Saravana Kannan 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 16b9e811ff01..c1fd57db50bd 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -876,43 +876,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); @@ -2582,7 +2554,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);