@@ -92,20 +92,24 @@ bool hibernation_available(void)
9292 */
9393void hibernation_set_ops (const struct platform_hibernation_ops * ops )
9494{
95+ unsigned int sleep_flags ;
96+
9597 if (ops && !(ops -> begin && ops -> end && ops -> pre_snapshot
9698 && ops -> prepare && ops -> finish && ops -> enter && ops -> pre_restore
9799 && ops -> restore_cleanup && ops -> leave )) {
98100 WARN_ON (1 );
99101 return ;
100102 }
101- lock_system_sleep ();
103+
104+ sleep_flags = lock_system_sleep ();
105+
102106 hibernation_ops = ops ;
103107 if (ops )
104108 hibernation_mode = HIBERNATION_PLATFORM ;
105109 else if (hibernation_mode == HIBERNATION_PLATFORM )
106110 hibernation_mode = HIBERNATION_SHUTDOWN ;
107111
108- unlock_system_sleep ();
112+ unlock_system_sleep (sleep_flags );
109113}
110114EXPORT_SYMBOL_GPL (hibernation_set_ops );
111115
@@ -713,14 +717,15 @@ static int load_image_and_restore(void)
713717int hibernate (void )
714718{
715719 bool snapshot_test = false;
720+ unsigned int sleep_flags ;
716721 int error ;
717722
718723 if (!hibernation_available ()) {
719724 pm_pr_dbg ("Hibernation not available.\n" );
720725 return - EPERM ;
721726 }
722727
723- lock_system_sleep ();
728+ sleep_flags = lock_system_sleep ();
724729 /* The snapshot device should not be opened while we're running */
725730 if (!hibernate_acquire ()) {
726731 error = - EBUSY ;
@@ -794,7 +799,7 @@ int hibernate(void)
794799 pm_restore_console ();
795800 hibernate_release ();
796801 Unlock :
797- unlock_system_sleep ();
802+ unlock_system_sleep (sleep_flags );
798803 pr_info ("hibernation exit\n" );
799804
800805 return error ;
@@ -809,9 +814,10 @@ int hibernate(void)
809814 */
810815int hibernate_quiet_exec (int (* func )(void * data ), void * data )
811816{
817+ unsigned int sleep_flags ;
812818 int error ;
813819
814- lock_system_sleep ();
820+ sleep_flags = lock_system_sleep ();
815821
816822 if (!hibernate_acquire ()) {
817823 error = - EBUSY ;
@@ -891,7 +897,7 @@ int hibernate_quiet_exec(int (*func)(void *data), void *data)
891897 hibernate_release ();
892898
893899unlock :
894- unlock_system_sleep ();
900+ unlock_system_sleep (sleep_flags );
895901
896902 return error ;
897903}
@@ -1100,19 +1106,20 @@ static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
11001106static ssize_t disk_store (struct kobject * kobj , struct kobj_attribute * attr ,
11011107 const char * buf , size_t n )
11021108{
1109+ int mode = HIBERNATION_INVALID ;
1110+ unsigned int sleep_flags ;
11031111 int error = 0 ;
1104- int i ;
11051112 int len ;
11061113 char * p ;
1107- int mode = HIBERNATION_INVALID ;
1114+ int i ;
11081115
11091116 if (!hibernation_available ())
11101117 return - EPERM ;
11111118
11121119 p = memchr (buf , '\n' , n );
11131120 len = p ? p - buf : n ;
11141121
1115- lock_system_sleep ();
1122+ sleep_flags = lock_system_sleep ();
11161123 for (i = HIBERNATION_FIRST ; i <= HIBERNATION_MAX ; i ++ ) {
11171124 if (len == strlen (hibernation_modes [i ])
11181125 && !strncmp (buf , hibernation_modes [i ], len )) {
@@ -1142,7 +1149,7 @@ static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr,
11421149 if (!error )
11431150 pm_pr_dbg ("Hibernation mode set to '%s'\n" ,
11441151 hibernation_modes [mode ]);
1145- unlock_system_sleep ();
1152+ unlock_system_sleep (sleep_flags );
11461153 return error ? error : n ;
11471154}
11481155
@@ -1158,9 +1165,10 @@ static ssize_t resume_show(struct kobject *kobj, struct kobj_attribute *attr,
11581165static ssize_t resume_store (struct kobject * kobj , struct kobj_attribute * attr ,
11591166 const char * buf , size_t n )
11601167{
1161- dev_t res ;
1168+ unsigned int sleep_flags ;
11621169 int len = n ;
11631170 char * name ;
1171+ dev_t res ;
11641172
11651173 if (len && buf [len - 1 ] == '\n' )
11661174 len -- ;
@@ -1173,9 +1181,10 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
11731181 if (!res )
11741182 return - EINVAL ;
11751183
1176- lock_system_sleep ();
1184+ sleep_flags = lock_system_sleep ();
11771185 swsusp_resume_device = res ;
1178- unlock_system_sleep ();
1186+ unlock_system_sleep (sleep_flags );
1187+
11791188 pm_pr_dbg ("Configured hibernation resume from disk to %u\n" ,
11801189 swsusp_resume_device );
11811190 noresume = 0 ;
0 commit comments