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

Commit d72bafee authored by Jack Pham's avatar Jack Pham Committed by Mayank Rana
Browse files

usb: dwc3-msm: Remove call to set POWER_SUPPLY_PROP_ONLINE



The charger drivers now handle setting of this property without
input from USB gadget other than the negotiated current draw
amount (set via POWER_SUPPLY_PROP_CURRENT_MAX). Remove setting
of POWER_SUPPLY_PROP_ONLINE which helps simplify the
dwc3_msm_gadget_vbus_draw() function a bit.

CRs-Fixed: 1034085
Change-Id: I2c5ec90cc8c45019ad75056b6feb7e6319f85514
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 5c9280cd
Loading
Loading
Loading
Loading
+8 −33
Original line number Diff line number Diff line
@@ -3147,7 +3147,8 @@ static int dwc3_otg_start_peripheral(struct dwc3_msm *mdwc, int on)

static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned int mA)
{
	union power_supply_propval pval = {0,};
	union power_supply_propval pval = {1000 * mA};
	int ret;

	if (mdwc->charging_disabled)
		return 0;
@@ -3165,42 +3166,16 @@ static int dwc3_msm_gadget_vbus_draw(struct dwc3_msm *mdwc, unsigned int mA)

	dev_info(mdwc->dev, "Avail curr from USB = %u\n", mA);

	if (mdwc->max_power <= 2 && mA > 2) {
		/* Enable Charging */
		pval.intval = true;
		if (power_supply_set_property(mdwc->usb_psy,
					POWER_SUPPLY_PROP_ONLINE, &pval))
			goto psy_error;
		pval.intval = 1000 * mA;
		if (power_supply_set_property(mdwc->usb_psy,
					POWER_SUPPLY_PROP_CURRENT_MAX, &pval))
			goto psy_error;
	} else if (mdwc->max_power > 0 && (mA == 0 || mA == 2)) {
		/* Disable charging */
		pval.intval = false;
		if (power_supply_set_property(mdwc->usb_psy,
					POWER_SUPPLY_PROP_ONLINE, &pval))
			goto psy_error;
	} else {
		/* Enable charging */
		pval.intval = true;
		if (power_supply_set_property(mdwc->usb_psy,
					POWER_SUPPLY_PROP_ONLINE, &pval))
			goto psy_error;
	}

	/* Set max current limit in uA */
	pval.intval = 1000 * mA;
	if (power_supply_set_property(mdwc->usb_psy,
				POWER_SUPPLY_PROP_CURRENT_MAX, &pval))
		goto psy_error;
	ret = power_supply_set_property(mdwc->usb_psy,
				POWER_SUPPLY_PROP_CURRENT_MAX, &pval);
	if (ret) {
		dev_dbg(mdwc->dev, "power supply error when setting property\n");
		return ret;
	}

	mdwc->max_power = mA;
	return 0;

psy_error:
	dev_dbg(mdwc->dev, "power supply error when setting property\n");
	return -ENXIO;
}