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