浏览代码

PM / sleep: Make suspend-to-idle-specific code depend on CONFIG_SUSPEND

Since idle_should_freeze() is defined to always return 'false'
for CONFIG_SUSPEND unset, all of the code depending on it in
cpuidle_idle_call() is not necessary in that case.

Make that code depend on CONFIG_SUSPEND too to avoid building it
when it is not going to be used.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Rafael J. Wysocki 10 年之前
父节点
当前提交
87e9b9f1d8
共有 4 个文件被更改,包括 22 次插入10 次删除
  1. 2 0
      drivers/cpuidle/cpuidle.c
  2. 10 6
      include/linux/cpuidle.h
  3. 8 4
      include/linux/tick.h
  4. 2 0
      kernel/time/tick-common.c

+ 2 - 0
drivers/cpuidle/cpuidle.c

@@ -92,6 +92,7 @@ static int find_deepest_state(struct cpuidle_driver *drv,
 	return ret;
 	return ret;
 }
 }
 
 
+#ifdef CONFIG_SUSPEND
 /**
 /**
  * cpuidle_find_deepest_state - Find the deepest available idle state.
  * cpuidle_find_deepest_state - Find the deepest available idle state.
  * @drv: cpuidle driver for the given CPU.
  * @drv: cpuidle driver for the given CPU.
@@ -145,6 +146,7 @@ int cpuidle_enter_freeze(struct cpuidle_driver *drv, struct cpuidle_device *dev)
 
 
 	return index;
 	return index;
 }
 }
+#endif /* CONFIG_SUSPEND */
 
 
 /**
 /**
  * cpuidle_enter_state - enter the state and update stats
  * cpuidle_enter_state - enter the state and update stats

+ 10 - 6
include/linux/cpuidle.h

@@ -151,10 +151,6 @@ extern void cpuidle_resume(void);
 extern int cpuidle_enable_device(struct cpuidle_device *dev);
 extern int cpuidle_enable_device(struct cpuidle_device *dev);
 extern void cpuidle_disable_device(struct cpuidle_device *dev);
 extern void cpuidle_disable_device(struct cpuidle_device *dev);
 extern int cpuidle_play_dead(void);
 extern int cpuidle_play_dead(void);
-extern int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
-				      struct cpuidle_device *dev);
-extern int cpuidle_enter_freeze(struct cpuidle_driver *drv,
-				struct cpuidle_device *dev);
 
 
 extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev);
 extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev);
 #else
 #else
@@ -190,14 +186,22 @@ static inline int cpuidle_enable_device(struct cpuidle_device *dev)
 {return -ENODEV; }
 {return -ENODEV; }
 static inline void cpuidle_disable_device(struct cpuidle_device *dev) { }
 static inline void cpuidle_disable_device(struct cpuidle_device *dev) { }
 static inline int cpuidle_play_dead(void) {return -ENODEV; }
 static inline int cpuidle_play_dead(void) {return -ENODEV; }
+static inline struct cpuidle_driver *cpuidle_get_cpu_driver(
+	struct cpuidle_device *dev) {return NULL; }
+#endif
+
+#if defined(CONFIG_CPU_IDLE) && defined(CONFIG_SUSPEND)
+extern int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
+				      struct cpuidle_device *dev);
+extern int cpuidle_enter_freeze(struct cpuidle_driver *drv,
+				struct cpuidle_device *dev);
+#else
 static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
 static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv,
 					     struct cpuidle_device *dev)
 					     struct cpuidle_device *dev)
 {return -ENODEV; }
 {return -ENODEV; }
 static inline int cpuidle_enter_freeze(struct cpuidle_driver *drv,
 static inline int cpuidle_enter_freeze(struct cpuidle_driver *drv,
 				       struct cpuidle_device *dev)
 				       struct cpuidle_device *dev)
 {return -ENODEV; }
 {return -ENODEV; }
-static inline struct cpuidle_driver *cpuidle_get_cpu_driver(
-	struct cpuidle_device *dev) {return NULL; }
 #endif
 #endif
 
 
 #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
 #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED

+ 8 - 4
include/linux/tick.h

@@ -13,8 +13,6 @@
 
 
 #ifdef CONFIG_GENERIC_CLOCKEVENTS
 #ifdef CONFIG_GENERIC_CLOCKEVENTS
 extern void __init tick_init(void);
 extern void __init tick_init(void);
-extern void tick_freeze(void);
-extern void tick_unfreeze(void);
 /* Should be core only, but ARM BL switcher requires it */
 /* Should be core only, but ARM BL switcher requires it */
 extern void tick_suspend_local(void);
 extern void tick_suspend_local(void);
 /* Should be core only, but XEN resume magic and ARM BL switcher require it */
 /* Should be core only, but XEN resume magic and ARM BL switcher require it */
@@ -23,14 +21,20 @@ extern void tick_handover_do_timer(void);
 extern void tick_cleanup_dead_cpu(int cpu);
 extern void tick_cleanup_dead_cpu(int cpu);
 #else /* CONFIG_GENERIC_CLOCKEVENTS */
 #else /* CONFIG_GENERIC_CLOCKEVENTS */
 static inline void tick_init(void) { }
 static inline void tick_init(void) { }
-static inline void tick_freeze(void) { }
-static inline void tick_unfreeze(void) { }
 static inline void tick_suspend_local(void) { }
 static inline void tick_suspend_local(void) { }
 static inline void tick_resume_local(void) { }
 static inline void tick_resume_local(void) { }
 static inline void tick_handover_do_timer(void) { }
 static inline void tick_handover_do_timer(void) { }
 static inline void tick_cleanup_dead_cpu(int cpu) { }
 static inline void tick_cleanup_dead_cpu(int cpu) { }
 #endif /* !CONFIG_GENERIC_CLOCKEVENTS */
 #endif /* !CONFIG_GENERIC_CLOCKEVENTS */
 
 
+#if defined(CONFIG_GENERIC_CLOCKEVENTS) && defined(CONFIG_SUSPEND)
+extern void tick_freeze(void);
+extern void tick_unfreeze(void);
+#else
+static inline void tick_freeze(void) { }
+static inline void tick_unfreeze(void) { }
+#endif
+
 #ifdef CONFIG_TICK_ONESHOT
 #ifdef CONFIG_TICK_ONESHOT
 extern void tick_irq_enter(void);
 extern void tick_irq_enter(void);
 #  ifndef arch_needs_cpu
 #  ifndef arch_needs_cpu

+ 2 - 0
kernel/time/tick-common.c

@@ -441,6 +441,7 @@ void tick_resume(void)
 	tick_resume_local();
 	tick_resume_local();
 }
 }
 
 
+#ifdef CONFIG_SUSPEND
 static DEFINE_RAW_SPINLOCK(tick_freeze_lock);
 static DEFINE_RAW_SPINLOCK(tick_freeze_lock);
 static unsigned int tick_freeze_depth;
 static unsigned int tick_freeze_depth;
 
 
@@ -494,6 +495,7 @@ void tick_unfreeze(void)
 
 
 	raw_spin_unlock(&tick_freeze_lock);
 	raw_spin_unlock(&tick_freeze_lock);
 }
 }
+#endif /* CONFIG_SUSPEND */
 
 
 /**
 /**
  * tick_init - initialize the tick control
  * tick_init - initialize the tick control