Commit 8d04df4d authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Linus Torvalds

[PATCH] cpufreq: /proc/sys/cpu and /proc/cpufreq can be used simultaneously

Both the /proc/sys/cpu/ and /proc/cpufreq interface can safely be
enabled in the same kernel. This simplifies the transition to the newer
interface. Only minor updates are needed in order to allow this to be
done.
parent 5370f2ff
...@@ -479,26 +479,19 @@ config CPU_FREQ ...@@ -479,26 +479,19 @@ config CPU_FREQ
If in doubt, say N. If in doubt, say N.
config CPU_FREQ_24_API config CPU_FREQ_24_API
bool "/proc/sys/cpu/ interface (2.4.)" bool "/proc/sys/cpu/ interface (2.4. / OLD)"
depends on CPU_FREQ depends on CPU_FREQ
---help--- help
This enables the /proc/sys/cpu/ sysctl interface for controlling This enables the /proc/sys/cpu/ sysctl interface for controlling
CPUFreq, as known from the 2.4.-kernel patches for CPUFreq. Note CPUFreq, as known from the 2.4.-kernel patches for CPUFreq. 2.5
that some drivers do not support this interface or offer less uses /proc/cpufreq instead. Please note that some drivers do not
functionality. work well with the 2.4. /proc/sys/cpu sysctl interface, so if in
doubt, say N here.
If you say N here, you'll be able to control CPUFreq using the
new /proc/cpufreq interface.
For details, take a look at linux/Documentation/cpufreq. For details, take a look at linux/Documentation/cpufreq.
If in doubt, say N. If in doubt, say N.
config CPU_FREQ_26_API
bool
depends on CPU_FREQ && !CPU_FREQ_24_API
default y
config X86_POWERNOW_K6 config X86_POWERNOW_K6
tristate "AMD Mobile K6-2/K6-3 PowerNow!" tristate "AMD Mobile K6-2/K6-3 PowerNow!"
depends on CPU_FREQ depends on CPU_FREQ
...@@ -562,7 +555,7 @@ config X86_P4_CLOCKMOD ...@@ -562,7 +555,7 @@ config X86_P4_CLOCKMOD
config X86_LONGRUN config X86_LONGRUN
tristate "Transmeta LongRun" tristate "Transmeta LongRun"
depends on CPU_FREQ && !CPU_FREQ_24_API depends on CPU_FREQ
help help
This adds the CPUFreq driver for Transmeta Crusoe processors which This adds the CPUFreq driver for Transmeta Crusoe processors which
support LongRun. support LongRun.
......
...@@ -251,6 +251,11 @@ static int __init longrun_init(void) ...@@ -251,6 +251,11 @@ static int __init longrun_init(void)
longrun_get_policy(&driver->policy[0]); longrun_get_policy(&driver->policy[0]);
#ifdef CONFIG_CPU_FREQ_24_API
driver->cpu_min_freq = longrun_low_freq;
driver->cpu_cur_freq[0] = longrun_high_freq; /* dummy value */
#endif
driver->verify = &longrun_verify_policy; driver->verify = &longrun_verify_policy;
driver->setpolicy = &longrun_set_policy; driver->setpolicy = &longrun_set_policy;
result = cpufreq_register(driver); result = cpufreq_register(driver);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* (C) 2002 Dominik Brodowski <linux@brodo.de> * (C) 2002 Dominik Brodowski <linux@brodo.de>
* *
* *
* $Id: cpufreq.h,v 1.26 2002/09/21 09:05:29 db Exp $ * $Id: cpufreq.h,v 1.27 2002/10/08 14:54:23 db Exp $
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -148,11 +148,9 @@ static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, u ...@@ -148,11 +148,9 @@ static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, u
int cpufreq_set_policy(struct cpufreq_policy *policy); int cpufreq_set_policy(struct cpufreq_policy *policy);
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
#ifdef CONFIG_CPU_FREQ_26_API
#ifdef CONFIG_PM #ifdef CONFIG_PM
int cpufreq_restore(void); int cpufreq_restore(void);
#endif #endif
#endif
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
...@@ -160,9 +158,6 @@ int cpufreq_restore(void); ...@@ -160,9 +158,6 @@ int cpufreq_restore(void);
* CPUFREQ 2.4. INTERFACE * * CPUFREQ 2.4. INTERFACE *
*********************************************************************/ *********************************************************************/
int cpufreq_setmax(unsigned int cpu); int cpufreq_setmax(unsigned int cpu);
#ifdef CONFIG_PM
int cpufreq_restore(void);
#endif
int cpufreq_set(unsigned int kHz, unsigned int cpu); int cpufreq_set(unsigned int kHz, unsigned int cpu);
unsigned int cpufreq_get(unsigned int cpu); unsigned int cpufreq_get(unsigned int cpu);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Copyright (C) 2001 Russell King * Copyright (C) 2001 Russell King
* (C) 2002 Dominik Brodowski <linux@brodo.de> * (C) 2002 Dominik Brodowski <linux@brodo.de>
* *
* $Id: cpufreq.c,v 1.43 2002/09/21 09:05:29 db Exp $ * $Id: cpufreq.c,v 1.45 2002/10/08 14:54:23 db Exp $
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -21,13 +21,10 @@ ...@@ -21,13 +21,10 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/proc_fs.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#ifdef CONFIG_CPU_FREQ_26_API
#include <linux/proc_fs.h>
#endif
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
#include <linux/sysctl.h> #include <linux/sysctl.h>
#endif #endif
...@@ -200,7 +197,6 @@ static int __init cpufreq_setup(char *str) ...@@ -200,7 +197,6 @@ static int __init cpufreq_setup(char *str)
__setup("cpufreq=", cpufreq_setup); __setup("cpufreq=", cpufreq_setup);
#ifdef CONFIG_CPU_FREQ_26_API
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
/** /**
...@@ -335,7 +331,6 @@ static void cpufreq_proc_exit (void) ...@@ -335,7 +331,6 @@ static void cpufreq_proc_exit (void)
return; return;
} }
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
#endif /* CONFIG_CPU_FREQ_26_API */
...@@ -344,10 +339,6 @@ static void cpufreq_proc_exit (void) ...@@ -344,10 +339,6 @@ static void cpufreq_proc_exit (void)
*********************************************************************/ *********************************************************************/
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
/* NOTE #1: when you use this API, you may not use any other calls,
* except cpufreq_[un]register_notifier, of course.
*/
/** /**
* cpufreq_set - set the CPU frequency * cpufreq_set - set the CPU frequency
* @freq: target frequency in kHz * @freq: target frequency in kHz
...@@ -879,7 +870,7 @@ int cpufreq_set_policy(struct cpufreq_policy *policy) ...@@ -879,7 +870,7 @@ int cpufreq_set_policy(struct cpufreq_policy *policy)
cpufreq_driver->policy[policy->cpu].max = policy->max; cpufreq_driver->policy[policy->cpu].max = policy->max;
cpufreq_driver->policy[policy->cpu].policy = policy->policy; cpufreq_driver->policy[policy->cpu].policy = policy->policy;
} }
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
if (policy->cpu == CPUFREQ_ALL_CPUS) { if (policy->cpu == CPUFREQ_ALL_CPUS) {
for (i=0;i<NR_CPUS;i++) for (i=0;i<NR_CPUS;i++)
...@@ -945,6 +936,14 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) ...@@ -945,6 +936,14 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
case CPUFREQ_POSTCHANGE: case CPUFREQ_POSTCHANGE:
adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_POSTCHANGE, freqs); notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_POSTCHANGE, freqs);
#ifdef CONFIG_CPU_FREQ_24_API
if (freqs->cpu == CPUFREQ_ALL_CPUS) {
int i;
for (i=0;i<NR_CPUS;i++)
cpu_cur_freq[i] = freqs->new;
} else
cpu_cur_freq[freqs->cpu] = freqs->new;
#endif
break; break;
} }
up(&cpufreq_notifier_sem); up(&cpufreq_notifier_sem);
...@@ -992,9 +991,7 @@ int cpufreq_register(struct cpufreq_driver *driver_data) ...@@ -992,9 +991,7 @@ int cpufreq_register(struct cpufreq_driver *driver_data)
ret = cpufreq_set_policy(&default_policy); ret = cpufreq_set_policy(&default_policy);
#ifdef CONFIG_CPU_FREQ_26_API
cpufreq_proc_init(); cpufreq_proc_init();
#endif
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
down(&cpufreq_driver_sem); down(&cpufreq_driver_sem);
...@@ -1042,9 +1039,7 @@ int cpufreq_unregister(void) ...@@ -1042,9 +1039,7 @@ int cpufreq_unregister(void)
up(&cpufreq_driver_sem); up(&cpufreq_driver_sem);
#ifdef CONFIG_CPU_FREQ_26_API
cpufreq_proc_exit(); cpufreq_proc_exit();
#endif
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
cpufreq_sysctl_exit(); cpufreq_sysctl_exit();
...@@ -1086,13 +1081,7 @@ int cpufreq_restore(void) ...@@ -1086,13 +1081,7 @@ int cpufreq_restore(void)
policy.cpu = i; policy.cpu = i;
up(&cpufreq_driver_sem); up(&cpufreq_driver_sem);
#ifdef CONFIG_CPU_FREQ_26_API
cpufreq_set_policy(&policy); cpufreq_set_policy(&policy);
#endif
#ifdef CONFIG_CPU_FREQ_24_API
cpufreq_set(cpu_cur_freq[i], i);
#endif
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment