diff --git a/headers/os/device/USBKit.h b/headers/os/device/USBKit.h index 9758942f12..f415bc00e1 100644 --- a/headers/os/device/USBKit.h +++ b/headers/os/device/USBKit.h @@ -204,8 +204,7 @@ friend class BUSBDevice; mutable char * fConfigurationString; - usb_configuration_descriptor* fFullDescriptor; - uint32 fReserved[9]; + uint32 fReserved[10]; }; diff --git a/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp b/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp index fae00ac8d5..d430080f19 100644 --- a/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp +++ b/src/add-ons/kernel/drivers/bus/usb/usb_raw.cpp @@ -300,36 +300,23 @@ usb_raw_ioctl(void *cookie, uint32 op, void *buffer, size_t length) } case B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR: - case B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR_ETC: { if (length < sizeof(command->config)) return B_BUFFER_OVERFLOW; - size_t descriptorLength = sizeof(usb_configuration_descriptor); - if (op == B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR_ETC) { - if (length < sizeof(command->config_etc)) - return B_BUFFER_OVERFLOW; - - descriptorLength = command->config_etc.length; - } - const usb_configuration_info *configurationInfo = usb_raw_get_configuration(device, command->config.config_index, &command->config.status); if (configurationInfo == NULL) return B_OK; - const usb_configuration_descriptor* descriptor - = configurationInfo->descr; - if (user_memcpy(command->config.descriptor, descriptor, - min_c(descriptorLength, descriptor->total_length)) != B_OK) { + if (user_memcpy(command->config.descriptor, + configurationInfo->descr, + sizeof(usb_configuration_descriptor)) != B_OK) { return B_BAD_ADDRESS; } - if (op == B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR_ETC - && descriptor->total_length > descriptorLength) - command->config.status = B_USB_RAW_STATUS_NO_MEMORY; - else - command->config.status = B_USB_RAW_STATUS_SUCCESS; + + command->config.status = B_USB_RAW_STATUS_SUCCESS; return B_OK; } diff --git a/src/add-ons/kernel/drivers/bus/usb/usb_raw.h b/src/add-ons/kernel/drivers/bus/usb/usb_raw.h index fc41654029..54112c2202 100644 --- a/src/add-ons/kernel/drivers/bus/usb/usb_raw.h +++ b/src/add-ons/kernel/drivers/bus/usb/usb_raw.h @@ -22,11 +22,10 @@ typedef enum { B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR, B_USB_RAW_COMMAND_GET_ALT_INTERFACE_COUNT, B_USB_RAW_COMMAND_GET_ACTIVE_ALT_INTERFACE_INDEX, - B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR_ETC, B_USB_RAW_COMMAND_GET_INTERFACE_DESCRIPTOR_ETC, B_USB_RAW_COMMAND_GET_ENDPOINT_DESCRIPTOR_ETC, B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR_ETC, - + B_USB_RAW_COMMAND_SET_CONFIGURATION = 0x3000, B_USB_RAW_COMMAND_SET_FEATURE, B_USB_RAW_COMMAND_CLEAR_FEATURE, @@ -75,13 +74,6 @@ typedef union { uint32 config_index; } config; - struct { - status_t status; - usb_configuration_descriptor *descriptor; - uint32 config_index; - size_t length; - } config_etc; - struct { status_t status; uint32 alternate_info; diff --git a/src/kits/device/USBConfiguration.cpp b/src/kits/device/USBConfiguration.cpp index 1751cd2573..cf158a06e2 100644 --- a/src/kits/device/USBConfiguration.cpp +++ b/src/kits/device/USBConfiguration.cpp @@ -8,12 +8,9 @@ #include #include - -#include -#include -#include #include - +#include +#include BUSBConfiguration::BUSBConfiguration(BUSBDevice *device, uint32 index, int rawFD) @@ -21,36 +18,14 @@ BUSBConfiguration::BUSBConfiguration(BUSBDevice *device, uint32 index, int rawFD fIndex(index), fRawFD(rawFD), fInterfaces(NULL), - fConfigurationString(NULL), - fFullDescriptor(NULL) + fConfigurationString(NULL) { usb_raw_command command; command.config.descriptor = &fDescriptor; command.config.config_index = fIndex; - - if (ioctl(fRawFD, B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR, - &command, sizeof(command)) - || command.config.status != B_USB_RAW_STATUS_SUCCESS) { + if (ioctl(fRawFD, B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR, &command, + sizeof(command)) || command.config.status != B_USB_RAW_STATUS_SUCCESS) memset(&fDescriptor, 0, sizeof(fDescriptor)); - } else { - // Got the descriptor header, retrieve the whole descriptor - size_t length = fDescriptor.total_length; - fFullDescriptor = (usb_configuration_descriptor*)malloc(length); - - if (fFullDescriptor != NULL) { - command.config_etc.descriptor = fFullDescriptor; - command.config_etc.config_index = fIndex; - command.config_etc.length = length; - - if (ioctl(fRawFD, B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR_ETC, - &command, sizeof(command)) - || command.config_etc.status != B_USB_RAW_STATUS_SUCCESS) { - - free(fFullDescriptor); - fFullDescriptor = NULL; - } - } - } fInterfaces = new(std::nothrow) BUSBInterface *[ fDescriptor.number_interfaces]; @@ -66,8 +41,6 @@ BUSBConfiguration::BUSBConfiguration(BUSBDevice *device, uint32 index, int rawFD BUSBConfiguration::~BUSBConfiguration() { - free(fFullDescriptor); - delete[] fConfigurationString; if (fInterfaces != NULL) { for (int32 i = 0; i < fDescriptor.number_interfaces; i++) @@ -112,7 +85,7 @@ BUSBConfiguration::ConfigurationString() const const usb_configuration_descriptor * BUSBConfiguration::Descriptor() const { - return (fFullDescriptor != NULL) ? fFullDescriptor : &fDescriptor; + return &fDescriptor; }