#include <linux/capability.h>
#include <linux/ctype.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/hrtimer.h>
#include <linux/list.h>
#include <linux/rbtree.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include "power.h"
static DEFINE_MUTEX(wakelocks_lock);
struct wakelock { … };
static struct rb_root wakelocks_tree = …;
ssize_t pm_show_wakelocks(char *buf, bool show_active)
{ … }
#if CONFIG_PM_WAKELOCKS_LIMIT > 0
static unsigned int number_of_wakelocks;
static inline bool wakelocks_limit_exceeded(void)
{ … }
static inline void increment_wakelocks_number(void)
{ … }
static inline void decrement_wakelocks_number(void)
{ … }
#else
static inline bool wakelocks_limit_exceeded(void) { return false; }
static inline void increment_wakelocks_number(void) {}
static inline void decrement_wakelocks_number(void) {}
#endif
#ifdef CONFIG_PM_WAKELOCKS_GC
#define WL_GC_COUNT_MAX …
#define WL_GC_TIME_SEC …
static void __wakelocks_gc(struct work_struct *work);
static LIST_HEAD(wakelocks_lru_list);
static DECLARE_WORK(wakelock_work, __wakelocks_gc);
static unsigned int wakelocks_gc_count;
static inline void wakelocks_lru_add(struct wakelock *wl)
{ … }
static inline void wakelocks_lru_most_recent(struct wakelock *wl)
{ … }
static void __wakelocks_gc(struct work_struct *work)
{ … }
static void wakelocks_gc(void)
{ … }
#else
static inline void wakelocks_lru_add(struct wakelock *wl) {}
static inline void wakelocks_lru_most_recent(struct wakelock *wl) {}
static inline void wakelocks_gc(void) {}
#endif
static struct wakelock *wakelock_lookup_add(const char *name, size_t len,
bool add_if_not_found)
{ … }
int pm_wake_lock(const char *buf)
{ … }
int pm_wake_unlock(const char *buf)
{ … }