summaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.com>2016-11-28 16:44:49 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-11-29 17:34:10 -0500
commit14f3f7d8cbceedab17f16cf301414fa3384117fe (patch)
tree599f73fb6004a4deade4a1d5ba42e45a20e2b3e3 /drivers/thermal
parentc1de45ca831acee9b72c9320dde447edafadb43f (diff)
thermal/intel_powerclamp: Remove duplicated code that starts the kthread
This patch removes code duplication. It does not modify the functionality. Signed-off-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/intel_powerclamp.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c
index 0e4dc0afcfd2..63657d193db5 100644
--- a/drivers/thermal/intel_powerclamp.c
+++ b/drivers/thermal/intel_powerclamp.c
@@ -508,10 +508,27 @@ static void poll_pkg_cstate(struct work_struct *dummy)
508 schedule_delayed_work(&poll_pkg_cstate_work, HZ); 508 schedule_delayed_work(&poll_pkg_cstate_work, HZ);
509} 509}
510 510
511static void start_power_clamp_thread(unsigned long cpu)
512{
513 struct task_struct **p = per_cpu_ptr(powerclamp_thread, cpu);
514 struct task_struct *thread;
515
516 thread = kthread_create_on_node(clamp_thread,
517 (void *) cpu,
518 cpu_to_node(cpu),
519 "kidle_inject/%ld", cpu);
520 if (IS_ERR(thread))
521 return;
522
523 /* bind to cpu here */
524 kthread_bind(thread, cpu);
525 wake_up_process(thread);
526 *p = thread;
527}
528
511static int start_power_clamp(void) 529static int start_power_clamp(void)
512{ 530{
513 unsigned long cpu; 531 unsigned long cpu;
514 struct task_struct *thread;
515 532
516 set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO - 1); 533 set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO - 1);
517 /* prevent cpu hotplug */ 534 /* prevent cpu hotplug */
@@ -527,20 +544,7 @@ static int start_power_clamp(void)
527 544
528 /* start one thread per online cpu */ 545 /* start one thread per online cpu */
529 for_each_online_cpu(cpu) { 546 for_each_online_cpu(cpu) {
530 struct task_struct **p = 547 start_power_clamp_thread(cpu);
531 per_cpu_ptr(powerclamp_thread, cpu);
532
533 thread = kthread_create_on_node(clamp_thread,
534 (void *) cpu,
535 cpu_to_node(cpu),
536 "kidle_inject/%ld", cpu);
537 /* bind to cpu here */
538 if (likely(!IS_ERR(thread))) {
539 kthread_bind(thread, cpu);
540 wake_up_process(thread);
541 *p = thread;
542 }
543
544 } 548 }
545 put_online_cpus(); 549 put_online_cpus();
546 550
@@ -572,7 +576,6 @@ static int powerclamp_cpu_callback(struct notifier_block *nfb,
572 unsigned long action, void *hcpu) 576 unsigned long action, void *hcpu)
573{ 577{
574 unsigned long cpu = (unsigned long)hcpu; 578 unsigned long cpu = (unsigned long)hcpu;
575 struct task_struct *thread;
576 struct task_struct **percpu_thread = 579 struct task_struct **percpu_thread =
577 per_cpu_ptr(powerclamp_thread, cpu); 580 per_cpu_ptr(powerclamp_thread, cpu);
578 581
@@ -581,15 +584,7 @@ static int powerclamp_cpu_callback(struct notifier_block *nfb,
581 584
582 switch (action) { 585 switch (action) {
583 case CPU_ONLINE: 586 case CPU_ONLINE:
584 thread = kthread_create_on_node(clamp_thread, 587 start_power_clamp_thread(cpu);
585 (void *) cpu,
586 cpu_to_node(cpu),
587 "kidle_inject/%lu", cpu);
588 if (likely(!IS_ERR(thread))) {
589 kthread_bind(thread, cpu);
590 wake_up_process(thread);
591 *percpu_thread = thread;
592 }
593 /* prefer BSP as controlling CPU */ 588 /* prefer BSP as controlling CPU */
594 if (cpu == 0) { 589 if (cpu == 0) {
595 control_cpu = 0; 590 control_cpu = 0;