From patchwork Wed Aug 21 14:42:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 19377 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 65A86248E6 for ; Wed, 21 Aug 2013 14:42:49 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id m1sf497009ves.2 for ; Wed, 21 Aug 2013 07:42:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=FxpMaDoCnsKz9FpncDb+t8Xb15/8HUEdvSvpcCdy1Vk=; b=eda3BTr8EU+tzPBB4MbmYtQNjP+lD2j1eM4D+2x+34Hn3NrU+Y5Xj21+l103AtxZs5 sGXV3DAawLHAJZ2oAk2QiuN1zhV42Jr5FiAUVOzPC16OLLnaIVGBGdPlbrRN2nEoYp7V o/qzs16ettW3BS1THYdR8ZOwnXxm/Q73ccm8kNbdfw9W/CZCXor7RWFTVJSPLj9hlMBR 41HFqFq+hDjbuoALwdx9yoLfwZKLUTThm5/kfSJ0fkL7WJmM8p8p/b7faUCD0bdZrDLb W343aGikFh5rybjP5358HELJOipxVcWYGdPxXSYjLvbZ3bXjPq9nFlvcjPOXqV+o/VF2 QgOw== X-Received: by 10.58.46.172 with SMTP id w12mr685518vem.16.1377096169226; Wed, 21 Aug 2013 07:42:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.85.4 with SMTP id d4ls606295qez.76.gmail; Wed, 21 Aug 2013 07:42:49 -0700 (PDT) X-Received: by 10.52.165.239 with SMTP id zb15mr169218vdb.44.1377096169104; Wed, 21 Aug 2013 07:42:49 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id aa5si2227027vdc.0.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Aug 2013 07:42:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id c13so406943vea.38 for ; Wed, 21 Aug 2013 07:42:49 -0700 (PDT) X-Gm-Message-State: ALoCoQl5j7LqQrofkAGwKu9o72cGNha2aeMxilZRmG709j0JEuImYR2N2sHzxuIAIKKwEL4EcyLR X-Received: by 10.59.8.232 with SMTP id dn8mr6763586ved.8.1377096168995; Wed, 21 Aug 2013 07:42:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp224518vcz; Wed, 21 Aug 2013 07:42:48 -0700 (PDT) X-Received: by 10.68.178.133 with SMTP id cy5mr80895pbc.110.1377096167899; Wed, 21 Aug 2013 07:42:47 -0700 (PDT) Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by mx.google.com with ESMTPS id iy4si5416078pbb.125.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Aug 2013 07:42:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.181 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.181; Received: by mail-pd0-f181.google.com with SMTP id g10so498565pdj.40 for ; Wed, 21 Aug 2013 07:42:47 -0700 (PDT) X-Received: by 10.68.189.228 with SMTP id gl4mr8082063pbc.57.1377096167470; Wed, 21 Aug 2013 07:42:47 -0700 (PDT) Received: from localhost ([122.172.193.46]) by mx.google.com with ESMTPSA id fk4sm10580116pab.23.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 21 Aug 2013 07:42:46 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 01/14] cpufreq: create cpufreq_generic_init() routine Date: Wed, 21 Aug 2013 20:12:20 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Many CPUFreq drivers for SMP system (where all cores share same clock lines), do similar stuff in their ->init() part. This patch creates a generic routine in cpufreq core which can be used by these so that we can remove some redundant code. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 31 +++++++++++++++++++++++++++++++ include/linux/cpufreq.h | 3 +++ 2 files changed, 34 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 556a8c5..5fc9c6b 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -188,6 +188,37 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) } EXPORT_SYMBOL_GPL(get_cpu_idle_time); +/* + * This is a generic cpufreq init() routine which can be used by cpufreq + * drivers of SMP systems. It will do following: + * - validate & show freq table passed + * - set policies transition latency + * - policy->cpus with all possible CPUs + */ +int cpufreq_generic_init(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *table, + unsigned int transition_latency) +{ + int ret; + + ret = cpufreq_table_validate_and_show(policy, table); + if (ret) { + pr_err("%s: invalid frequency table: %d\n", __func__, ret); + return ret; + } + + policy->cpuinfo.transition_latency = transition_latency; + + /* + * The driver only supports the SMP configuartion where all processors + * share the clock and voltage and clock. + */ + cpumask_setall(policy->cpus); + + return 0; +} +EXPORT_SYMBOL_GPL(cpufreq_generic_init); + struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) { struct cpufreq_policy *policy = NULL; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index b4ad9b5..6adea26 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -424,6 +424,9 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu); int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table); +int cpufreq_generic_init(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *table, + unsigned int transition_latency); static inline int cpufreq_generic_exit(struct cpufreq_policy *policy) { cpufreq_frequency_table_put_attr(policy->cpu);