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

Commit 37b5801e authored by Parirajan Muthalagu's avatar Parirajan Muthalagu Committed by Greg Kroah-Hartman
Browse files

USB Gadget: Verify VBUS current before setting the device self-powered bit

parent 90593899
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1074,6 +1074,12 @@ static int composite_bind(struct usb_gadget *gadget)
	cdev->bufsiz = USB_BUFSIZ;
	cdev->driver = composite;

	/*
	 * As per USB compliance update, a device that is actively drawing
	 * more than 100mA from USB must report itself as bus-powered in
	 * the GetStatus(DEVICE) call.
	 */
	if (CONFIG_USB_GADGET_VBUS_DRAW <= USB_SELF_POWER_VBUS_MAX_DRAW)
		usb_gadget_set_selfpowered(gadget);

	/* interface and string IDs start at zero via kzalloc.
+10 −0
Original line number Diff line number Diff line
@@ -808,4 +808,14 @@ enum usb_device_state {
	 */
};

/*-------------------------------------------------------------------------*/

/*
 * As per USB compliance update, a device that is actively drawing
 * more than 100mA from USB must report itself as bus-powered in
 * the GetStatus(DEVICE) call.
 * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
 */
#define USB_SELF_POWER_VBUS_MAX_DRAW		100

#endif /* __LINUX_USB_CH9_H */