Skip to content

Commit

Permalink
PM: pm_wakeup - switch to using bool
Browse files Browse the repository at this point in the history
Also change couple of stubs implemented as macros in !CONFIG_PM case
in statinc inline functions to provide proper typechecking of
arguments regardless of config.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Dmitry Torokhov authored and Rafael J. Wysocki committed May 10, 2010
1 parent 94b849a commit 228c54e
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions include/linux/pm_wakeup.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,53 +25,63 @@
# error "please don't include this file directly"
#endif

#include <linux/types.h>

#ifdef CONFIG_PM

/* changes to device_may_wakeup take effect on the next pm state change.
* by default, devices should wakeup if they can.
*/
static inline void device_init_wakeup(struct device *dev, int val)
static inline void device_init_wakeup(struct device *dev, bool val)
{
dev->power.can_wakeup = dev->power.should_wakeup = !!val;
dev->power.can_wakeup = dev->power.should_wakeup = val;
}

static inline void device_set_wakeup_capable(struct device *dev, int val)
static inline void device_set_wakeup_capable(struct device *dev, bool capable)
{
dev->power.can_wakeup = !!val;
dev->power.can_wakeup = capable;
}

static inline int device_can_wakeup(struct device *dev)
static inline bool device_can_wakeup(struct device *dev)
{
return dev->power.can_wakeup;
}

static inline void device_set_wakeup_enable(struct device *dev, int val)
static inline void device_set_wakeup_enable(struct device *dev, bool enable)
{
dev->power.should_wakeup = !!val;
dev->power.should_wakeup = enable;
}

static inline int device_may_wakeup(struct device *dev)
static inline bool device_may_wakeup(struct device *dev)
{
return dev->power.can_wakeup && dev->power.should_wakeup;
}

#else /* !CONFIG_PM */

/* For some reason the next two routines work even without CONFIG_PM */
static inline void device_init_wakeup(struct device *dev, int val)
static inline void device_init_wakeup(struct device *dev, bool val)
{
dev->power.can_wakeup = !!val;
dev->power.can_wakeup = val;
}

static inline void device_set_wakeup_capable(struct device *dev, int val) { }
static inline void device_set_wakeup_capable(struct device *dev, bool capable)
{
}

static inline int device_can_wakeup(struct device *dev)
static inline bool device_can_wakeup(struct device *dev)
{
return dev->power.can_wakeup;
}

#define device_set_wakeup_enable(dev, val) do {} while (0)
#define device_may_wakeup(dev) 0
static inline void device_set_wakeup_enable(struct device *dev, bool enable)
{
}

static inline bool device_may_wakeup(struct device *dev)
{
return false;
}

#endif /* !CONFIG_PM */

Expand Down

0 comments on commit 228c54e

Please sign in to comment.