PM / devfreq: map devfreq drivers to governor using name
[deliverable/linux.git] / drivers / devfreq / governor_userspace.c
index 0681246fc89dc32e53900929abd2c2df4329e0ab..34fb80f50cf6e439cca5765e1f8bf66ca59805a5 100644 (file)
@@ -116,10 +116,45 @@ static void userspace_exit(struct devfreq *devfreq)
        devfreq->data = NULL;
 }
 
-const struct devfreq_governor devfreq_userspace = {
+static int devfreq_userspace_handler(struct devfreq *devfreq,
+                       unsigned int event, void *data)
+{
+       int ret = 0;
+
+       switch (event) {
+       case DEVFREQ_GOV_START:
+               ret = userspace_init(devfreq);
+               break;
+       case DEVFREQ_GOV_STOP:
+               userspace_exit(devfreq);
+               break;
+       default:
+               break;
+       }
+
+       return ret;
+}
+
+static struct devfreq_governor devfreq_userspace = {
        .name = "userspace",
        .get_target_freq = devfreq_userspace_func,
-       .init = userspace_init,
-       .exit = userspace_exit,
-       .no_central_polling = true,
+       .event_handler = devfreq_userspace_handler,
 };
+
+static int __init devfreq_userspace_init(void)
+{
+       return devfreq_add_governor(&devfreq_userspace);
+}
+subsys_initcall(devfreq_userspace_init);
+
+static void __exit devfreq_userspace_exit(void)
+{
+       int ret;
+
+       ret = devfreq_remove_governor(&devfreq_userspace);
+       if (ret)
+               pr_err("%s: failed remove governor %d\n", __func__, ret);
+
+       return;
+}
+module_exit(devfreq_userspace_exit);
This page took 0.024907 seconds and 5 git commands to generate.