Skip to content

Commit 5903195

Browse files
Lukasz Lubamyungjoo
authored andcommitted
PM / devfreq: add devfreq_suspend/resume() functions
This patch adds implementation for global suspend/resume for devfreq framework. System suspend will next use these functions. Suggested-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de> Suggested-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
1 parent 83f8ca4 commit 5903195

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

drivers/devfreq/devfreq.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,50 @@ int devfreq_resume_device(struct devfreq *devfreq)
934934
}
935935
EXPORT_SYMBOL(devfreq_resume_device);
936936

937+
/**
938+
* devfreq_suspend() - Suspend devfreq governors and devices
939+
*
940+
* Called during system wide Suspend/Hibernate cycles for suspending governors
941+
* and devices preserving the state for resume. On some platforms the devfreq
942+
* device must have precise state (frequency) after resume in order to provide
943+
* fully operating setup.
944+
*/
945+
void devfreq_suspend(void)
946+
{
947+
struct devfreq *devfreq;
948+
int ret;
949+
950+
mutex_lock(&devfreq_list_lock);
951+
list_for_each_entry(devfreq, &devfreq_list, node) {
952+
ret = devfreq_suspend_device(devfreq);
953+
if (ret)
954+
dev_err(&devfreq->dev,
955+
"failed to suspend devfreq device\n");
956+
}
957+
mutex_unlock(&devfreq_list_lock);
958+
}
959+
960+
/**
961+
* devfreq_resume() - Resume devfreq governors and devices
962+
*
963+
* Called during system wide Suspend/Hibernate cycle for resuming governors and
964+
* devices that are suspended with devfreq_suspend().
965+
*/
966+
void devfreq_resume(void)
967+
{
968+
struct devfreq *devfreq;
969+
int ret;
970+
971+
mutex_lock(&devfreq_list_lock);
972+
list_for_each_entry(devfreq, &devfreq_list, node) {
973+
ret = devfreq_resume_device(devfreq);
974+
if (ret)
975+
dev_warn(&devfreq->dev,
976+
"failed to resume devfreq device\n");
977+
}
978+
mutex_unlock(&devfreq_list_lock);
979+
}
980+
937981
/**
938982
* devfreq_add_governor() - Add devfreq governor
939983
* @governor: the devfreq governor to be added

include/linux/devfreq.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ extern void devm_devfreq_remove_device(struct device *dev,
205205
extern int devfreq_suspend_device(struct devfreq *devfreq);
206206
extern int devfreq_resume_device(struct devfreq *devfreq);
207207

208+
extern void devfreq_suspend(void);
209+
extern void devfreq_resume(void);
210+
208211
/**
209212
* update_devfreq() - Reevaluate the device and configure frequency
210213
* @devfreq: the devfreq device
@@ -331,6 +334,9 @@ static inline int devfreq_resume_device(struct devfreq *devfreq)
331334
return 0;
332335
}
333336

337+
static inline void devfreq_suspend(void) {}
338+
static inline void devfreq_resume(void) {}
339+
334340
static inline struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
335341
unsigned long *freq, u32 flags)
336342
{

0 commit comments

Comments
 (0)