From patchwork Thu Aug 8 13:48:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 2841105 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6674EBF546 for ; Thu, 8 Aug 2013 13:49:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4163E2024A for ; Thu, 8 Aug 2013 13:49:49 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF346200DE for ; Thu, 8 Aug 2013 13:49:47 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7Qav-0002QQ-1x; Thu, 08 Aug 2013 13:49:37 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7Qap-00046v-U2; Thu, 08 Aug 2013 13:49:31 +0000 Received: from mail-pa0-f48.google.com ([209.85.220.48]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7Qai-00044T-PV for linux-arm-kernel@lists.infradead.org; Thu, 08 Aug 2013 13:49:27 +0000 Received: by mail-pa0-f48.google.com with SMTP id kp13so3447825pab.7 for ; Thu, 08 Aug 2013 06:49:00 -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=4Fv8H4WJvIIF5+5A2BKsnr/5aGPr7qngFtuNz2aahtI=; b=Yu1ciHnQxHlXzuoijFdF5HCU4Dof9OHBDfO2AQ7sxFg6JGGCfAVcAQiuDJjTH+OF2L /kvzXYYW64CIZI+VhRknAu/GHu2Mu731rQ8RQcsSq4PojkRxM3j1j9GoBLa7ud4XFW+T 1MPhAkKan5YkoqSuwIjdSCBx4xkUF8WzODaX306+aLs3i6GU7t3ECYUf+m1DQl6KZ94O V6IAgh+MAKgNm5u/rzHk+bgkrXpizeIjIipOclhzpiSJ+BhBHNB/eQ9nkXVG1dvncqPz c+6EAJOOzYGevJahULicnT77I91AeNvGfOOW78pM14tMoDFW2qpqLl8cm3Dt4HQBMkvI 0YvQ== X-Gm-Message-State: ALoCoQn5QtoD3+hwRQLTea7t3zLOCDFbT6/C0k6bl/alzc/xFoBtmNS83AapumMdNsPe5a5/Pr1o X-Received: by 10.66.163.199 with SMTP id yk7mr6174097pab.136.1375969740555; Thu, 08 Aug 2013 06:49:00 -0700 (PDT) Received: from localhost ([122.172.193.46]) by mx.google.com with ESMTPSA id ts6sm14400575pbc.12.2013.08.08.06.48.56 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 08 Aug 2013 06:48:59 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Subject: [PATCH 01/35] cpufreq: Add new helper cpufreq_table_validate_and_show() Date: Thu, 8 Aug 2013 19:18:03 +0530 Message-Id: <8adda0413f007dd3d4ab6dac934c074c205ada8d.1375964117.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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130808_094924_968255_A136CC61 X-CRM114-Status: GOOD ( 10.86 ) X-Spam-Score: -2.6 (--) Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Viresh Kumar , patches@linaro.org, linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Almost every cpufreq driver is required to validate its frequency table with: cpufreq_frequency_table_cpuinfo() and then expose it to cpufreq core with: cpufreq_frequency_table_get_attr(). This patch creates another helper routine cpufreq_table_validate_and_show() that will do both these steps in a single call and will return 0 for success, error otherwise. This also fixes potential bugs in cpufreq drivers where people have called cpufreq_frequency_table_get_attr() before calling cpufreq_frequency_table_cpuinfo(), as the later may fail. Signed-off-by: Viresh Kumar --- drivers/cpufreq/freq_table.c | 12 ++++++++++++ include/linux/cpufreq.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index f111454a..11f6fa9 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -219,6 +219,18 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu) } EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr); +int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *table) +{ + int ret = cpufreq_frequency_table_cpuinfo(policy, table); + + if (!ret) + cpufreq_frequency_table_get_attr(table, policy->cpu); + + return ret; +} +EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show); + void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy) { pr_debug("Updating show_table for new_cpu %u from last_cpu %u\n", diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index d568f39..c0297a6 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -411,5 +411,7 @@ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; 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); #endif /* _LINUX_CPUFREQ_H */