modules/batt_health/sys.c
static bool sys_is_battery_nvm_write_needed(bhd_state_t *old_state, bhd_state_t *cur_state)
{
	bool is_write_needed = false;

	if (cur_state->bms.chargecycles > old_state->bms.chargecycles) {
		is_write_needed = true;
		ALOGD("Write needed - Charge cycle increase, current = %d, old = %d",
			cur_state->bms.chargecycles, old_state->bms.chargecycles);
	}

	/* Compare current charge increase against the last previously written value.
	   Need to do this to account for multiple smaller increases */
	if (cur_state->bms.charge_increase >= (old_state->last_chg_inc_write + 50)) {
		is_write_needed = true;
		ALOGD("Write needed - Charge %% increase, current = %d, old = %d",
			cur_state->bms.charge_increase, old_state->last_chg_inc_write);
	}

	if (cur_state->aged_capacity != old_state->aged_capacity) {
		is_write_needed = true;
		ALOGD("Write needed - Aged capacity chage, current = %d, old = %d",
			cur_state->aged_capacity, old_state->aged_capacity);
	}

	return is_write_needed;
}
/* Determines if sysfs values have changed enough to warrant and NVM write. Should
   make best effort to limit the number of NVM writes */
Determines if sysfs values have changed enough to warrant and NVM write. Should
make best effort to limit the number of NVM writes
Determines if sysfs values have changed enough to warrant and NVM write . Should make best effort to limit the number of NVM writes
static bool sys_is_battery_nvm_write_needed(bhd_state_t *old_state, bhd_state_t *cur_state)
{
	bool is_write_needed = false;
	if (cur_state->bms.chargecycles > old_state->bms.chargecycles) {
		is_write_needed = true;
		ALOGD("Write needed - Charge cycle increase, current = %d, old = %d",
			cur_state->bms.chargecycles, old_state->bms.chargecycles);
	}
	if (cur_state->bms.charge_increase >= (old_state->last_chg_inc_write + 50)) {
		is_write_needed = true;
		ALOGD("Write needed - Charge %% increase, current = %d, old = %d",
			cur_state->bms.charge_increase, old_state->last_chg_inc_write);
	}
	if (cur_state->aged_capacity != old_state->aged_capacity) {
		is_write_needed = true;
		ALOGD("Write needed - Aged capacity chage, current = %d, old = %d",
			cur_state->aged_capacity, old_state->aged_capacity);
	}
	return is_write_needed;
}
static bool sys_is_battery_nvm_write_needed ( bhd_state_t * old_state , bhd_state_t * cur_state ) { bool is_write_needed = false ; if ( cur_state -> bms . chargecycles > old_state -> bms . chargecycles ) { is_write_needed = true ; ALOGD ( " " , cur_state -> bms . chargecycles , old_state -> bms . chargecycles ) ; } if ( cur_state -> bms . charge_increase >= ( old_state -> last_chg_inc_write + 50 ) ) { is_write_needed = true ; ALOGD ( " " , cur_state -> bms . charge_increase , old_state -> last_chg_inc_write ) ; } if ( cur_state -> aged_capacity != old_state -> aged_capacity ) { is_write_needed = true ; ALOGD ( " " , cur_state -> aged_capacity , old_state -> aged_capacity ) ; } return is_write_needed ; }
Determines if sysfs values have changed enough to warrant and NVM write.
Determines if sysfs values have changed enough to warrant and NVM write .
/* Compare current charge increase against the last previously written value.
	   Need to do this to account for multiple smaller increases */