power: Rename enable/disable autosleep to init/exit 20/290520/5 accepted/tizen/unified/20230330.025600
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 28 Mar 2023 05:39:41 +0000 (14:39 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Wed, 29 Mar 2023 01:48:46 +0000 (10:48 +0900)
The functions below has been renamed:
 - power_enable_autosleep() => power_init_autosleep()
 - power_disable_autosleep() => power_exit_autosleep()

Those functions are only executed once, after booting done and before
shutting down. Therefore the name init/exit is much proper than
enable/disable. In addition, for the power_init_autosleep(), it has
changed to acquire mainlock before writing "mem" on the
/sys/power/autosleep. This prevents system from going suspend just
after the writing "mem" on /sys/power/autosleep.

Change-Id: Iafe5b4a3507ef983edaaa68735858c57577e24f8
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/power/power-off.c
src/power/power-suspend.c
src/power/power-suspend.h
src/power/power.c

index 9c454dd..a42261f 100644 (file)
@@ -311,7 +311,7 @@ void poweroff_prepare(uint64_t state)
        if (ret < 0)
                _W("Failed to set vconf value for power off status: %d", vconf_get_ext_errno());
 
-       power_disable_autosleep();
+       power_exit_autosleep();
        device_notify_once(DEVICE_NOTIFIER_POWEROFF_TRIGGERED, (void *)(intptr_t) vconf);
 
        /* Poweroff event broadcasting */
index 12ec794..850dc52 100644 (file)
@@ -253,15 +253,16 @@ int vital_state_changed(void *data)
        return 0;
 }
 
-int power_enable_autosleep(void)
+int power_init_autosleep(void)
 {
-       _I("System autosleep enabled.");
+       _I("System autosleep init.");
+       sys_set_str("/sys/power/wake_lock", "mainlock");
        return sys_set_str(POWER_AUTOSLEEP_PATH, "mem");
 }
 
-int power_disable_autosleep(void)
+int power_exit_autosleep(void)
 {
-       _I("System autosleep disabled.");
+       _I("System autosleep exit.");
        return sys_set_str(POWER_AUTOSLEEP_PATH, "off");
 }
 
index 3fac1a3..abdcf9d 100644 (file)
@@ -75,8 +75,8 @@ void pm_history_print(int fd, int count);
 #endif
 bool vital_mode(void);
 int vital_state_changed(void *data);
-int power_enable_autosleep(void);
-int power_disable_autosleep(void);
+int power_init_autosleep(void);
+int power_exit_autosleep(void);
 int power_acquire_wakelock(void);
 int power_release_wakelock(void);
 int pm_get_power_lock(void);
index f6f05e9..6682617 100644 (file)
@@ -789,7 +789,7 @@ static int delayed_init_callback(void *data)
                trigger_transition();
        }
 
-       power_enable_autosleep();
+       power_init_autosleep();
 
        return 0;
 }