From patchwork Wed Aug 24 13:48:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan Jackman X-Patchwork-Id: 9297927 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BA9B0607D0 for ; Wed, 24 Aug 2016 13:55:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABD1028F6C for ; Wed, 24 Aug 2016 13:55:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E5DB28FF3; Wed, 24 Aug 2016 13:55:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40DE028F6C for ; Wed, 24 Aug 2016 13:55:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754569AbcHXNzP (ORCPT ); Wed, 24 Aug 2016 09:55:15 -0400 Received: from foss.arm.com ([217.140.101.70]:48633 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753286AbcHXNzO (ORCPT ); Wed, 24 Aug 2016 09:55:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3326067E; Wed, 24 Aug 2016 06:50:17 -0700 (PDT) Received: from brendan-thinkstation.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BDE4F3F32C; Wed, 24 Aug 2016 06:48:35 -0700 (PDT) From: Brendan Jackman To: ulf.hansson@linaro.org, khilman@kernel.org, rjw@rjwysocki.net Cc: andy.gross@linaro.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org, Axel Haslam , devicetree@vger.kernel.org, Marc Titinger , Lina Iyer , Lorenzo Pieralisi , Sudeep Holla Subject: [RFC 2/6] cpuidle: Add public funcion to get driver from CPU index Date: Wed, 24 Aug 2016 14:48:18 +0100 Message-Id: <20160824134822.3591-3-brendan.jackman@arm.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160824134822.3591-1-brendan.jackman@arm.com> References: <1470351902-43103-3-git-send-email-lina.iyer@linaro.org> <20160824134822.3591-1-brendan.jackman@arm.com> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This will be used to enable the PSCI driver to get a reference to the cpuidle driver, in absence of a registered cpuidle_device, in order to get the idle states that the cpuidle driver init discovered. --- drivers/cpuidle/driver.c | 14 +++++++------- include/linux/cpuidle.h | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 9e0ec15..9cb4300 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c @@ -24,13 +24,13 @@ DEFINE_SPINLOCK(cpuidle_driver_lock); static DEFINE_PER_CPU(struct cpuidle_driver *, cpuidle_drivers); /** - * __cpuidle_get_cpu_driver - return the cpuidle driver tied to a CPU. + * cpuidle_get_cpu_driver - return the cpuidle driver tied to a CPU. * @cpu: the CPU handled by the driver * * Returns a pointer to struct cpuidle_driver or NULL if no driver has been * registered for @cpu. */ -static struct cpuidle_driver *__cpuidle_get_cpu_driver(int cpu) +struct cpuidle_driver *cpuidle_get_cpu_driver(int cpu) { return per_cpu(cpuidle_drivers, cpu); } @@ -49,7 +49,7 @@ static inline void __cpuidle_unset_driver(struct cpuidle_driver *drv) for_each_cpu(cpu, drv->cpumask) { - if (drv != __cpuidle_get_cpu_driver(cpu)) + if (drv != cpuidle_get_cpu_driver(cpu)) continue; per_cpu(cpuidle_drivers, cpu) = NULL; @@ -71,7 +71,7 @@ static inline int __cpuidle_set_driver(struct cpuidle_driver *drv) for_each_cpu(cpu, drv->cpumask) { - if (__cpuidle_get_cpu_driver(cpu)) { + if (cpuidle_get_cpu_driver(cpu)) { __cpuidle_unset_driver(drv); return -EBUSY; } @@ -87,13 +87,13 @@ static inline int __cpuidle_set_driver(struct cpuidle_driver *drv) static struct cpuidle_driver *cpuidle_curr_driver; /** - * __cpuidle_get_cpu_driver - return the global cpuidle driver pointer. + * cpuidle_get_cpu_driver - return the global cpuidle driver pointer. * @cpu: ignored without the multiple driver support * * Return a pointer to a struct cpuidle_driver object or NULL if no driver was * previously registered. */ -static inline struct cpuidle_driver *__cpuidle_get_cpu_driver(int cpu) +inline struct cpuidle_driver *cpuidle_get_cpu_driver(int cpu) { return cpuidle_curr_driver; } @@ -321,7 +321,7 @@ struct cpuidle_driver *cpuidle_get_driver(void) int cpu; cpu = get_cpu(); - drv = __cpuidle_get_cpu_driver(cpu); + drv = cpuidle_get_cpu_driver(cpu); put_cpu(); return drv; diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index e32c72b..8435577 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -134,6 +134,7 @@ extern int cpuidle_enter(struct cpuidle_driver *drv, extern void cpuidle_reflect(struct cpuidle_device *dev, int index); extern int cpuidle_register_driver(struct cpuidle_driver *drv); +extern struct cpuidle_driver *cpuidle_get_cpu_driver(int cpu); extern struct cpuidle_driver *cpuidle_get_driver(void); extern struct cpuidle_driver *cpuidle_driver_ref(void); extern void cpuidle_driver_unref(void); @@ -168,6 +169,8 @@ static inline int cpuidle_enter(struct cpuidle_driver *drv, static inline void cpuidle_reflect(struct cpuidle_device *dev, int index) { } static inline int cpuidle_register_driver(struct cpuidle_driver *drv) {return -ENODEV; } +static inline struct cpuidle_driver *cpuidle_get_cpu_driver(int cpu) +{return NULL; } static inline struct cpuidle_driver *cpuidle_get_driver(void) {return NULL; } static inline struct cpuidle_driver *cpuidle_driver_ref(void) {return NULL; } static inline void cpuidle_driver_unref(void) {}