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

Commit 83e10419 authored by Harsh Agarwal's avatar Harsh Agarwal Committed by Gerrit - the friendly Code Review server
Browse files

usb: dwc3-msm: Prevent switch to peripheral for host-mode only core



Currently certain platforms have cores which are only host-mode
compatible. Prevent switch to peripharal mode for such cores so
as to prevent unanticipated core behavior and crashes.

Change-Id: I163e878bfe7428ed339409adb8a491a6673ca055
Signed-off-by: default avatarHarsh Agarwal <harshq@codeaurora.org>
parent 84df7e40
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3869,8 +3869,14 @@ static ssize_t mode_store(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t count)
{
	struct dwc3_msm *mdwc = dev_get_drvdata(dev);
	struct dwc3 *dwc = platform_get_drvdata(mdwc->dwc3);

	if (sysfs_streq(buf, "peripheral")) {
		if (dwc->dr_mode == USB_DR_MODE_HOST) {
			dev_err(dev, "Core supports host mode only.\n");
			return -EINVAL;
		}

		mdwc->vbus_active = true;
		mdwc->id_state = DWC3_ID_FLOAT;
	} else if (sysfs_streq(buf, "host")) {