staging: rtl8188eu: rename HalSetBrateCfg() - style
[linux/fpc-iii.git] / drivers / cpuidle / poll_state.c
blob3f86d23c592ec0cdce4b6e8019a02256f4146d78
1 /*
2 * poll_state.c - Polling idle state
4 * This file is released under the GPLv2.
5 */
7 #include <linux/cpuidle.h>
8 #include <linux/sched.h>
9 #include <linux/sched/clock.h>
10 #include <linux/sched/idle.h>
12 #define POLL_IDLE_TIME_LIMIT (TICK_NSEC / 16)
13 #define POLL_IDLE_RELAX_COUNT 200
15 static int __cpuidle poll_idle(struct cpuidle_device *dev,
16 struct cpuidle_driver *drv, int index)
18 u64 time_start = local_clock();
20 local_irq_enable();
21 if (!current_set_polling_and_test()) {
22 unsigned int loop_count = 0;
24 while (!need_resched()) {
25 cpu_relax();
26 if (loop_count++ < POLL_IDLE_RELAX_COUNT)
27 continue;
29 loop_count = 0;
30 if (local_clock() - time_start > POLL_IDLE_TIME_LIMIT)
31 break;
34 current_clr_polling();
36 return index;
39 void cpuidle_poll_state_init(struct cpuidle_driver *drv)
41 struct cpuidle_state *state = &drv->states[0];
43 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
44 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
45 state->exit_latency = 0;
46 state->target_residency = 0;
47 state->power_usage = -1;
48 state->enter = poll_idle;
49 state->disabled = false;
50 state->flags = CPUIDLE_FLAG_POLLING;
52 EXPORT_SYMBOL_GPL(cpuidle_poll_state_init);