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

Commit 62c2efe9 authored by Abhijeet Dharmapurikar's avatar Abhijeet Dharmapurikar
Browse files

power: smb135x-charger: fixed charging enabled indication



The current driver checks if charging is enabled by reading a status bit.
Note that when CHARGING_ENABLED property is set to being disabled the
driver puts DC and USB path in suspend state (CHARGING_ENABLED property
being set to disabled actually means do not draw any current from any
chargers). It does not disable charging. Hence reading the status bit to
report whether charging is enabled/disabled is incorrect. Instead return
the chg_enabled variable tracked in the chip structure that tracks
the CHARGING_ENABLED property.

Change-Id: Iee1761b8230414c41947c5964e50393cc223a6ce
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent 39dccc5e
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -505,18 +505,6 @@ static int smb135x_get_prop_batt_present(struct smb135x_chg *chip)
	return chip->batt_present;
}

static int smb135x_get_charging_status(struct smb135x_chg *chip)
{
	int rc;
	u8 reg = 0;

	rc = smb135x_read(chip, STATUS_4_REG, &reg);
	if (rc < 0)
		return 0;

	return (reg & CHG_EN_BIT) ? 1 : 0;
}

static int smb135x_get_prop_charge_type(struct smb135x_chg *chip)
{
	int rc;
@@ -915,7 +903,7 @@ static int smb135x_battery_get_property(struct power_supply *psy,
		val->intval = smb135x_get_prop_batt_present(chip);
		break;
	case POWER_SUPPLY_PROP_CHARGING_ENABLED:
		val->intval = smb135x_get_charging_status(chip);
		val->intval = chip->chg_enabled;
		break;
	case POWER_SUPPLY_PROP_CHARGE_TYPE:
		val->intval = smb135x_get_prop_charge_type(chip);