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

Commit 117b6273 authored by Ke Liu's avatar Ke Liu
Browse files

power: smb135x-charger: resolve circular wait between USB and SMB at probe



During SMB driver probe, it will wait for the usb_psy (the "USB" power
supply obejct) to be present before it creates a regulator. In host only
mode, USB will also try to get the regulator at probe time. This results
in a circular wait.

Update the SMB driver probe sequence so that the SMB driver does not wait
for the usb_psy in host only mode.

Change-Id: Ida8988a2ccff43124af6f3e61ee27b26f5c27169
CRs-fixed: 661326
Signed-off-by: default avatarKe Liu <keliu@codeaurora.org>
parent 2049a6cf
Loading
Loading
Loading
Loading
+19 −12
Original line number Diff line number Diff line
@@ -1084,6 +1084,9 @@ static int smb135x_set_appropriate_current(struct smb135x_chg *chip,
	int (*func)(struct smb135x_chg *chip, int current_ma);
	int rc = 0;

	if (!chip->usb_psy && path == USB)
		return 0;

	/*
	 * If battery is absent do not modify the current at all, these
	 * would be some appropriate values set by the bootloader or default
@@ -1376,6 +1379,9 @@ static void smb135x_external_power_changed(struct power_supply *psy)
	union power_supply_propval prop = {0,};
	int rc, current_limit = 0;

	if (!chip->usb_psy)
		return;

	if (chip->bms_psy_name)
		chip->bms_psy =
			power_supply_get_by_name((char *)chip->bms_psy_name);
@@ -3091,12 +3097,6 @@ static int smb135x_charger_probe(struct i2c_client *client,
	struct power_supply *usb_psy;
	u8 reg = 0;

	usb_psy = power_supply_get_by_name("usb");
	if (!usb_psy) {
		dev_dbg(&client->dev, "USB supply not found; defer probe\n");
		return -EPROBE_DEFER;
	}

	chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
	if (!chip) {
		dev_err(&client->dev, "Unable to allocate memory\n");
@@ -3105,7 +3105,20 @@ static int smb135x_charger_probe(struct i2c_client *client,

	chip->client = client;
	chip->dev = &client->dev;

	rc = smb_parse_dt(chip);
	if (rc < 0) {
		dev_err(&client->dev, "Unable to parse DT nodes\n");
		return rc;
	}

	usb_psy = power_supply_get_by_name("usb");
	if (!usb_psy && chip->chg_enabled) {
		dev_dbg(&client->dev, "USB supply not found; defer probe\n");
		return -EPROBE_DEFER;
	}
	chip->usb_psy = usb_psy;

	chip->fake_battery_soc = -EINVAL;

	INIT_DELAYED_WORK(&chip->wireless_insertion_work,
@@ -3121,12 +3134,6 @@ static int smb135x_charger_probe(struct i2c_client *client,
		return -ENODEV;
	}

	rc = smb_parse_dt(chip);
	if (rc < 0) {
		dev_err(&client->dev, "Unable to parse DT nodes\n");
		return rc;
	}

	i2c_set_clientdata(client, chip);

	rc = smb135x_chip_version_and_revision(chip);