aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2017-10-04 20:54:21 -0400
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>2017-11-05 06:53:14 -0500
commitfbc15e30400c9d927eda37445c78a7811a68e4a7 (patch)
treeaf6579ded2ec9eee78bfdf595c00b5e510f30bb5
parente4a18052bb99e25d2c0074981120b76638285c22 (diff)
platform/x86: intel_ips: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Moves timer structure off stack and into struct ips_driver. Cc: Darren Hart <dvhart@infradead.org> Cc: Andy Shevchenko <andy@infradead.org> Cc: platform-driver-x86@vger.kernel.org Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-rw-r--r--drivers/platform/x86/intel_ips.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c
index 680ab4fd7087..a0c95853fd3f 100644
--- a/drivers/platform/x86/intel_ips.c
+++ b/drivers/platform/x86/intel_ips.c
@@ -296,6 +296,7 @@ struct ips_driver {
296 struct task_struct *monitor; 296 struct task_struct *monitor;
297 struct task_struct *adjust; 297 struct task_struct *adjust;
298 struct dentry *debug_root; 298 struct dentry *debug_root;
299 struct timer_list timer;
299 300
300 /* Average CPU core temps (all averages in .01 degrees C for precision) */ 301 /* Average CPU core temps (all averages in .01 degrees C for precision) */
301 u16 ctv1_avg_temp; 302 u16 ctv1_avg_temp;
@@ -937,9 +938,10 @@ static u32 calc_avg_power(struct ips_driver *ips, u32 *array)
937 return avg; 938 return avg;
938} 939}
939 940
940static void monitor_timeout(unsigned long arg) 941static void monitor_timeout(struct timer_list *t)
941{ 942{
942 wake_up_process((struct task_struct *)arg); 943 struct ips_driver *ips = from_timer(ips, t, timer);
944 wake_up_process(ips->monitor);
943} 945}
944 946
945/** 947/**
@@ -956,7 +958,6 @@ static void monitor_timeout(unsigned long arg)
956static int ips_monitor(void *data) 958static int ips_monitor(void *data)
957{ 959{
958 struct ips_driver *ips = data; 960 struct ips_driver *ips = data;
959 struct timer_list timer;
960 unsigned long seqno_timestamp, expire, last_msecs, last_sample_period; 961 unsigned long seqno_timestamp, expire, last_msecs, last_sample_period;
961 int i; 962 int i;
962 u32 *cpu_samples, *mchp_samples, old_cpu_power; 963 u32 *cpu_samples, *mchp_samples, old_cpu_power;
@@ -1044,8 +1045,7 @@ static int ips_monitor(void *data)
1044 schedule_timeout_interruptible(msecs_to_jiffies(IPS_SAMPLE_PERIOD)); 1045 schedule_timeout_interruptible(msecs_to_jiffies(IPS_SAMPLE_PERIOD));
1045 last_sample_period = IPS_SAMPLE_PERIOD; 1046 last_sample_period = IPS_SAMPLE_PERIOD;
1046 1047
1047 setup_deferrable_timer_on_stack(&timer, monitor_timeout, 1048 timer_setup(&ips->timer, monitor_timeout, TIMER_DEFERRABLE);
1048 (unsigned long)current);
1049 do { 1049 do {
1050 u32 cpu_val, mch_val; 1050 u32 cpu_val, mch_val;
1051 u16 val; 1051 u16 val;
@@ -1103,7 +1103,7 @@ static int ips_monitor(void *data)
1103 expire = jiffies + msecs_to_jiffies(IPS_SAMPLE_PERIOD); 1103 expire = jiffies + msecs_to_jiffies(IPS_SAMPLE_PERIOD);
1104 1104
1105 __set_current_state(TASK_INTERRUPTIBLE); 1105 __set_current_state(TASK_INTERRUPTIBLE);
1106 mod_timer(&timer, expire); 1106 mod_timer(&ips->timer, expire);
1107 schedule(); 1107 schedule();
1108 1108
1109 /* Calculate actual sample period for power averaging */ 1109 /* Calculate actual sample period for power averaging */
@@ -1112,8 +1112,7 @@ static int ips_monitor(void *data)
1112 last_sample_period = 1; 1112 last_sample_period = 1;
1113 } while (!kthread_should_stop()); 1113 } while (!kthread_should_stop());
1114 1114
1115 del_timer_sync(&timer); 1115 del_timer_sync(&ips->timer);
1116 destroy_timer_on_stack(&timer);
1117 1116
1118 dev_dbg(ips->dev, "ips-monitor thread stopped\n"); 1117 dev_dbg(ips->dev, "ips-monitor thread stopped\n");
1119 1118