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

Commit 801b18de authored by Xiaozhe Shi's avatar Xiaozhe Shi Committed by Ashay Jaiswal
Browse files

power: smb135x-charger: stay awake during i2c transactions



I2C transactions can timeout if the bus is already suspended when the
I2C transaction is initiated. Prevent this by holding the device awake
during I2C transactions.

Note that if the transaction is initiated after suspend_noirq, the
transaction will still timeout, but the I2C retry will ensure the
transction goes through.

CRs-Fixed: 878738
Change-Id: I780a7ddfc7a25f9796dbe19a16c15cee66a2e0ed
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent 077d77bd
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -479,7 +479,9 @@ static int smb135x_read(struct smb135x_chg *chip, int reg,
		return 0;
	}
	mutex_lock(&chip->read_write_lock);
	pm_stay_awake(chip->dev);
	rc = __smb135x_read(chip, reg, val);
	pm_relax(chip->dev);
	mutex_unlock(&chip->read_write_lock);

	return rc;
@@ -494,7 +496,9 @@ static int smb135x_write(struct smb135x_chg *chip, int reg,
		return 0;

	mutex_lock(&chip->read_write_lock);
	pm_stay_awake(chip->dev);
	rc = __smb135x_write(chip, reg, val);
	pm_relax(chip->dev);
	mutex_unlock(&chip->read_write_lock);

	return rc;
@@ -4128,6 +4132,7 @@ static int smb135x_main_charger_probe(struct i2c_client *client,
	mutex_init(&chip->current_change_lock);
	mutex_init(&chip->read_write_lock);
	mutex_init(&chip->otg_oc_count_lock);
	device_init_wakeup(chip->dev, true);
	/* probe the device to check if its actually connected */
	rc = smb135x_read(chip, CFG_4_REG, &reg);
	if (rc) {