From 160fe3a960977498808e2a7ac8dd67d671865eaf Mon Sep 17 00:00:00 2001 From: Jongyun Jung Date: Tue, 23 Feb 2016 16:00:04 +0900 Subject: [PATCH] [COMMON] power: qos: added the function for reading request value Added the function for reading the value not adjusted, but requested. Change-Id: Ief4fefe5a867ab1643e75bd4ae927966f24bc588 Signed-off-by: Jongyun Jung --- include/linux/pm_qos.h | 1 + kernel/power/qos.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 531f0a95d433..289e71669058 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -164,6 +164,7 @@ void pm_qos_update_request_timeout(struct pm_qos_request *req, s32 new_value, unsigned long timeout_us); void pm_qos_remove_request(struct pm_qos_request *req); +int pm_qos_read_req_value(int pm_qos_class, struct pm_qos_request *req); int pm_qos_request(int pm_qos_class); int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier); int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier); diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 0906e70abb69..0863d732ba18 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -519,6 +519,33 @@ bool pm_qos_update_flags(struct pm_qos_flags *pqf, return prev_value != curr_value; } +/** + * pm_qos_read_req_value - returns requested qos value + * @pm_qos_class: identification of which qos value is requested + * @req: request wanted to find set value + * + * This function returns the requested qos value by sysfs node. + */ +int pm_qos_read_req_value(int pm_qos_class, struct pm_qos_request *req) +{ + struct plist_node *p; + unsigned long flags; + + spin_lock_irqsave(&pm_qos_lock, flags); + + plist_for_each(p, &pm_qos_array[pm_qos_class]->constraints->list) { + if (req == container_of(p, struct pm_qos_request, node)) { + spin_unlock_irqrestore(&pm_qos_lock, flags); + return p->prio; + } + } + + spin_unlock_irqrestore(&pm_qos_lock, flags); + + return -ENODATA; +} +EXPORT_SYMBOL_GPL(pm_qos_read_req_value); + /** * pm_qos_request - returns current system wide qos expectation * @pm_qos_class: identification of which qos value is requested -- 2.20.1