usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus
authorJack Pham <jackp@codeaurora.org>
Fri, 31 Jan 2020 03:10:35 +0000 (19:10 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 28 Feb 2020 15:38:59 +0000 (16:38 +0100)
commitde8dbb7b02faf959196232b0d28dec2d3c8dfccf
tree1a083a32896743fb81d95b55578149fe3c7786fc
parent1cad1a6497ecb07c87c6199a41e9316183eb4898
usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus

commit c724417baf162bd3e035659e22cdf990cfb0d917 upstream.

SuperSpeedPlus peripherals must report their bMaxPower of the
configuration descriptor in units of 8mA as per the USB 3.2
specification. The current switch statement in encode_bMaxPower()
only checks for USB_SPEED_SUPER but not USB_SPEED_SUPER_PLUS so
the latter falls back to USB 2.0 encoding which uses 2mA units.
Replace the switch with a simple if/else.

Fixes: eae5820b852f ("usb: gadget: composite: Write SuperSpeedPlus config descriptors")
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/composite.c