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

Commit ec41a30d authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: smb5: show charger temp only when USB or DC is present"

parents ef038037 a529b344
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -1123,8 +1123,6 @@ static int smb5_batt_get_prop(struct power_supply *psy,
		union power_supply_propval *val)
{
	struct smb_charger *chg = power_supply_get_drvdata(psy);
	union power_supply_propval pval = {0, };

	int rc = 0;

	switch (psp) {
@@ -1153,12 +1151,6 @@ static int smb5_batt_get_prop(struct power_supply *psy,
		rc = smblib_get_prop_system_temp_level_max(chg, val);
		break;
	case POWER_SUPPLY_PROP_CHARGER_TEMP:
		rc = smblib_get_prop_usb_present(chg, &pval);
		if (rc < 0) {
			pr_err("Couldn't get usb present rc=%d\n", rc);
			break;
		}
		if (pval.intval)
		rc = smblib_get_prop_charger_temp(chg, val);
		break;
	case POWER_SUPPLY_PROP_CHARGER_TEMP_MAX:
+22 −3
Original line number Diff line number Diff line
@@ -2058,16 +2058,35 @@ int smblib_get_prop_usb_voltage_now(struct smb_charger *chg,
int smblib_get_prop_charger_temp(struct smb_charger *chg,
				 union power_supply_propval *val)
{
	int rc;
	union power_supply_propval pval = {0, };
	bool usb_present, dc_present;
	int temp, rc;

	rc = smblib_get_prop_usb_present(chg, &pval);
	if (rc < 0) {
		pr_err("Couldn't get usb presence status rc=%d\n", rc);
		return rc;
	}
	usb_present = pval.intval;

	rc = smblib_get_prop_dc_present(chg, &pval);
	if (rc < 0) {
		pr_err("Couldn't get dc presence status rc=%d\n", rc);
		return rc;
	}
	dc_present = pval.intval;

	if (!usb_present && !dc_present)
		return -ENODATA;

	if (chg->iio.temp_chan) {
		rc = iio_read_channel_processed(chg->iio.temp_chan,
				&val->intval);
				&temp);
		if (rc < 0) {
			pr_err("Error in reading temp channel, rc=%d", rc);
			return rc;
		}
		val->intval /= 100;
		val->intval = temp / 100;
	} else {
		return -ENODATA;
	}