freemyipod r936 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r935‎ | r936 | r937 >
Date:03:16, 7 June 2014
Author:theseven
Status:new
Tags:
Comment:
emCORE: Prevent low battery conditions from causing a reboot loop
Modified paths:
  • /emcore/trunk/init.c (modified) (history)

Diff [purge]

Index: emcore/trunk/init.c
@@ -119,6 +119,26 @@
120120 void storageinitthread(void* arg0, void* arg1, void* arg2, void* arg3)
121121 {
122122 struct initbss* ib = (struct initbss*)arg0;
 123+ int threshold = 0;
 124+ DEBUGF("Battery state: %d mV, %d mAh", read_battery_voltage(0), read_battery_mwh_current(0));
 125+ if (read_battery_mwh_current(0) <= threshold)
 126+ {
 127+ backlight_set_brightness(50);
 128+ cputs(CONSOLE_BOOT, "The battery is discharged.\n"
 129+ "Please connect to a power supply\n"
 130+ "and wait a few minutes.\n");
 131+ while (read_battery_mwh_current(0) <= threshold)
 132+ {
 133+ DEBUGF("Battery state: %d mV, %d mAh", read_battery_voltage(0), read_battery_mwh_current(0));
 134+ sleep(10000000);
 135+ if (read_input_state(0) != INPUT_STATE_ACTIVE)
 136+ {
 137+ shutdown(true);
 138+ power_off();
 139+ }
 140+ }
 141+ backlight_set_brightness(100);
 142+ }
123143 DEBUGF("Initializing storage drivers...");
124144 int rc = storage_init();
125145 if (IS_ERR(rc))