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

Commit 567b986a authored by Kiran Gunda's avatar Kiran Gunda Committed by Gerrit - the friendly Code Review server
Browse files

power: smb1398: Update adapter_type in the work-queue's context



There is mutex deadlock where the adapter_type is read in the
context of a call-back from the main-charger driver. Fix it by
moving it to the status_change work and using a local variable
to hold the type.

Change-Id: Id112097f70fbfb13acc368e9787cf6a0c3a1acff
Signed-off-by: default avatarKiran Gunda <kgunda@codeaurora.org>
parent 198d27fa
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -345,6 +345,7 @@ struct smb1398_chip {
	int			cp_isns_master;
	int			cp_isns_slave;
	int			cp_ilim;
	int			adapter_type;

	bool			status_change_running;
	bool			taper_work_running;
@@ -1023,17 +1024,13 @@ static void smb1398_toggle_switcher(struct smb1398_chip *chip)
#define DEFAULT_HVDCP3_MIN_ICL_UA 1000000
static int smb1398_div2_cp_get_min_icl(struct smb1398_chip *chip)
{
	int rc, val = 0;
	int min_ilim = chip->div2_cp_min_ilim_ua;

	/* Use max(dt_min_icl, 1A) for HVDCP3 */
	if (!IS_ERR_OR_NULL(chip->smb5_iio_chan_list)) {
		rc = cp_read_iio_prop(chip, QPNP_SMB5, REAL_TYPE, &val);
		if (rc >= 0 && (val == QTI_POWER_SUPPLY_TYPE_USB_HVDCP_3))
			return max(chip->div2_cp_min_ilim_ua,
	if (chip->adapter_type == QTI_POWER_SUPPLY_TYPE_USB_HVDCP_3)
		min_ilim = max(chip->div2_cp_min_ilim_ua,
				DEFAULT_HVDCP3_MIN_ICL_UA);
	}

	return chip->div2_cp_min_ilim_ua;
	return min_ilim;
}

static char *div2_cp_get_model_name(struct smb1398_chip *chip)
@@ -1615,6 +1612,12 @@ static void smb1398_status_change_work(struct work_struct *work)
		goto out;
	}

	rc = cp_read_iio_prop(chip, QPNP_SMB5, REAL_TYPE, &chip->adapter_type);
	if (rc < 0) {
		dev_err(chip->dev, "Couldn't get REAL_TYPE, rc=%d\n", rc);
		goto out;
	}

	rc = cp_read_iio_prop(chip, QPNP_SMB5, SMB_EN_REASON, &val);
	if (rc < 0) {
		dev_err(chip->dev, "Couldn't get SMB_EN_REASON failed, rc=%d\n",