Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[sfrench/cifs-2.6.git] / drivers / cpuidle / poll_state.c
1 /*
2  * poll_state.c - Polling idle state
3  *
4  * This file is released under the GPLv2.
5  */
6
7 #include <linux/cpuidle.h>
8 #include <linux/sched.h>
9 #include <linux/sched/idle.h>
10
11 static int __cpuidle poll_idle(struct cpuidle_device *dev,
12                                struct cpuidle_driver *drv, int index)
13 {
14         local_irq_enable();
15         if (!current_set_polling_and_test()) {
16                 while (!need_resched())
17                         cpu_relax();
18         }
19         current_clr_polling();
20
21         return index;
22 }
23
24 void cpuidle_poll_state_init(struct cpuidle_driver *drv)
25 {
26         struct cpuidle_state *state = &drv->states[0];
27
28         snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
29         snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
30         state->exit_latency = 0;
31         state->target_residency = 0;
32         state->power_usage = -1;
33         state->enter = poll_idle;
34         state->disabled = false;
35         state->flags = CPUIDLE_FLAG_POLLING;
36 }
37 EXPORT_SYMBOL_GPL(cpuidle_poll_state_init);