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

Commit c7efbfff authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

qpnp-smb2: smb-lib: update reading charge_done property



Instead of setting charge_done property from smb-lib when
handling chg_state_change interrupt, move it to a separate
function which reads the hardware register directly and
updates it. Since this doesn't require a set_property callback,
remove it.

Change-Id: I1005b135f5e16111257902413ef2b44c09cb1cfc
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 21005fbb
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -664,7 +664,7 @@ static int smb2_batt_get_prop(struct power_supply *psy,
		val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
		break;
	case POWER_SUPPLY_PROP_CHARGE_DONE:
		val->intval = chg->chg_done;
		rc = smblib_get_prop_batt_charge_done(chg, val);
		break;
	default:
		pr_err("batt power supply prop %d not supported\n", psp);
@@ -696,9 +696,6 @@ static int smb2_batt_set_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_CAPACITY:
		rc = smblib_set_prop_batt_capacity(chg, val);
		break;
	case POWER_SUPPLY_PROP_CHARGE_DONE:
		chg->chg_done = val->intval;
		break;
	default:
		rc = -EINVAL;
	}
+18 −4
Original line number Diff line number Diff line
@@ -1093,6 +1093,24 @@ int smblib_get_prop_step_chg_step(struct smb_charger *chg,
	return rc;
}

int smblib_get_prop_batt_charge_done(struct smb_charger *chg,
					union power_supply_propval *val)
{
	int rc;
	u8 stat;

	rc = smblib_read(chg, BATTERY_CHARGER_STATUS_1_REG, &stat);
	if (rc < 0) {
		dev_err(chg->dev, "Couldn't read BATTERY_CHARGER_STATUS_1 rc=%d\n",
			rc);
		return rc;
	}

	stat = stat & BATTERY_CHARGER_STATUS_MASK;
	val->intval = (stat == TERMINATE_CHARGE);
	return 0;
}

/***********************
 * BATTERY PSY SETTERS *
 ***********************/
@@ -1716,7 +1734,6 @@ static void smblib_pl_handle_chg_state_change(struct smb_charger *chg, u8 stat)

irqreturn_t smblib_handle_chg_state_change(int irq, void *data)
{
	union power_supply_propval pval = {0, };
	struct smb_irq_data *irq_data = data;
	struct smb_charger *chg = irq_data->parent_data;
	u8 stat;
@@ -1733,9 +1750,6 @@ irqreturn_t smblib_handle_chg_state_change(int irq, void *data)

	stat = stat & BATTERY_CHARGER_STATUS_MASK;
	smblib_pl_handle_chg_state_change(chg, stat);
	pval.intval = (stat == TERMINATE_CHARGE);
	power_supply_set_property(chg->batt_psy, POWER_SUPPLY_PROP_CHARGE_DONE,
		&pval);
	power_supply_changed(chg->batt_psy);
	return IRQ_HANDLED;
}
+2 −0
Original line number Diff line number Diff line
@@ -222,6 +222,8 @@ int smblib_get_prop_batt_status(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_batt_charge_type(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_batt_charge_done(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_batt_health(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_system_temp_level(struct smb_charger *chg,