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

Commit 37cf30d2 authored by Hemant Kumar's avatar Hemant Kumar Committed by Gerrit - the friendly Code Review server
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 e59d2258
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -2405,7 +2405,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;

@@ -2439,9 +2439,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);