diff options
Diffstat (limited to 'tools/power/cpupower/lib/cpufreq.c')
-rw-r--r-- | tools/power/cpupower/lib/cpufreq.c | 72 |
1 files changed, 45 insertions, 27 deletions
diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c index ae7d8c57b447..d961101d1cea 100644 --- a/tools/power/cpupower/lib/cpufreq.c +++ b/tools/power/cpupower/lib/cpufreq.c | |||
@@ -42,21 +42,25 @@ int cpufreq_get_hardware_limits(unsigned int cpu, | |||
42 | return sysfs_get_freq_hardware_limits(cpu, min, max); | 42 | return sysfs_get_freq_hardware_limits(cpu, min, max); |
43 | } | 43 | } |
44 | 44 | ||
45 | char * cpufreq_get_driver(unsigned int cpu) { | 45 | char *cpufreq_get_driver(unsigned int cpu) |
46 | { | ||
46 | return sysfs_get_freq_driver(cpu); | 47 | return sysfs_get_freq_driver(cpu); |
47 | } | 48 | } |
48 | 49 | ||
49 | void cpufreq_put_driver(char * ptr) { | 50 | void cpufreq_put_driver(char *ptr) |
51 | { | ||
50 | if (!ptr) | 52 | if (!ptr) |
51 | return; | 53 | return; |
52 | free(ptr); | 54 | free(ptr); |
53 | } | 55 | } |
54 | 56 | ||
55 | struct cpufreq_policy * cpufreq_get_policy(unsigned int cpu) { | 57 | struct cpufreq_policy *cpufreq_get_policy(unsigned int cpu) |
58 | { | ||
56 | return sysfs_get_freq_policy(cpu); | 59 | return sysfs_get_freq_policy(cpu); |
57 | } | 60 | } |
58 | 61 | ||
59 | void cpufreq_put_policy(struct cpufreq_policy *policy) { | 62 | void cpufreq_put_policy(struct cpufreq_policy *policy) |
63 | { | ||
60 | if ((!policy) || (!policy->governor)) | 64 | if ((!policy) || (!policy->governor)) |
61 | return; | 65 | return; |
62 | 66 | ||
@@ -65,11 +69,14 @@ void cpufreq_put_policy(struct cpufreq_policy *policy) { | |||
65 | free(policy); | 69 | free(policy); |
66 | } | 70 | } |
67 | 71 | ||
68 | struct cpufreq_available_governors * cpufreq_get_available_governors(unsigned int cpu) { | 72 | struct cpufreq_available_governors *cpufreq_get_available_governors(unsigned |
73 | int cpu) | ||
74 | { | ||
69 | return sysfs_get_freq_available_governors(cpu); | 75 | return sysfs_get_freq_available_governors(cpu); |
70 | } | 76 | } |
71 | 77 | ||
72 | void cpufreq_put_available_governors(struct cpufreq_available_governors *any) { | 78 | void cpufreq_put_available_governors(struct cpufreq_available_governors *any) |
79 | { | ||
73 | struct cpufreq_available_governors *tmp, *next; | 80 | struct cpufreq_available_governors *tmp, *next; |
74 | 81 | ||
75 | if (!any) | 82 | if (!any) |
@@ -86,11 +93,14 @@ void cpufreq_put_available_governors(struct cpufreq_available_governors *any) { | |||
86 | } | 93 | } |
87 | 94 | ||
88 | 95 | ||
89 | struct cpufreq_available_frequencies * cpufreq_get_available_frequencies(unsigned int cpu) { | 96 | struct cpufreq_available_frequencies |
97 | *cpufreq_get_available_frequencies(unsigned int cpu) | ||
98 | { | ||
90 | return sysfs_get_available_frequencies(cpu); | 99 | return sysfs_get_available_frequencies(cpu); |
91 | } | 100 | } |
92 | 101 | ||
93 | void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies *any) { | 102 | void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies |
103 | *any) { | ||
94 | struct cpufreq_available_frequencies *tmp, *next; | 104 | struct cpufreq_available_frequencies *tmp, *next; |
95 | 105 | ||
96 | if (!any) | 106 | if (!any) |
@@ -105,11 +115,13 @@ void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies *any | |||
105 | } | 115 | } |
106 | 116 | ||
107 | 117 | ||
108 | struct cpufreq_affected_cpus * cpufreq_get_affected_cpus(unsigned int cpu) { | 118 | struct cpufreq_affected_cpus *cpufreq_get_affected_cpus(unsigned int cpu) |
119 | { | ||
109 | return sysfs_get_freq_affected_cpus(cpu); | 120 | return sysfs_get_freq_affected_cpus(cpu); |
110 | } | 121 | } |
111 | 122 | ||
112 | void cpufreq_put_affected_cpus(struct cpufreq_affected_cpus *any) { | 123 | void cpufreq_put_affected_cpus(struct cpufreq_affected_cpus *any) |
124 | { | ||
113 | struct cpufreq_affected_cpus *tmp, *next; | 125 | struct cpufreq_affected_cpus *tmp, *next; |
114 | 126 | ||
115 | if (!any) | 127 | if (!any) |
@@ -124,16 +136,19 @@ void cpufreq_put_affected_cpus(struct cpufreq_affected_cpus *any) { | |||
124 | } | 136 | } |
125 | 137 | ||
126 | 138 | ||
127 | struct cpufreq_affected_cpus * cpufreq_get_related_cpus(unsigned int cpu) { | 139 | struct cpufreq_affected_cpus *cpufreq_get_related_cpus(unsigned int cpu) |
140 | { | ||
128 | return sysfs_get_freq_related_cpus(cpu); | 141 | return sysfs_get_freq_related_cpus(cpu); |
129 | } | 142 | } |
130 | 143 | ||
131 | void cpufreq_put_related_cpus(struct cpufreq_affected_cpus *any) { | 144 | void cpufreq_put_related_cpus(struct cpufreq_affected_cpus *any) |
145 | { | ||
132 | cpufreq_put_affected_cpus(any); | 146 | cpufreq_put_affected_cpus(any); |
133 | } | 147 | } |
134 | 148 | ||
135 | 149 | ||
136 | int cpufreq_set_policy(unsigned int cpu, struct cpufreq_policy *policy) { | 150 | int cpufreq_set_policy(unsigned int cpu, struct cpufreq_policy *policy) |
151 | { | ||
137 | if (!policy || !(policy->governor)) | 152 | if (!policy || !(policy->governor)) |
138 | return -EINVAL; | 153 | return -EINVAL; |
139 | 154 | ||
@@ -141,35 +156,39 @@ int cpufreq_set_policy(unsigned int cpu, struct cpufreq_policy *policy) { | |||
141 | } | 156 | } |
142 | 157 | ||
143 | 158 | ||
144 | int cpufreq_modify_policy_min(unsigned int cpu, unsigned long min_freq) { | 159 | int cpufreq_modify_policy_min(unsigned int cpu, unsigned long min_freq) |
160 | { | ||
145 | return sysfs_modify_freq_policy_min(cpu, min_freq); | 161 | return sysfs_modify_freq_policy_min(cpu, min_freq); |
146 | } | 162 | } |
147 | 163 | ||
148 | 164 | ||
149 | int cpufreq_modify_policy_max(unsigned int cpu, unsigned long max_freq) { | 165 | int cpufreq_modify_policy_max(unsigned int cpu, unsigned long max_freq) |
166 | { | ||
150 | return sysfs_modify_freq_policy_max(cpu, max_freq); | 167 | return sysfs_modify_freq_policy_max(cpu, max_freq); |
151 | } | 168 | } |
152 | 169 | ||
153 | 170 | ||
154 | int cpufreq_modify_policy_governor(unsigned int cpu, char *governor) { | 171 | int cpufreq_modify_policy_governor(unsigned int cpu, char *governor) |
172 | { | ||
155 | if ((!governor) || (strlen(governor) > 19)) | 173 | if ((!governor) || (strlen(governor) > 19)) |
156 | return -EINVAL; | 174 | return -EINVAL; |
157 | 175 | ||
158 | return sysfs_modify_freq_policy_governor(cpu, governor); | 176 | return sysfs_modify_freq_policy_governor(cpu, governor); |
159 | } | 177 | } |
160 | 178 | ||
161 | int cpufreq_set_frequency(unsigned int cpu, unsigned long target_frequency) { | 179 | int cpufreq_set_frequency(unsigned int cpu, unsigned long target_frequency) |
180 | { | ||
162 | return sysfs_set_frequency(cpu, target_frequency); | 181 | return sysfs_set_frequency(cpu, target_frequency); |
163 | } | 182 | } |
164 | 183 | ||
165 | struct cpufreq_stats * cpufreq_get_stats(unsigned int cpu, unsigned long long *total_time) { | 184 | struct cpufreq_stats *cpufreq_get_stats(unsigned int cpu, |
166 | struct cpufreq_stats *ret; | 185 | unsigned long long *total_time) |
167 | 186 | { | |
168 | ret = sysfs_get_freq_stats(cpu, total_time); | 187 | return sysfs_get_freq_stats(cpu, total_time); |
169 | return (ret); | ||
170 | } | 188 | } |
171 | 189 | ||
172 | void cpufreq_put_stats(struct cpufreq_stats *any) { | 190 | void cpufreq_put_stats(struct cpufreq_stats *any) |
191 | { | ||
173 | struct cpufreq_stats *tmp, *next; | 192 | struct cpufreq_stats *tmp, *next; |
174 | 193 | ||
175 | if (!any) | 194 | if (!any) |
@@ -183,8 +202,7 @@ void cpufreq_put_stats(struct cpufreq_stats *any) { | |||
183 | } | 202 | } |
184 | } | 203 | } |
185 | 204 | ||
186 | unsigned long cpufreq_get_transitions(unsigned int cpu) { | 205 | unsigned long cpufreq_get_transitions(unsigned int cpu) |
187 | unsigned long ret = sysfs_get_freq_transitions(cpu); | 206 | { |
188 | 207 | return sysfs_get_freq_transitions(cpu); | |
189 | return (ret); | ||
190 | } | 208 | } |