aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/cpuidle/cpuidle.c12
-rw-r--r--drivers/cpuidle/cpuidle.h1
-rw-r--r--drivers/cpuidle/driver.c11
-rw-r--r--drivers/cpuidle/sysfs.c5
-rw-r--r--include/linux/cpuidle.h2
5 files changed, 22 insertions, 9 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 12fdd3987a36..199488576a05 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -156,7 +156,7 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
156 156
157 if (dev->enabled) 157 if (dev->enabled)
158 return 0; 158 return 0;
159 if (!cpuidle_curr_driver || !cpuidle_curr_governor) 159 if (!cpuidle_get_driver() || !cpuidle_curr_governor)
160 return -EIO; 160 return -EIO;
161 if (!dev->state_count) 161 if (!dev->state_count)
162 return -EINVAL; 162 return -EINVAL;
@@ -207,7 +207,7 @@ void cpuidle_disable_device(struct cpuidle_device *dev)
207{ 207{
208 if (!dev->enabled) 208 if (!dev->enabled)
209 return; 209 return;
210 if (!cpuidle_curr_driver || !cpuidle_curr_governor) 210 if (!cpuidle_get_driver() || !cpuidle_curr_governor)
211 return; 211 return;
212 212
213 dev->enabled = 0; 213 dev->enabled = 0;
@@ -271,10 +271,11 @@ static int __cpuidle_register_device(struct cpuidle_device *dev)
271{ 271{
272 int ret; 272 int ret;
273 struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu); 273 struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu);
274 struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver();
274 275
275 if (!sys_dev) 276 if (!sys_dev)
276 return -EINVAL; 277 return -EINVAL;
277 if (!try_module_get(cpuidle_curr_driver->owner)) 278 if (!try_module_get(cpuidle_driver->owner))
278 return -EINVAL; 279 return -EINVAL;
279 280
280 init_completion(&dev->kobj_unregister); 281 init_completion(&dev->kobj_unregister);
@@ -284,7 +285,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev)
284 per_cpu(cpuidle_devices, dev->cpu) = dev; 285 per_cpu(cpuidle_devices, dev->cpu) = dev;
285 list_add(&dev->device_list, &cpuidle_detected_devices); 286 list_add(&dev->device_list, &cpuidle_detected_devices);
286 if ((ret = cpuidle_add_sysfs(sys_dev))) { 287 if ((ret = cpuidle_add_sysfs(sys_dev))) {
287 module_put(cpuidle_curr_driver->owner); 288 module_put(cpuidle_driver->owner);
288 return ret; 289 return ret;
289 } 290 }
290 291
@@ -325,6 +326,7 @@ EXPORT_SYMBOL_GPL(cpuidle_register_device);
325void cpuidle_unregister_device(struct cpuidle_device *dev) 326void cpuidle_unregister_device(struct cpuidle_device *dev)
326{ 327{
327 struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu); 328 struct sys_device *sys_dev = get_cpu_sysdev((unsigned long)dev->cpu);
329 struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver();
328 330
329 if (dev->registered == 0) 331 if (dev->registered == 0)
330 return; 332 return;
@@ -340,7 +342,7 @@ void cpuidle_unregister_device(struct cpuidle_device *dev)
340 342
341 cpuidle_resume_and_unlock(); 343 cpuidle_resume_and_unlock();
342 344
343 module_put(cpuidle_curr_driver->owner); 345 module_put(cpuidle_driver->owner);
344} 346}
345 347
346EXPORT_SYMBOL_GPL(cpuidle_unregister_device); 348EXPORT_SYMBOL_GPL(cpuidle_unregister_device);
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
index 9476ba33ee2c..33e50d556f17 100644
--- a/drivers/cpuidle/cpuidle.h
+++ b/drivers/cpuidle/cpuidle.h
@@ -9,7 +9,6 @@
9 9
10/* For internal use only */ 10/* For internal use only */
11extern struct cpuidle_governor *cpuidle_curr_governor; 11extern struct cpuidle_governor *cpuidle_curr_governor;
12extern struct cpuidle_driver *cpuidle_curr_driver;
13extern struct list_head cpuidle_governors; 12extern struct list_head cpuidle_governors;
14extern struct list_head cpuidle_detected_devices; 13extern struct list_head cpuidle_detected_devices;
15extern struct mutex cpuidle_lock; 14extern struct mutex cpuidle_lock;
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
index 826b5c0aa12b..fd1601e3d125 100644
--- a/drivers/cpuidle/driver.c
+++ b/drivers/cpuidle/driver.c
@@ -14,7 +14,7 @@
14 14
15#include "cpuidle.h" 15#include "cpuidle.h"
16 16
17struct cpuidle_driver *cpuidle_curr_driver; 17static struct cpuidle_driver *cpuidle_curr_driver;
18DEFINE_SPINLOCK(cpuidle_driver_lock); 18DEFINE_SPINLOCK(cpuidle_driver_lock);
19 19
20/** 20/**
@@ -40,6 +40,15 @@ int cpuidle_register_driver(struct cpuidle_driver *drv)
40EXPORT_SYMBOL_GPL(cpuidle_register_driver); 40EXPORT_SYMBOL_GPL(cpuidle_register_driver);
41 41
42/** 42/**
43 * cpuidle_get_driver - return the current driver
44 */
45struct cpuidle_driver *cpuidle_get_driver(void)
46{
47 return cpuidle_curr_driver;
48}
49EXPORT_SYMBOL_GPL(cpuidle_get_driver);
50
51/**
43 * cpuidle_unregister_driver - unregisters a driver 52 * cpuidle_unregister_driver - unregisters a driver
44 * @drv: the driver 53 * @drv: the driver
45 */ 54 */
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 0ba9c8b8ee74..0310ffaec9df 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -47,10 +47,11 @@ static ssize_t show_current_driver(struct sysdev_class *class,
47 char *buf) 47 char *buf)
48{ 48{
49 ssize_t ret; 49 ssize_t ret;
50 struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver();
50 51
51 spin_lock(&cpuidle_driver_lock); 52 spin_lock(&cpuidle_driver_lock);
52 if (cpuidle_curr_driver) 53 if (cpuidle_driver)
53 ret = sprintf(buf, "%s\n", cpuidle_curr_driver->name); 54 ret = sprintf(buf, "%s\n", cpuidle_driver->name);
54 else 55 else
55 ret = sprintf(buf, "none\n"); 56 ret = sprintf(buf, "none\n");
56 spin_unlock(&cpuidle_driver_lock); 57 spin_unlock(&cpuidle_driver_lock);
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index f5e6480dc16f..55215cce5005 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -125,6 +125,7 @@ struct cpuidle_driver {
125#ifdef CONFIG_CPU_IDLE 125#ifdef CONFIG_CPU_IDLE
126 126
127extern int cpuidle_register_driver(struct cpuidle_driver *drv); 127extern int cpuidle_register_driver(struct cpuidle_driver *drv);
128struct cpuidle_driver *cpuidle_get_driver(void);
128extern void cpuidle_unregister_driver(struct cpuidle_driver *drv); 129extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
129extern int cpuidle_register_device(struct cpuidle_device *dev); 130extern int cpuidle_register_device(struct cpuidle_device *dev);
130extern void cpuidle_unregister_device(struct cpuidle_device *dev); 131extern void cpuidle_unregister_device(struct cpuidle_device *dev);
@@ -138,6 +139,7 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev);
138 139
139static inline int cpuidle_register_driver(struct cpuidle_driver *drv) 140static inline int cpuidle_register_driver(struct cpuidle_driver *drv)
140{return -ENODEV; } 141{return -ENODEV; }
142static inline struct cpuidle_driver *cpuidle_get_driver(void) {return NULL; }
141static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { } 143static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { }
142static inline int cpuidle_register_device(struct cpuidle_device *dev) 144static inline int cpuidle_register_device(struct cpuidle_device *dev)
143{return -ENODEV; } 145{return -ENODEV; }