From patchwork Fri Sep 13 12:59:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20063 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 92689202E6 for ; Fri, 13 Sep 2013 13:04:06 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id f12sf1186578vbg.3 for ; Fri, 13 Sep 2013 06:04:06 -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=i4dCy9Jc+AJmbu5V1okZUwXnFUiaynjwpIjYRpF2Y74=; b=fNtY7K0pA6ronvPfPhDgW8LiJqxD8pL7SDSsFJAsVRkiZBtITMYoGjuReU8OFv+lUb sYA11M1RInVPtuvt54LacN8Fh2StJABKt3Tba71d0XnSglmdRUynQm1DrSnx+n7Up/od DI39GD0rEXl1hszgpHsNlOOusWG5MlgVgo0OBKuGzKoWvp2hcVx52AdkLQbE9PmLF5tH o02bLsNr5+CcN0qRUTiJWfBr/0cJ4OcPtvwEDv0Xry/b5NcrF6rdqxZ2EH7XiKuM2Vfi CSzRhyOzRpAyf9eRYJVlYGoDVWAdzUDo2aq7JrCnMO15qMsPvC5aR/1b13WhGIC8aeSJ ycKA== X-Gm-Message-State: ALoCoQnwM+E2jWQzqiQt+zCFMUKRJdnxw6UdzLGGs/2NqoDbTns3Le3nW7vaEQ/a30u/C7WvkAAO X-Received: by 10.58.46.172 with SMTP id w12mr933109vem.16.1379077446260; Fri, 13 Sep 2013 06:04:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.94.68 with SMTP id da4ls1129789qeb.24.gmail; Fri, 13 Sep 2013 06:04:06 -0700 (PDT) X-Received: by 10.52.122.68 with SMTP id lq4mr10074647vdb.21.1379077446028; Fri, 13 Sep 2013 06:04:06 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id st7si3071558vdc.146.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:04:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.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.128.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so909566veb.26 for ; Fri, 13 Sep 2013 06:04:05 -0700 (PDT) X-Received: by 10.52.164.16 with SMTP id ym16mr162175vdb.39.1379077445942; Fri, 13 Sep 2013 06:04:05 -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 u4csp79436vcz; Fri, 13 Sep 2013 06:04:05 -0700 (PDT) X-Received: by 10.68.33.100 with SMTP id q4mr5948058pbi.119.1379077444775; Fri, 13 Sep 2013 06:04:04 -0700 (PDT) Received: from mail-pd0-f169.google.com (mail-pd0-f169.google.com [209.85.192.169]) by mx.google.com with ESMTPS id vs3si11195179pab.56.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:04:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.169 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.169; Received: by mail-pd0-f169.google.com with SMTP id r10so1226904pdi.14 for ; Fri, 13 Sep 2013 06:04:04 -0700 (PDT) X-Received: by 10.68.137.170 with SMTP id qj10mr13219712pbb.31.1379077444303; Fri, 13 Sep 2013 06:04:04 -0700 (PDT) Received: from localhost ([122.167.78.148]) by mx.google.com with ESMTPSA id im2sm11634105pbd.31.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 13 Sep 2013 06:04:03 -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 009/228] cpufreq: Add new helper cpufreq_table_validate_and_show() Date: Fri, 13 Sep 2013 18:29:15 +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.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: , 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 29ff77f..b9336ed 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -218,6 +218,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 21f6543..e257407 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -433,5 +433,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 */