Blob Blame History Raw
From: Jeff Mahoney <jeffm@suse.com>
Subject: apm: Honor CONFIG_APM_CPU_IDLE=n
Patch-mainline: Submitted to x86@kernel.org, 13 Jun 2011

 Commit 06ae40c (x86 idle: EXPORT_SYMBOL(default_idle, pm_idle) only when
 APM demands it) removed the exports for pm_idle and default_idle unless
 CONFIG_APM_CPU_IDLE is defined.

 This caused build failures when CONFIG_APM=m and CONFIG_APM_CPU_IDLE=n,
 since the APM code was still using those unconditionally.

 This is due to CONFIG_APM_CPU_IDLE=y really only setting the default
 threshold to 95% as opposed to 100%. The user is still allowed to
 manually input thresholds < 100%, which would still invoke the cpu idle
 code.

 This patch makes the ability to adjust the threshold, which would invoke
 the cpu idle functionaltity, depend on CONFIG_APM_CPU_IDLE=y.

 I've only build tested it as I don't have hardware that makes use of APM.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 arch/x86/kernel/apm_32.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -375,10 +375,12 @@ static struct {
 	unsigned long	offset;
 	unsigned short	segment;
 } apm_bios_entry;
+#ifdef CONFIG_APM_CPU_IDLE
 static int clock_slowed;
 static int idle_threshold __read_mostly = DEFAULT_IDLE_THRESHOLD;
 static int idle_period __read_mostly = DEFAULT_IDLE_PERIOD;
 static int set_pm_idle;
+#endif
 static int suspends_pending;
 static int standbys_pending;
 static int ignore_sys_suspend;
@@ -807,6 +809,7 @@ static int set_system_power_state(u_shor
 	return set_power_state(APM_DEVICE_ALL, state);
 }
 
+#ifdef CONFIG_APM_CPU_IDLE
 /**
  *	apm_do_idle	-	perform power saving
  *
@@ -966,6 +969,7 @@ recalc:
 
 	local_irq_enable();
 }
+#endif
 
 /**
  *	apm_power_off	-	ask the BIOS to power off
@@ -1875,12 +1879,14 @@ static int __init apm_setup(char *str)
 		if ((strncmp(str, "bounce-interval=", 16) == 0) ||
 		    (strncmp(str, "bounce_interval=", 16) == 0))
 			bounce_interval = simple_strtol(str + 16, NULL, 0);
+#ifdef CONFIG_APM_CPU_IDLE
 		if ((strncmp(str, "idle-threshold=", 15) == 0) ||
 		    (strncmp(str, "idle_threshold=", 15) == 0))
 			idle_threshold = simple_strtol(str + 15, NULL, 0);
 		if ((strncmp(str, "idle-period=", 12) == 0) ||
 		    (strncmp(str, "idle_period=", 12) == 0))
 			idle_period = simple_strtol(str + 12, NULL, 0);
+#endif
 		invert = (strncmp(str, "no-", 3) == 0) ||
 			(strncmp(str, "no_", 3) == 0);
 		if (invert)
@@ -2383,6 +2389,7 @@ static int __init apm_init(void)
 	if (misc_register(&apm_device))
 		printk(KERN_WARNING "apm: Could not register misc device.\n");
 
+#ifdef CONFIG_APM_CPU_IDLE
 	if (HZ != 100)
 		idle_period = (idle_period * HZ) / 100;
 	if (idle_threshold < 100) {
@@ -2390,6 +2397,7 @@ static int __init apm_init(void)
 		pm_idle  = apm_cpu_idle;
 		set_pm_idle = 1;
 	}
+#endif
 
 	return 0;
 }
@@ -2398,6 +2406,7 @@ static void __exit apm_exit(void)
 {
 	int error;
 
+#ifdef CONFIG_APM_CPU_IDLE
 	if (set_pm_idle) {
 		pm_idle = original_pm_idle;
 		/*
@@ -2407,6 +2416,7 @@ static void __exit apm_exit(void)
 		 */
 		cpu_idle_wait();
 	}
+#endif
 	if (((apm_info.bios.flags & APM_BIOS_DISENGAGED) == 0)
 	    && (apm_info.connection_version > 0x0100)) {
 		error = apm_engage_power_management(APM_DEVICE_ALL, 0);
@@ -2443,12 +2453,14 @@ MODULE_PARM_DESC(broken_psr, "BIOS has a
 module_param(realmode_power_off, bool, 0444);
 MODULE_PARM_DESC(realmode_power_off,
 		"Switch to real mode before powering off");
+#ifdef CONFIG_APM_CPU_IDLE
 module_param(idle_threshold, int, 0444);
 MODULE_PARM_DESC(idle_threshold,
 	"System idle percentage above which to make APM BIOS idle calls");
 module_param(idle_period, int, 0444);
 MODULE_PARM_DESC(idle_period,
 	"Period (in sec/100) over which to caculate the idle percentage");
+#endif
 module_param(smp, bool, 0444);
 MODULE_PARM_DESC(smp,
 	"Set this to enable APM use on an SMP platform. Use with caution on older systems");