File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ static const struct battery_info info = {
40
40
.discharging_max_c = 62 ,
41
41
};
42
42
43
+ static enum battery_present batt_pres_prev = BP_NOT_SURE ;
43
44
static uint8_t charging_maximum_level = NEED_RESTORE ;
44
45
static int old_btp ;
45
46
@@ -100,20 +101,31 @@ static int battery_check_disconnect(void)
100
101
101
102
enum battery_present battery_is_present (void )
102
103
{
103
- enum battery_present bp ;
104
+ enum battery_present batt_pres ;
104
105
int mv ;
105
106
106
107
mv = adc_read_channel (ADC_VCIN1_BATT_TEMP );
107
- bp = (mv < 3000 ? BP_YES : BP_NO );
108
+ batt_pres = (mv < 3000 ? BP_YES : BP_NO );
108
109
109
110
if (mv == ADC_READ_ERROR )
110
111
return BP_NO ;
111
- else if (!bp )
112
+
113
+ /*
114
+ * If the battery is present now and was present last time we checked,
115
+ * return early.
116
+ */
117
+ if (batt_pres == BP_YES && batt_pres_prev == batt_pres )
118
+ return batt_pres ;
119
+
120
+
121
+ if (!batt_pres )
112
122
return BP_NO ;
113
123
else if (battery_check_disconnect () != BATTERY_NOT_DISCONNECTED )
114
124
return BP_NOT_SURE ;
115
- else
116
- return bp ;
125
+
126
+ batt_pres_prev = batt_pres ;
127
+
128
+ return batt_pres ;
117
129
}
118
130
119
131
#ifdef CONFIG_EMI_REGION1
You can’t perform that action at this time.
0 commit comments