From patchwork Wed Sep 10 09:41:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 4875491 Return-Path: X-Original-To: patchwork-linux-pm@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 4046E9F3AE for ; Wed, 10 Sep 2014 09:43:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 074A6201D5 for ; Wed, 10 Sep 2014 09:43:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C53E201F2 for ; Wed, 10 Sep 2014 09:43:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751715AbaIJJnW (ORCPT ); Wed, 10 Sep 2014 05:43:22 -0400 Received: from top.free-electrons.com ([176.31.233.9]:35887 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751220AbaIJJmk (ORCPT ); Wed, 10 Sep 2014 05:42:40 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id CF8906F8; Wed, 10 Sep 2014 11:42:38 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id 1B0F86F8; Wed, 10 Sep 2014 11:42:08 +0200 (CEST) From: Thomas Petazzoni To: Viresh Kumar Cc: Rafael Wysocki , Lists linaro-kernel , "linux-pm@vger.kernel.org" , Shawn Guo , Stephen Boyd , "linux-arm-msm@vger.kernel.org" , Sachin Kamat , Thomas Abraham , Tomasz Figa , Santosh Shilimkar , "pramod.gurav@smartplayin.com" , Rob Herring , Mike Turquette , Gregory Clement , Ezequiel Garcia , Tawfik Bayouk , Nadav Haklai , Lior Amsalem , Thomas Petazzoni Subject: [PATCH 1/4] cpufreq: allow driver-specific flags Date: Wed, 10 Sep 2014 11:41:49 +0200 Message-Id: <1410342112-13264-2-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1410342112-13264-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1410342112-13264-1-git-send-email-thomas.petazzoni@free-electrons.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Exactly like the cpuidle subsystem separates core cpuidle flags from driver-specific cpuidle flags, this commit extends the cpufreq subsystem with the same idea: the cpufreq_driver->flags field contain the existing core cpufreq flags in the low 16 bits, and driver-specific flags in the high 16 bits. A new function called cpufreq_get_driver_flags() is added to allow a cpufreq driver to retrieve those flags, since they are typically needed from a cpufreq_policy->init() callback, which does not have access to the cpufreq_driver structure. This function call is similar to the existing cpufreq_get_current_driver() function call. Signed-off-by: Thomas Petazzoni Acked-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 15 +++++++++++++++ include/linux/cpufreq.h | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index d9fdedd..e41b971 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1728,6 +1728,21 @@ const char *cpufreq_get_current_driver(void) } EXPORT_SYMBOL_GPL(cpufreq_get_current_driver); +/** + * cpufreq_get_driver_flags - return current driver's flags + * + * Return the flags of the currently loaded cpufreq driver, or 0 + * if none. + */ +unsigned int cpufreq_get_driver_flags(void) +{ + if (cpufreq_driver) + return cpufreq_driver->flags & CPUFREQ_DRIVER_FLAGS_MASK; + + return 0; +} +EXPORT_SYMBOL_GPL(cpufreq_get_driver_flags); + /********************************************************************* * NOTIFIER LISTS INTERFACE * *********************************************************************/ diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 138336b..fa35601 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -218,7 +218,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name) struct cpufreq_driver { char name[CPUFREQ_NAME_LEN]; - u8 flags; + unsigned int flags; /* needed by all drivers */ int (*init) (struct cpufreq_policy *policy); @@ -308,10 +308,13 @@ struct cpufreq_driver { */ #define CPUFREQ_NEED_INITIAL_FREQ_CHECK (1 << 5) +#define CPUFREQ_DRIVER_FLAGS_MASK (0xFFFF0000) + int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); const char *cpufreq_get_current_driver(void); +unsigned int cpufreq_get_driver_flags(void); static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max)