summaryrefslogtreecommitdiff
path: root/drivers/edp
diff options
context:
space:
mode:
authorSivaram Nair <sivaramn@nvidia.com>2012-08-28 19:03:30 +0300
committerVarun Colbert <vcolbert@nvidia.com>2012-08-29 14:59:22 -0700
commitbf2d0f3d8ff63205714ed22a6111aa80ec83f1a4 (patch)
treefbb5b0322a012e8f818e62af52472f3080ca28d6 /drivers/edp
parent8bbb976204b22cf0a7968bd689b12c0dab87dc90 (diff)
pm: EDP: refactoring
Minor refactoring to prepare the code for adding sysfs entries. Change-Id: I12cb12f1a22b5064a284da12b27687ab2ed209f8 Signed-off-by: Sivaram Nair <sivaramn@nvidia.com> Reviewed-on: http://git-master/r/127889 Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
Diffstat (limited to 'drivers/edp')
-rw-r--r--drivers/edp/edp.c21
-rw-r--r--drivers/edp/edp_internal.h7
2 files changed, 18 insertions, 10 deletions
diff --git a/drivers/edp/edp.c b/drivers/edp/edp.c
index 0081975008bb..f08e3caed8d1 100644
--- a/drivers/edp/edp.c
+++ b/drivers/edp/edp.c
@@ -25,7 +25,7 @@
DEFINE_MUTEX(edp_lock);
static LIST_HEAD(edp_managers);
-static LIST_HEAD(edp_governors);
+LIST_HEAD(edp_governors);
static struct edp_manager *find_manager(const char *name)
{
@@ -72,7 +72,8 @@ int edp_register_manager(struct edp_manager *mgr)
}
EXPORT_SYMBOL(edp_register_manager);
-static int set_governor(struct edp_manager *mgr, struct edp_governor *gov)
+int edp_set_governor_unlocked(struct edp_manager *mgr,
+ struct edp_governor *gov)
{
int r = 0;
@@ -121,7 +122,7 @@ int edp_unregister_manager(struct edp_manager *mgr)
} else if (!list_empty(&mgr->clients)) {
r = -EBUSY;
} else {
- set_governor(mgr, NULL);
+ edp_set_governor_unlocked(mgr, NULL);
list_del(&mgr->link);
mgr->registered = false;
}
@@ -205,12 +206,12 @@ static int register_client(struct edp_manager *mgr, struct edp_client *client)
if (!mgr || !client)
return -EINVAL;
- if (client->manager || find_client(mgr, client->name))
- return -EEXIST;
-
if (!mgr->registered)
return -ENODEV;
+ if (client->manager || find_client(mgr, client->name))
+ return -EEXIST;
+
if (!states_ok(client) || client->priority < EDP_MIN_PRIO ||
client->priority > EDP_MAX_PRIO)
return -EINVAL;
@@ -500,7 +501,7 @@ int edp_update_loan_threshold(struct edp_client *client, unsigned int threshold)
}
EXPORT_SYMBOL(edp_update_loan_threshold);
-static struct edp_governor *find_governor(const char *s)
+struct edp_governor *edp_find_governor_unlocked(const char *s)
{
struct edp_governor *g;
@@ -522,7 +523,7 @@ int edp_register_governor(struct edp_governor *gov)
return -EINVAL;
mutex_lock(&edp_lock);
- if (find_governor(gov->name)) {
+ if (edp_find_governor_unlocked(gov->name)) {
r = -EEXIST;
} else {
gov->refcnt = 1;
@@ -558,7 +559,7 @@ struct edp_governor *edp_get_governor(const char *name)
struct edp_governor *g;
mutex_lock(&edp_lock);
- g = find_governor(name);
+ g = edp_find_governor_unlocked(name);
mutex_unlock(&edp_lock);
return g;
@@ -570,7 +571,7 @@ int edp_set_governor(struct edp_manager *mgr, struct edp_governor *gov)
int r;
mutex_lock(&edp_lock);
- r = set_governor(mgr, gov);
+ r = edp_set_governor_unlocked(mgr, gov);
mutex_unlock(&edp_lock);
return r;
diff --git a/drivers/edp/edp_internal.h b/drivers/edp/edp_internal.h
index 636a8574adc4..227e42c585a2 100644
--- a/drivers/edp/edp_internal.h
+++ b/drivers/edp/edp_internal.h
@@ -51,4 +51,11 @@ static inline unsigned int req_index(struct edp_client *c)
return c->req ? c->req - c->states : c->num_states;
}
+extern struct mutex edp_lock;
+extern struct list_head edp_governors;
+
+struct edp_governor *edp_find_governor_unlocked(const char *s);
+int edp_set_governor_unlocked(struct edp_manager *mgr,
+ struct edp_governor *gov);
+
#endif