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

Commit 3d50082e authored by Hemant Kumar's avatar Hemant Kumar
Browse files

usb: composite: Draw current based on speed upon resume



If usb device goes to suspend in high speed mode and resumed
back, it is drawing 900mA. Fix this issue by checking gadget
speed before calling usb_gadget_vbus_draw().

Change-Id: I8e94811597084fce015951bd27cc65dec3ae91ff
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent 76ec68dc
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -2433,7 +2433,7 @@ void composite_resume(struct usb_gadget *gadget)
{
	struct usb_composite_dev	*cdev = get_gadget_data(gadget);
	struct usb_function		*f;
	u16				maxpower;
	unsigned int			maxpower;
	int				ret;
	unsigned long			flags;

@@ -2475,9 +2475,10 @@ void composite_resume(struct usb_gadget *gadget)
		}

		maxpower = cdev->config->MaxPower;

		usb_gadget_vbus_draw(gadget, maxpower ?
			maxpower : CONFIG_USB_GADGET_VBUS_DRAW);
		maxpower = maxpower ? maxpower : CONFIG_USB_GADGET_VBUS_DRAW;
		if (gadget->speed < USB_SPEED_SUPER)
			maxpower = min(maxpower, 500U);
		usb_gadget_vbus_draw(gadget, maxpower);
	}

	spin_unlock_irqrestore(&cdev->lock, flags);