blob: 7416b16287de040190d28db95f11cc76c4650b87 [file] [log] [blame]
Rafael J. Wysocki34c2f652017-08-23 23:21:07 +02001/*
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
11static 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
Rafael J. Wysocki1b39e3f2017-08-29 03:14:37 +020024void cpuidle_poll_state_init(struct cpuidle_driver *drv)
Rafael J. Wysocki34c2f652017-08-23 23:21:07 +020025{
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}
Rafael J. Wysocki1b39e3f2017-08-29 03:14:37 +020037EXPORT_SYMBOL_GPL(cpuidle_poll_state_init);