sctp: better integer overflow check in sctp_auth_create_key()
[linux/fpc-iii.git] / tools / power / cpupower / lib / cpufreq.h
blob3aae8e7a083940ae6b5a961402d3515d265cc98c
1 /*
2 * cpufreq.h - definitions for libcpufreq
4 * Copyright (C) 2004-2009 Dominik Brodowski <linux@dominikbrodowski.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef _CPUFREQ_H
21 #define _CPUFREQ_H 1
23 struct cpufreq_policy {
24 unsigned long min;
25 unsigned long max;
26 char *governor;
29 struct cpufreq_available_governors {
30 char *governor;
31 struct cpufreq_available_governors *next;
32 struct cpufreq_available_governors *first;
35 struct cpufreq_available_frequencies {
36 unsigned long frequency;
37 struct cpufreq_available_frequencies *next;
38 struct cpufreq_available_frequencies *first;
42 struct cpufreq_affected_cpus {
43 unsigned int cpu;
44 struct cpufreq_affected_cpus *next;
45 struct cpufreq_affected_cpus *first;
48 struct cpufreq_stats {
49 unsigned long frequency;
50 unsigned long long time_in_state;
51 struct cpufreq_stats *next;
52 struct cpufreq_stats *first;
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
62 * returns 0 if the specified CPU is present (it doesn't say
63 * whether it is online!), and an error value if not.
66 extern int cpufreq_cpu_exists(unsigned int cpu);
68 /* determine current CPU frequency
69 * - _kernel variant means kernel's opinion of CPU frequency
70 * - _hardware variant means actual hardware CPU frequency,
71 * which is only available to root.
73 * returns 0 on failure, else frequency in kHz.
76 extern unsigned long cpufreq_get_freq_kernel(unsigned int cpu);
78 extern unsigned long cpufreq_get_freq_hardware(unsigned int cpu);
80 #define cpufreq_get(cpu) cpufreq_get_freq_kernel(cpu);
83 /* determine CPU transition latency
85 * returns 0 on failure, else transition latency in 10^(-9) s = nanoseconds
87 extern unsigned long cpufreq_get_transition_latency(unsigned int cpu);
90 /* determine hardware CPU frequency limits
92 * These may be limited further by thermal, energy or other
93 * considerations by cpufreq policy notifiers in the kernel.
96 extern int cpufreq_get_hardware_limits(unsigned int cpu,
97 unsigned long *min,
98 unsigned long *max);
101 /* determine CPUfreq driver used
103 * Remember to call cpufreq_put_driver when no longer needed
104 * to avoid memory leakage, please.
107 extern char *cpufreq_get_driver(unsigned int cpu);
109 extern void cpufreq_put_driver(char *ptr);
112 /* determine CPUfreq policy currently used
114 * Remember to call cpufreq_put_policy when no longer needed
115 * to avoid memory leakage, please.
119 extern struct cpufreq_policy *cpufreq_get_policy(unsigned int cpu);
121 extern void cpufreq_put_policy(struct cpufreq_policy *policy);
124 /* determine CPUfreq governors currently available
126 * may be modified by modprobe'ing or rmmod'ing other governors. Please
127 * free allocated memory by calling cpufreq_put_available_governors
128 * after use.
132 extern struct cpufreq_available_governors
133 *cpufreq_get_available_governors(unsigned int cpu);
135 extern void cpufreq_put_available_governors(
136 struct cpufreq_available_governors *first);
139 /* determine CPU frequency states available
141 * Only present on _some_ ->target() cpufreq drivers. For information purposes
142 * only. Please free allocated memory by calling
143 * cpufreq_put_available_frequencies after use.
146 extern struct cpufreq_available_frequencies
147 *cpufreq_get_available_frequencies(unsigned int cpu);
149 extern void cpufreq_put_available_frequencies(
150 struct cpufreq_available_frequencies *first);
153 /* determine affected CPUs
155 * Remember to call cpufreq_put_affected_cpus when no longer needed
156 * to avoid memory leakage, please.
159 extern struct cpufreq_affected_cpus *cpufreq_get_affected_cpus(unsigned
160 int cpu);
162 extern void cpufreq_put_affected_cpus(struct cpufreq_affected_cpus *first);
165 /* determine related CPUs
167 * Remember to call cpufreq_put_related_cpus when no longer needed
168 * to avoid memory leakage, please.
171 extern struct cpufreq_affected_cpus *cpufreq_get_related_cpus(unsigned
172 int cpu);
174 extern void cpufreq_put_related_cpus(struct cpufreq_affected_cpus *first);
177 /* determine stats for cpufreq subsystem
179 * This is not available in all kernel versions or configurations.
182 extern struct cpufreq_stats *cpufreq_get_stats(unsigned int cpu,
183 unsigned long long *total_time);
185 extern void cpufreq_put_stats(struct cpufreq_stats *stats);
187 extern unsigned long cpufreq_get_transitions(unsigned int cpu);
190 /* set new cpufreq policy
192 * Tries to set the passed policy as new policy as close as possible,
193 * but results may differ depending e.g. on governors being available.
196 extern int cpufreq_set_policy(unsigned int cpu, struct cpufreq_policy *policy);
199 /* modify a policy by only changing min/max freq or governor
201 * Does not check whether result is what was intended.
204 extern int cpufreq_modify_policy_min(unsigned int cpu, unsigned long min_freq);
205 extern int cpufreq_modify_policy_max(unsigned int cpu, unsigned long max_freq);
206 extern int cpufreq_modify_policy_governor(unsigned int cpu, char *governor);
209 /* set a specific frequency
211 * Does only work if userspace governor can be used and no external
212 * interference (other calls to this function or to set/modify_policy)
213 * occurs. Also does not work on ->range() cpufreq drivers.
216 extern int cpufreq_set_frequency(unsigned int cpu,
217 unsigned long target_frequency);
219 #ifdef __cplusplus
221 #endif
223 #endif /* _CPUFREQ_H */