diff options
Diffstat (limited to 'drivers/devfreq/governor_userspace.c')
-rw-r--r-- | drivers/devfreq/governor_userspace.c | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c index 0681246fc89d..35de6e83c1fe 100644 --- a/drivers/devfreq/governor_userspace.c +++ b/drivers/devfreq/governor_userspace.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/devfreq.h> | 14 | #include <linux/devfreq.h> |
15 | #include <linux/pm.h> | 15 | #include <linux/pm.h> |
16 | #include <linux/mutex.h> | 16 | #include <linux/mutex.h> |
17 | #include <linux/module.h> | ||
17 | #include "governor.h" | 18 | #include "governor.h" |
18 | 19 | ||
19 | struct userspace_data { | 20 | struct userspace_data { |
@@ -116,10 +117,46 @@ static void userspace_exit(struct devfreq *devfreq) | |||
116 | devfreq->data = NULL; | 117 | devfreq->data = NULL; |
117 | } | 118 | } |
118 | 119 | ||
119 | const struct devfreq_governor devfreq_userspace = { | 120 | static int devfreq_userspace_handler(struct devfreq *devfreq, |
121 | unsigned int event, void *data) | ||
122 | { | ||
123 | int ret = 0; | ||
124 | |||
125 | switch (event) { | ||
126 | case DEVFREQ_GOV_START: | ||
127 | ret = userspace_init(devfreq); | ||
128 | break; | ||
129 | case DEVFREQ_GOV_STOP: | ||
130 | userspace_exit(devfreq); | ||
131 | break; | ||
132 | default: | ||
133 | break; | ||
134 | } | ||
135 | |||
136 | return ret; | ||
137 | } | ||
138 | |||
139 | static struct devfreq_governor devfreq_userspace = { | ||
120 | .name = "userspace", | 140 | .name = "userspace", |
121 | .get_target_freq = devfreq_userspace_func, | 141 | .get_target_freq = devfreq_userspace_func, |
122 | .init = userspace_init, | 142 | .event_handler = devfreq_userspace_handler, |
123 | .exit = userspace_exit, | ||
124 | .no_central_polling = true, | ||
125 | }; | 143 | }; |
144 | |||
145 | static int __init devfreq_userspace_init(void) | ||
146 | { | ||
147 | return devfreq_add_governor(&devfreq_userspace); | ||
148 | } | ||
149 | subsys_initcall(devfreq_userspace_init); | ||
150 | |||
151 | static void __exit devfreq_userspace_exit(void) | ||
152 | { | ||
153 | int ret; | ||
154 | |||
155 | ret = devfreq_remove_governor(&devfreq_userspace); | ||
156 | if (ret) | ||
157 | pr_err("%s: failed remove governor %d\n", __func__, ret); | ||
158 | |||
159 | return; | ||
160 | } | ||
161 | module_exit(devfreq_userspace_exit); | ||
162 | MODULE_LICENSE("GPL"); | ||