Skip to content

Commit

Permalink
PM: Add convenience macro to make switching to dev_pm_ops less error-…
Browse files Browse the repository at this point in the history
…prone

In a number of cases, the .suspend, .freeze, .poweroff and .resume,
.thaw, .restore functions are identical. However, they all need to be
assigned to avoid regressionsm as the previous code called .suspend
resp. .resume in all those cases. SIMPLE_DEV_PM_OPS helps to deal
with this case.

[rjw: Changed the name of the macro and added the comment explaining its
 purpose.]

Signed-off-by: Albin Tonnerre <albin.tonnerre@free-electrons.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Albin Tonnerre authored and Rafael J. Wysocki committed Sep 14, 2009
1 parent 8dd2b42 commit 9d62ec6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/linux/pm.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@ struct dev_pm_ops {
int (*runtime_idle)(struct device *dev);
};

/*
* Use this if you want to use the same suspend and resume callbacks for suspend
* to RAM and hibernation.
*/
#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
struct dev_pm_ops name = { \
.suspend = suspend_fn, \
.resume = resume_fn, \
.freeze = suspend_fn, \
.thaw = resume_fn, \
.poweroff = suspend_fn, \
.restore = resume_fn, \
}

/**
* PM_EVENT_ messages
*
Expand Down

0 comments on commit 9d62ec6

Please sign in to comment.