usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus

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: eae5820b85 ("usb: gadget: composite: Write SuperSpeedPlus config descriptors")
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
This commit is contained in:
Jack Pham 2020-01-30 19:10:35 -08:00 коммит произвёл Felipe Balbi
Родитель 904967c60d
Коммит c724417baf
1 изменённых файлов: 3 добавлений и 5 удалений

Просмотреть файл

@ -437,12 +437,10 @@ static u8 encode_bMaxPower(enum usb_device_speed speed,
val = CONFIG_USB_GADGET_VBUS_DRAW; val = CONFIG_USB_GADGET_VBUS_DRAW;
if (!val) if (!val)
return 0; return 0;
switch (speed) { if (speed < USB_SPEED_SUPER)
case USB_SPEED_SUPER:
return DIV_ROUND_UP(val, 8);
default:
return DIV_ROUND_UP(val, 2); return DIV_ROUND_UP(val, 2);
} else
return DIV_ROUND_UP(val, 8);
} }
static int config_buf(struct usb_configuration *config, static int config_buf(struct usb_configuration *config,