2 * driver.c - driver support
4 * (C) 2006-2007 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
5 * Shaohua Li <shaohua.li@intel.com>
6 * Adam Belay <abelay@novell.com>
8 * This code is licenced under the GPL.
11 #include <linux/mutex.h>
12 #include <linux/module.h>
13 #include <linux/cpuidle.h>
17 static struct cpuidle_driver
*cpuidle_curr_driver
;
18 DEFINE_SPINLOCK(cpuidle_driver_lock
);
21 * cpuidle_register_driver - registers a driver
24 int cpuidle_register_driver(struct cpuidle_driver
*drv
)
29 spin_lock(&cpuidle_driver_lock
);
30 if (cpuidle_curr_driver
) {
31 spin_unlock(&cpuidle_driver_lock
);
34 cpuidle_curr_driver
= drv
;
35 spin_unlock(&cpuidle_driver_lock
);
40 EXPORT_SYMBOL_GPL(cpuidle_register_driver
);
43 * cpuidle_get_driver - return the current driver
45 struct cpuidle_driver
*cpuidle_get_driver(void)
47 return cpuidle_curr_driver
;
49 EXPORT_SYMBOL_GPL(cpuidle_get_driver
);
52 * cpuidle_unregister_driver - unregisters a driver
55 void cpuidle_unregister_driver(struct cpuidle_driver
*drv
)
57 if (drv
!= cpuidle_curr_driver
) {
58 WARN(1, "invalid cpuidle_unregister_driver(%s)\n",
63 spin_lock(&cpuidle_driver_lock
);
64 cpuidle_curr_driver
= NULL
;
65 spin_unlock(&cpuidle_driver_lock
);
68 EXPORT_SYMBOL_GPL(cpuidle_unregister_driver
);