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: 18850 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f198.google.com (mail-ve0-f198.google.com [209.85.128.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8D52F246A4 for ; Thu, 8 Aug 2013 13:49:02 +0000 (UTC) Received: by mail-ve0-f198.google.com with SMTP id 15sf3484830vea.1 for ; Thu, 08 Aug 2013 06:49:02 -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=4Fv8H4WJvIIF5+5A2BKsnr/5aGPr7qngFtuNz2aahtI=; b=BkHOO0A8oIgROjUdy7MTJ4PV4SdO+c7SZYP8LmA62N903XVL4OmsMLKH3EiFeCozdl 9yVi/FSf30w6wihDuko0zM8j0QyQkGhOBeFFGMBZbNTvyGRP8HPUJKqha+4LRZhivUGU SfTVx4plhtgpRzZlU9kuo5kDNytL+PimgWI/e2ggkE3wfmwbko5iGcqfgEXq3mL9EFc5 IxVpwPbmwuGKmfZjKuqfm6fhKDmqmqsVCcXbwGRsMFx1+w47dm6Y6W/zQb0ye7tidrbT Y5TDXdRuM5bboU+khcFYvsk9YTab78QS0SrQgtVXT+903o21ME/BneYLeaRilVPMpM2y Ge/A== X-Received: by 10.236.139.3 with SMTP id b3mr3414531yhj.3.1375969742208; Thu, 08 Aug 2013 06:49:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.26.6 with SMTP id h6ls1111659qeg.99.gmail; Thu, 08 Aug 2013 06:49:02 -0700 (PDT) X-Received: by 10.58.200.73 with SMTP id jq9mr3150098vec.53.1375969742108; Thu, 08 Aug 2013 06:49:02 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id gq10si3093171vdc.43.2013.08.08.06.49.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 06:49:02 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 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.177; Received: by mail-ve0-f177.google.com with SMTP id cz11so3023876veb.8 for ; Thu, 08 Aug 2013 06:49:02 -0700 (PDT) X-Gm-Message-State: ALoCoQnWDMAUYyR16N1prxF4FuAPfU/cDFab8hTgDO72IKPsGR6G0REE0Yv8o/2xt+yINCvm0yxk X-Received: by 10.58.211.227 with SMTP id nf3mr3214975vec.20.1375969741985; Thu, 08 Aug 2013 06:49:01 -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 u4csp16676vcz; Thu, 8 Aug 2013 06:49:01 -0700 (PDT) X-Received: by 10.66.253.40 with SMTP id zx8mr6283825pac.71.1375969741086; Thu, 08 Aug 2013 06:49:01 -0700 (PDT) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by mx.google.com with ESMTPS id i3si9777383pac.16.2013.08.08.06.49.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 06:49:01 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.52 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.52; Received: by mail-pa0-f52.google.com with SMTP id kq13so3466828pab.25 for ; Thu, 08 Aug 2013 06:49:00 -0700 (PDT) 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 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 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-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.177 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: , 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 */