cpuquiet: Enable cpuquiet by default
[firefly-linux-kernel-4.4.55.git] / drivers / cpuquiet / governors / userspace.c
1 /*
2  * Copyright (c) 2012 NVIDIA CORPORATION.  All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16  *
17  */
18
19 #include <linux/mutex.h>
20 #include <linux/module.h>
21 #include <linux/cpuquiet.h>
22 #include <linux/sysfs.h>
23
24 static DEFINE_MUTEX(userspace_mutex);
25
26 static int governor_set(unsigned int cpu, bool active)
27 {
28         mutex_lock(&userspace_mutex);
29         if (active)
30                 cpuquiet_wake_cpu(cpu);
31         else
32                 cpuquiet_quiesence_cpu(cpu);
33         mutex_unlock(&userspace_mutex);
34
35         return 0;
36 }
37
38 struct cpuquiet_governor userspace_governor = {
39         .name           = "userspace",
40         .store_active   = governor_set,
41         .owner          = THIS_MODULE,
42 };
43
44 static int __init init_usermode(void)
45 {
46         return cpuquiet_register_governor(&userspace_governor);
47 }
48
49 static void __exit exit_usermode(void)
50 {
51         cpuquiet_unregister_governor(&userspace_governor);
52 }
53
54 MODULE_LICENSE("GPL");
55 #ifdef CONFIG_CPUQUIET_DEFAULT_GOV_USERSPACE
56 fs_initcall(init_usermode);
57 #else
58 module_init(init_usermode);
59 #endif
60 module_exit(exit_usermode);