usb: Return configuration = 0 in Addressed state.

This is as per USB 2.0 chapter 9 specifications, and
enables passing of USB-IF Chapter 9 tests.
This commit is contained in:
svo 2016-01-07 19:35:42 +03:00 committed by Karl Palsson
parent 63fda0a231
commit d7f09d1178

View File

@ -312,9 +312,13 @@ static int usb_standard_get_configuration(usbd_device *usbd_dev,
if (*len > 1) {
*len = 1;
}
const struct usb_config_descriptor *cfg =
&usbd_dev->config[usbd_dev->current_config - 1];
(*buf)[0] = cfg->bConfigurationValue;
if (usbd_dev->current_config > 0) {
const struct usb_config_descriptor *cfg =
&usbd_dev->config[usbd_dev->current_config - 1];
(*buf)[0] = cfg->bConfigurationValue;
} else {
(*buf)[0] = 0;
}
return 1;
}