From patchwork Sat Aug 10 06:44:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 2842361 X-Patchwork-Delegate: lethal@linux-sh.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C1C2F9F271 for ; Sat, 10 Aug 2013 06:59:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB8902029B for ; Sat, 10 Aug 2013 06:59:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A05D620279 for ; Sat, 10 Aug 2013 06:59:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758659Ab3HJGsw (ORCPT ); Sat, 10 Aug 2013 02:48:52 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:59110 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758515Ab3HJGss (ORCPT ); Sat, 10 Aug 2013 02:48:48 -0400 Received: by mail-pd0-f174.google.com with SMTP id y13so1386669pdi.5 for ; Fri, 09 Aug 2013 23:48:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=RlO6Vd/yP6da0kZd99INlfAPct2Akb6UCXxadDfLA7I=; b=UgB+JDNha1cOHV5uU6nCMCbPk0Ln5vnTbI+aMEYvb3nzrMrC4MBgqg6eezV9b9mWtB pewnqQv2He/SnNQVJjhwEdpUV4HG9E9FUfL8lOcNh8pSPLycOiNCQXAv6s5V8GGCAuCP 9Eex7X/OYOc+kGUmjb9bE6DrqLyU4TySOED1cxicNMDztOvmLPhCLVpe7LyQyGi8M6US qBxPmd1QFXfmICW+5S96BY6bTyTPYxM1NNVvsARdx04X2HCuHxWQZF8ilNoE8M3cg426 JCkEcB15aSpQ0MJMUXz33yhpfok6aP33Hvem17k6r1NRy3KwEqyCdBpjXhlvvrF4apH4 /pSg== X-Gm-Message-State: ALoCoQk24GCJ9IH9O5dhCul+UmFYszmBKZq8ztIoBVay6C1V9XzSlDyX/zvKlTCQM6jYFljI6H1r X-Received: by 10.66.231.3 with SMTP id tc3mr15081575pac.167.1376117327166; Fri, 09 Aug 2013 23:48:47 -0700 (PDT) Received: from localhost ([122.172.193.46]) by mx.google.com with ESMTPSA id om2sm24133007pbb.34.2013.08.09.23.48.38 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 09 Aug 2013 23:48: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 , Andrew Lunn , "David S. Miller" , Dmitry Eremin-Solenikov , Eric Miao , Guan Xuetao , Hans-Christian Egtvedt , Jesper Nilsson , John Crispin , Kukjin Kim , Linus Walleij , linux-cris-kernel@axis.com, linux-sh@vger.kernel.org, Mikael Starvik , Paul Mundt , Santosh Shilimkar , Sekhar Nori , Shawn Guo , sparclinux@vger.kernel.org, spear-devel@list.st.com, Stephen Warren , Steven Miao , Tony Luck Subject: [PATCH 08/44] cpufreq: define generic .attr, .exit() and .verify() routines Date: Sat, 10 Aug 2013 12:14:04 +0530 Message-Id: <180b46ed83c4e51375c5c011110ce4f1bf9c963d.1376116345.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: Andrew Lunn Cc: David S. Miller Cc: Dmitry Eremin-Solenikov Cc: Eric Miao Cc: Guan Xuetao Cc: Hans-Christian Egtvedt Cc: Jesper Nilsson Cc: John Crispin Cc: Kukjin Kim Cc: Linus Walleij Cc: linux-cris-kernel@axis.com Cc: linux-sh@vger.kernel.org Cc: Mikael Starvik Cc: Paul Mundt Cc: Santosh Shilimkar Cc: Sekhar Nori Cc: Shawn Guo Cc: sparclinux@vger.kernel.org Cc: spear-devel@list.st.com Cc: Stephen Warren Cc: Steven Miao Cc: Tony Luck 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 11f6fa9..b198458 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -87,6 +87,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, @@ -200,6 +214,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 c0297a6..4907eb2 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -393,6 +393,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, @@ -408,10 +409,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 */