Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312704
b: refs/heads/master
c: 6e797a0
h: refs/heads/master
v: v3
  • Loading branch information
Rafael J. Wysocki committed Jul 3, 2012
1 parent 95e4bc1 commit 7afa9a9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dc7fd275ae60ef8edf952aff2a62462f5d892fd4
refs/heads/master: 6e797a078824b30afbfae6cc4b1c2b21c51761ef
29 changes: 28 additions & 1 deletion trunk/drivers/cpuidle/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

static struct cpuidle_driver *cpuidle_curr_driver;
DEFINE_SPINLOCK(cpuidle_driver_lock);
int cpuidle_driver_refcount;

static void __cpuidle_register_driver(struct cpuidle_driver *drv)
{
Expand Down Expand Up @@ -89,8 +90,34 @@ void cpuidle_unregister_driver(struct cpuidle_driver *drv)
}

spin_lock(&cpuidle_driver_lock);
cpuidle_curr_driver = NULL;

if (!WARN_ON(cpuidle_driver_refcount > 0))
cpuidle_curr_driver = NULL;

spin_unlock(&cpuidle_driver_lock);
}

EXPORT_SYMBOL_GPL(cpuidle_unregister_driver);

struct cpuidle_driver *cpuidle_driver_ref(void)
{
struct cpuidle_driver *drv;

spin_lock(&cpuidle_driver_lock);

drv = cpuidle_curr_driver;
cpuidle_driver_refcount++;

spin_unlock(&cpuidle_driver_lock);
return drv;
}

void cpuidle_driver_unref(void)
{
spin_lock(&cpuidle_driver_lock);

if (!WARN_ON(cpuidle_driver_refcount <= 0))
cpuidle_driver_refcount--;

spin_unlock(&cpuidle_driver_lock);
}
6 changes: 5 additions & 1 deletion trunk/include/linux/cpuidle.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ struct cpuidle_driver {
extern void disable_cpuidle(void);
extern int cpuidle_idle_call(void);
extern int cpuidle_register_driver(struct cpuidle_driver *drv);
struct cpuidle_driver *cpuidle_get_driver(void);
extern struct cpuidle_driver *cpuidle_get_driver(void);
extern struct cpuidle_driver *cpuidle_driver_ref(void);
extern void cpuidle_driver_unref(void);
extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
extern int cpuidle_register_device(struct cpuidle_device *dev);
extern void cpuidle_unregister_device(struct cpuidle_device *dev);
Expand All @@ -157,6 +159,8 @@ static inline int cpuidle_idle_call(void) { return -ENODEV; }
static inline int cpuidle_register_driver(struct cpuidle_driver *drv)
{return -ENODEV; }
static inline struct cpuidle_driver *cpuidle_get_driver(void) {return NULL; }
static inline struct cpuidle_driver *cpuidle_driver_ref(void) {return NULL; }
static inline void cpuidle_driver_unref(void) {}
static inline void cpuidle_unregister_driver(struct cpuidle_driver *drv) { }
static inline int cpuidle_register_device(struct cpuidle_device *dev)
{return -ENODEV; }
Expand Down

0 comments on commit 7afa9a9

Please sign in to comment.