Revert r42812. As pointed by Michael, one can use
BUSBDevice::GetDescriptor() to retrieve whatever descriptor, including a complete configuration descriptor. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42905 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -204,8 +204,7 @@ friend class BUSBDevice;
|
|||||||
|
|
||||||
mutable char * fConfigurationString;
|
mutable char * fConfigurationString;
|
||||||
|
|
||||||
usb_configuration_descriptor* fFullDescriptor;
|
uint32 fReserved[10];
|
||||||
uint32 fReserved[9];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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:
|
||||||
case B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR_ETC:
|
|
||||||
{
|
{
|
||||||
if (length < sizeof(command->config))
|
if (length < sizeof(command->config))
|
||||||
return B_BUFFER_OVERFLOW;
|
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 =
|
const usb_configuration_info *configurationInfo =
|
||||||
usb_raw_get_configuration(device, command->config.config_index,
|
usb_raw_get_configuration(device, command->config.config_index,
|
||||||
&command->config.status);
|
&command->config.status);
|
||||||
if (configurationInfo == NULL)
|
if (configurationInfo == NULL)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
const usb_configuration_descriptor* descriptor
|
if (user_memcpy(command->config.descriptor,
|
||||||
= configurationInfo->descr;
|
configurationInfo->descr,
|
||||||
if (user_memcpy(command->config.descriptor, descriptor,
|
sizeof(usb_configuration_descriptor)) != B_OK) {
|
||||||
min_c(descriptorLength, descriptor->total_length)) != B_OK) {
|
|
||||||
return B_BAD_ADDRESS;
|
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_SUCCESS;
|
||||||
command->config.status = B_USB_RAW_STATUS_NO_MEMORY;
|
|
||||||
else
|
|
||||||
command->config.status = B_USB_RAW_STATUS_SUCCESS;
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ typedef enum {
|
|||||||
B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR,
|
B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR,
|
||||||
B_USB_RAW_COMMAND_GET_ALT_INTERFACE_COUNT,
|
B_USB_RAW_COMMAND_GET_ALT_INTERFACE_COUNT,
|
||||||
B_USB_RAW_COMMAND_GET_ACTIVE_ALT_INTERFACE_INDEX,
|
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_INTERFACE_DESCRIPTOR_ETC,
|
||||||
B_USB_RAW_COMMAND_GET_ENDPOINT_DESCRIPTOR_ETC,
|
B_USB_RAW_COMMAND_GET_ENDPOINT_DESCRIPTOR_ETC,
|
||||||
B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR_ETC,
|
B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR_ETC,
|
||||||
@@ -75,13 +74,6 @@ typedef union {
|
|||||||
uint32 config_index;
|
uint32 config_index;
|
||||||
} config;
|
} config;
|
||||||
|
|
||||||
struct {
|
|
||||||
status_t status;
|
|
||||||
usb_configuration_descriptor *descriptor;
|
|
||||||
uint32 config_index;
|
|
||||||
size_t length;
|
|
||||||
} config_etc;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
status_t status;
|
status_t status;
|
||||||
uint32 alternate_info;
|
uint32 alternate_info;
|
||||||
|
|||||||
@@ -8,12 +8,9 @@
|
|||||||
|
|
||||||
#include <USBKit.h>
|
#include <USBKit.h>
|
||||||
#include <usb_raw.h>
|
#include <usb_raw.h>
|
||||||
|
|
||||||
#include <new>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
|
||||||
BUSBConfiguration::BUSBConfiguration(BUSBDevice *device, uint32 index, int rawFD)
|
BUSBConfiguration::BUSBConfiguration(BUSBDevice *device, uint32 index, int rawFD)
|
||||||
@@ -21,36 +18,14 @@ BUSBConfiguration::BUSBConfiguration(BUSBDevice *device, uint32 index, int rawFD
|
|||||||
fIndex(index),
|
fIndex(index),
|
||||||
fRawFD(rawFD),
|
fRawFD(rawFD),
|
||||||
fInterfaces(NULL),
|
fInterfaces(NULL),
|
||||||
fConfigurationString(NULL),
|
fConfigurationString(NULL)
|
||||||
fFullDescriptor(NULL)
|
|
||||||
{
|
{
|
||||||
usb_raw_command command;
|
usb_raw_command command;
|
||||||
command.config.descriptor = &fDescriptor;
|
command.config.descriptor = &fDescriptor;
|
||||||
command.config.config_index = fIndex;
|
command.config.config_index = fIndex;
|
||||||
|
if (ioctl(fRawFD, B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR, &command,
|
||||||
if (ioctl(fRawFD, B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR,
|
sizeof(command)) || command.config.status != B_USB_RAW_STATUS_SUCCESS)
|
||||||
&command, sizeof(command))
|
|
||||||
|| command.config.status != B_USB_RAW_STATUS_SUCCESS) {
|
|
||||||
memset(&fDescriptor, 0, sizeof(fDescriptor));
|
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 *[
|
fInterfaces = new(std::nothrow) BUSBInterface *[
|
||||||
fDescriptor.number_interfaces];
|
fDescriptor.number_interfaces];
|
||||||
@@ -66,8 +41,6 @@ BUSBConfiguration::BUSBConfiguration(BUSBDevice *device, uint32 index, int rawFD
|
|||||||
|
|
||||||
BUSBConfiguration::~BUSBConfiguration()
|
BUSBConfiguration::~BUSBConfiguration()
|
||||||
{
|
{
|
||||||
free(fFullDescriptor);
|
|
||||||
|
|
||||||
delete[] fConfigurationString;
|
delete[] fConfigurationString;
|
||||||
if (fInterfaces != NULL) {
|
if (fInterfaces != NULL) {
|
||||||
for (int32 i = 0; i < fDescriptor.number_interfaces; i++)
|
for (int32 i = 0; i < fDescriptor.number_interfaces; i++)
|
||||||
@@ -112,7 +85,7 @@ BUSBConfiguration::ConfigurationString() const
|
|||||||
const usb_configuration_descriptor *
|
const usb_configuration_descriptor *
|
||||||
BUSBConfiguration::Descriptor() const
|
BUSBConfiguration::Descriptor() const
|
||||||
{
|
{
|
||||||
return (fFullDescriptor != NULL) ? fFullDescriptor : &fDescriptor;
|
return &fDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user