Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c59c634 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: fg-util: Update fg_get_battery_type



Simplify showing the battery type based on profile loading status
and battery missing. As profile_load_status has the information
about whether profile is loaded or not, skipped or missing, it
is better using it and remove profile_loaded variable. Since this
affects both GEN3 and GEN4 FG drivers, update them too.

Change-Id: I81e28153a81a9cbae7c6a10819dea7c4c530eb73
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 94ee3d2a
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -417,7 +417,6 @@ struct fg_dev {
	int			last_msoc;
	int			last_msoc;
	int			last_recharge_volt_mv;
	int			last_recharge_volt_mv;
	bool			profile_available;
	bool			profile_available;
	bool			profile_loaded;
	enum prof_load_status	profile_load_status;
	enum prof_load_status	profile_load_status;
	bool			battery_missing;
	bool			battery_missing;
	bool			fg_restarting;
	bool			fg_restarting;
+17 −10
Original line number Original line Diff line number Diff line
@@ -886,19 +886,26 @@ int fg_get_msoc(struct fg_dev *fg, int *msoc)
#define SKIP_BATT_TYPE		"Skipped loading battery"
#define SKIP_BATT_TYPE		"Skipped loading battery"
const char *fg_get_battery_type(struct fg_dev *fg)
const char *fg_get_battery_type(struct fg_dev *fg)
{
{
	if (fg->battery_missing ||
	switch (fg->profile_load_status) {
		fg->profile_load_status == PROFILE_MISSING)
	case PROFILE_MISSING:
		return DEFAULT_BATT_TYPE;
	case PROFILE_SKIPPED:
		return SKIP_BATT_TYPE;
	case PROFILE_LOADED:
		if (fg->bp.batt_type_str)
			return fg->bp.batt_type_str;
		break;
	case PROFILE_NOT_LOADED:
		return MISSING_BATT_TYPE;
		return MISSING_BATT_TYPE;
	default:
		break;
	};


	if (fg->profile_load_status == PROFILE_SKIPPED)
	if (fg->battery_missing)
		return SKIP_BATT_TYPE;
		return MISSING_BATT_TYPE;


	if (fg->bp.batt_type_str) {
	if (fg->profile_available)
		if (fg->profile_loaded)
			return fg->bp.batt_type_str;
		else if (fg->profile_available)
		return LOADING_BATT_TYPE;
		return LOADING_BATT_TYPE;
	}


	return DEFAULT_BATT_TYPE;
	return DEFAULT_BATT_TYPE;
}
}
+0 −4
Original line number Original line Diff line number Diff line
@@ -2548,9 +2548,6 @@ static void profile_load_work(struct work_struct *work)
	batt_psy_initialized(fg);
	batt_psy_initialized(fg);
	fg_notify_charger(fg);
	fg_notify_charger(fg);


	if (fg->profile_load_status == PROFILE_LOADED)
		fg->profile_loaded = true;

	fg_dbg(fg, FG_STATUS, "profile loaded successfully");
	fg_dbg(fg, FG_STATUS, "profile loaded successfully");
out:
out:
	fg->soc_reporting_ready = true;
	fg->soc_reporting_ready = true;
@@ -3915,7 +3912,6 @@ static irqreturn_t fg_batt_missing_irq_handler(int irq, void *data)


	if (fg->battery_missing) {
	if (fg->battery_missing) {
		fg->profile_available = false;
		fg->profile_available = false;
		fg->profile_loaded = false;
		fg->profile_load_status = PROFILE_NOT_LOADED;
		fg->profile_load_status = PROFILE_NOT_LOADED;
		fg->soc_reporting_ready = false;
		fg->soc_reporting_ready = false;
		fg->batt_id_ohms = -EINVAL;
		fg->batt_id_ohms = -EINVAL;
+0 −4
Original line number Original line Diff line number Diff line
@@ -1031,9 +1031,6 @@ static void profile_load_work(struct work_struct *work)
	batt_psy_initialized(fg);
	batt_psy_initialized(fg);
	fg_notify_charger(fg);
	fg_notify_charger(fg);


	if (fg->profile_load_status == PROFILE_LOADED)
		fg->profile_loaded = true;

	fg_dbg(fg, FG_STATUS, "profile loaded successfully");
	fg_dbg(fg, FG_STATUS, "profile loaded successfully");
out:
out:
	fg->soc_reporting_ready = true;
	fg->soc_reporting_ready = true;
@@ -1284,7 +1281,6 @@ static irqreturn_t fg_batt_missing_irq_handler(int irq, void *data)


	if (fg->battery_missing) {
	if (fg->battery_missing) {
		fg->profile_available = false;
		fg->profile_available = false;
		fg->profile_loaded = false;
		fg->profile_load_status = PROFILE_NOT_LOADED;
		fg->profile_load_status = PROFILE_NOT_LOADED;
		fg->soc_reporting_ready = false;
		fg->soc_reporting_ready = false;
		fg->batt_id_ohms = -EINVAL;
		fg->batt_id_ohms = -EINVAL;