Source
/*
* driver.c - driver support
*
* (C) 2006-2007 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
* Shaohua Li <shaohua.li@intel.com>
* Adam Belay <abelay@novell.com>
*
* This code is licenced under the GPL.
*/
DEFINE_SPINLOCK(cpuidle_driver_lock);
static DEFINE_PER_CPU(struct cpuidle_driver *, cpuidle_drivers);
/**
* __cpuidle_get_cpu_driver - return the cpuidle driver tied to a CPU.
* @cpu: the CPU handled by the driver
*
* Returns a pointer to struct cpuidle_driver or NULL if no driver has been
* registered for @cpu.
*/
static struct cpuidle_driver *__cpuidle_get_cpu_driver(int cpu)
{
return per_cpu(cpuidle_drivers, cpu);
}
/**
* __cpuidle_unset_driver - unset per CPU driver variables.
* @drv: a valid pointer to a struct cpuidle_driver
*
* For each CPU in the driver's CPU mask, unset the registered driver per CPU
* variable. If @drv is different from the registered driver, the corresponding
* variable is not cleared.
*/
static inline void __cpuidle_unset_driver(struct cpuidle_driver *drv)
{
int cpu;
for_each_cpu(cpu, drv->cpumask) {
if (drv != __cpuidle_get_cpu_driver(cpu))
continue;
per_cpu(cpuidle_drivers, cpu) = NULL;
}
}
/**
* __cpuidle_set_driver - set per CPU driver variables for the given driver.
* @drv: a valid pointer to a struct cpuidle_driver