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

Commit 998aead3 authored by Mayank Rana's avatar Mayank Rana
Browse files

dwc3: gadget: Fix dr_mode check with USB device mode APIs



dwc3_gadget_pullup() and dwc3_gadget_vbus_session() APIs are used
to configure USB controller into device mode and start USB gadget.
Current check doesn't allow it if dr_mode is set as peripheral.
Fix this issue by correcting used dr_mode check.

Change-Id: I083b984cb9fa828c37614c7886ab90a4489e8bb1
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent 3a4e5978
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2124,7 +2124,7 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
	is_on = !!is_on;
	dwc->softconnect = is_on;

	if (((dwc->dr_mode == USB_DR_MODE_OTG) && !dwc->vbus_active)
	if (((dwc->dr_mode > USB_DR_MODE_HOST) && !dwc->vbus_active)
			|| !dwc->gadget_driver) {
		/*
		 * Need to wait for vbus_session(on) from otg driver or to
@@ -2264,7 +2264,7 @@ static int dwc3_gadget_vbus_session(struct usb_gadget *_gadget, int is_active)
	unsigned long flags;
	int ret = 0;

	if (dwc->dr_mode != USB_DR_MODE_OTG)
	if (dwc->dr_mode <= USB_DR_MODE_HOST)
		return -EPERM;

	is_active = !!is_active;