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

Commit a109977a authored by Jack Pham's avatar Jack Pham
Browse files

usb: gadget: composite: Allow vbus_draw() to be called with 0mA



Similar to commit 9ffbd89c ("USB: gadget: composite: Allow
bMaxPower=0 if self-powered"), c->MaxPower may be allowed to be 0
when the gadget's configuration indicates it is self-powered. Thus
allow 0 to be passed directly to usb_gadget_vbus_draw() instead of
defaulting to CONFIG_USB_GADGET_VBUS_DRAW which is non-zero.

Change-Id: I4bf677a31a449c7763e2decad4860909f359dcb7
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent d1d92738
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -944,7 +944,11 @@ static int set_config(struct usb_composite_dev *cdev,
	}

	/* when we return, be sure our power usage is valid */
	power = c->MaxPower ? c->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW;
	if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
		power = c->MaxPower;
	else
		power = CONFIG_USB_GADGET_VBUS_DRAW;

	if (gadget->speed < USB_SPEED_SUPER)
		power = min(power, 500U);
	else