From patchwork Fri Sep 13 13:00:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20109 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 76EDB202E6 for ; Fri, 13 Sep 2013 13:09:34 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id gf11sf1193066vcb.2 for ; Fri, 13 Sep 2013 06:09:34 -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 :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=zb1I0eU09QSo3TAF9jDcAAegjf9/0fUDp9EHYsHr0sA=; b=mQphT6WkJT5FuEug/1l4Sv86a/v98XSZJ3HlkEtUMUFFEZTvb0F1woUPJ/Kbz4ZjRG yXikQ6coj5r6zKJi9A1kUTBb+lKyAHewpHt+DsewC6f6vRCdiE6RhhXmv/k4IRY3wdHn eLdkVFP+uBNJDoNQWBaeCvJmCKhv607HWuSYpsQdfWXG3FdHv0JyHrwnirrusZkUjzCk Z9NIZ1gzNrNb9cYW4KVgRY7h/fI9+Hhd6WvOUiP1py5f3UN3RIxVLjICUhjWZ7931Mrx nRkzJXxOBTxgSHvzuxPYGGO5lYl/jwfy2xRFCWK7pa/wzSnNq+MBLbxjPq+q9rTP7aX6 3nsQ== X-Gm-Message-State: ALoCoQl0ij46i4P9RXcmgcnanB67IBVce8YfuvEWJQ8nrC819pvx2/NGD7VsbDv0n7mDPS3cYYJS X-Received: by 10.236.41.100 with SMTP id g64mr5101065yhb.31.1379077774226; Fri, 13 Sep 2013 06:09:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.233 with SMTP id x9ls1167893qef.46.gmail; Fri, 13 Sep 2013 06:09:34 -0700 (PDT) X-Received: by 10.52.165.131 with SMTP id yy3mr5954731vdb.25.1379077773994; Fri, 13 Sep 2013 06:09:33 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id lu1si3096619vcb.88.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:09:33 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id hz10so912477vcb.12 for ; Fri, 13 Sep 2013 06:09:33 -0700 (PDT) X-Received: by 10.220.74.69 with SMTP id t5mr12011587vcj.18.1379077773897; Fri, 13 Sep 2013 06:09:33 -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 u4csp79776vcz; Fri, 13 Sep 2013 06:09:33 -0700 (PDT) X-Received: by 10.68.218.163 with SMTP id ph3mr13388779pbc.19.1379077772871; Fri, 13 Sep 2013 06:09:32 -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 qc9si11223835pac.37.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:09:32 -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 g10so1225228pdj.26 for ; Fri, 13 Sep 2013 06:09:32 -0700 (PDT) X-Received: by 10.66.221.8 with SMTP id qa8mr1567165pac.188.1379077772335; Fri, 13 Sep 2013 06:09:32 -0700 (PDT) Received: from localhost ([122.167.78.148]) by mx.google.com with ESMTPSA id tz3sm11676814pbc.20.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:09:31 -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, linux-arm-kernel@lists.infradead.org, Viresh Kumar Subject: [PATCH 055/228] cpufreq: define generic .attr, .exit() and .verify() routines Date: Fri, 13 Sep 2013 18:30:01 +0530 Message-Id: <95b345e71483780f63bd3e77a255769178bae2ec.1379063063.git.viresh.kumar@linaro.org> 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.220.181 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: , Most of the CPUFreq drivers do similar things in .exit() and .verify() routines and .attr. So its better if we have generic routines for them which can be used by cpufreq drivers then. This patch introduces generic .attr, .exit() and .verify() cpufreq drivers. Signed-off-by: Viresh Kumar --- drivers/cpufreq/freq_table.c | 20 ++++++++++++++++++++ include/linux/cpufreq.h | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index b9336ed..3458d27 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -86,6 +86,20 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, } EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify); +/* + * Generic routine to verify policy & frequency table, requires driver to call + * cpufreq_frequency_table_get_attr() prior to it. + */ +int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy) +{ + struct cpufreq_frequency_table *table = + cpufreq_frequency_get_table(policy->cpu); + if (!table) + return -ENODEV; + + return cpufreq_frequency_table_verify(policy, table); +} +EXPORT_SYMBOL_GPL(cpufreq_generic_frequency_table_verify); int cpufreq_frequency_table_target(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table, @@ -199,6 +213,12 @@ struct freq_attr cpufreq_freq_attr_scaling_available_freqs = { }; EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs); +struct freq_attr *cpufreq_generic_attr[] = { + &cpufreq_freq_attr_scaling_available_freqs, + NULL, +}; +EXPORT_SYMBOL_GPL(cpufreq_generic_attr); + /* * if you use these, you must assure that the frequency table is valid * all the time between get_attr and put_attr! diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index e257407..57d2907 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -415,6 +415,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table); +int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy); int cpufreq_frequency_table_target(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table, @@ -430,10 +431,17 @@ struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu); /* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; +extern struct freq_attr *cpufreq_generic_attr[]; void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, unsigned int cpu); void cpufreq_frequency_table_put_attr(unsigned int cpu); int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table); +static inline int cpufreq_generic_exit(struct cpufreq_policy *policy) +{ + cpufreq_frequency_table_put_attr(policy->cpu); + return 0; +} + #endif /* _LINUX_CPUFREQ_H */