aboutsummaryrefslogtreecommitdiff
path: root/init/init_z2_plus.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'init/init_z2_plus.cpp')
-rw-r--r--init/init_z2_plus.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/init/init_z2_plus.cpp b/init/init_z2_plus.cpp
index d1524c4..5c6c550 100644
--- a/init/init_z2_plus.cpp
+++ b/init/init_z2_plus.cpp
@@ -59,14 +59,12 @@ static int read_file2(const char *fname, char *data, int max_size)
return 1;
}
-static void init_alarm_boot_properties()
+void init_alarm_boot_properties()
{
- int boot_reason;
- FILE *fp;
+ char const *alarm_file = "/proc/sys/kernel/boot_reason";
+ char buf[64];
- fp = fopen("/proc/sys/kernel/boot_reason", "r");
- fscanf(fp, "%d", &boot_reason);
- fclose(fp);
+ if(read_file2(alarm_file, buf, sizeof(buf))) {
/*
* Setup ro.alarm_boot value to true when it is RTC triggered boot up
@@ -78,15 +76,15 @@ static void init_alarm_boot_properties()
* 2 -> sudden momentary power loss (SMPL)
* 3 -> real time clock (RTC)
* 4 -> DC charger inserted
- * 5 -> USB charger inserted
+ * 5 -> USB charger insertd
* 6 -> PON1 pin toggled (for secondary PMICs)
* 7 -> CBLPWR_N pin toggled (for external power supply)
* 8 -> KPDPWR_N pin toggled (power key pressed)
*/
- if (boot_reason == 3) {
- property_set("ro.alarm_boot", "true");
- } else {
- property_set("ro.alarm_boot", "false");
+ if(buf[0] == '3')
+ property_set("ro.alarm_boot", "true");
+ else
+ property_set("ro.alarm_boot", "false");
}
}