Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Lukasz Luba and committed by
MyungJoo Ham
59031956 83f8ca45

+50
+44
drivers/devfreq/devfreq.c
··· 935 935 EXPORT_SYMBOL(devfreq_resume_device); 936 936 937 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 + 981 + /** 938 982 * devfreq_add_governor() - Add devfreq governor 939 983 * @governor: the devfreq governor to be added 940 984 */
+6
include/linux/devfreq.h
··· 205 205 extern int devfreq_suspend_device(struct devfreq *devfreq); 206 206 extern int devfreq_resume_device(struct devfreq *devfreq); 207 207 208 + extern void devfreq_suspend(void); 209 + extern void devfreq_resume(void); 210 + 208 211 /** 209 212 * update_devfreq() - Reevaluate the device and configure frequency 210 213 * @devfreq: the devfreq device ··· 333 330 { 334 331 return 0; 335 332 } 333 + 334 + static inline void devfreq_suspend(void) {} 335 + static inline void devfreq_resume(void) {} 336 336 337 337 static inline struct dev_pm_opp *devfreq_recommended_opp(struct device *dev, 338 338 unsigned long *freq, u32 flags)