Removed transfer buffer in usb_raw driver. The user provided buffers are now used directly which saves two memcpy operations and removes the 4K transfer length restriction from the USBKit.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20417 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -447,18 +447,12 @@ usb_raw_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case RAW_COMMAND_CONTROL_TRANSFER: {
|
case RAW_COMMAND_CONTROL_TRANSFER: {
|
||||||
if (command->control.length > B_PAGE_SIZE) {
|
|
||||||
command->control.status = RAW_STATUS_FAILED;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
benaphore_lock(&device->lock);
|
benaphore_lock(&device->lock);
|
||||||
memcpy(device->buffer, command->control.data, command->control.length);
|
|
||||||
if (gUSBModule->queue_request(device->device,
|
if (gUSBModule->queue_request(device->device,
|
||||||
command->control.request_type, command->control.request,
|
command->control.request_type, command->control.request,
|
||||||
command->control.value, command->control.index,
|
command->control.value, command->control.index,
|
||||||
command->control.length, device->buffer, usb_raw_callback,
|
command->control.length, command->control.data,
|
||||||
device) < B_OK) {
|
usb_raw_callback, device) < B_OK) {
|
||||||
command->control.status = RAW_STATUS_FAILED;
|
command->control.status = RAW_STATUS_FAILED;
|
||||||
command->control.length = 0;
|
command->control.length = 0;
|
||||||
benaphore_unlock(&device->lock);
|
benaphore_unlock(&device->lock);
|
||||||
@@ -466,7 +460,6 @@ usb_raw_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
acquire_sem(device->notify);
|
acquire_sem(device->notify);
|
||||||
memcpy(command->control.data, device->buffer, command->control.length);
|
|
||||||
command->control.status = device->status;
|
command->control.status = device->status;
|
||||||
command->control.length = device->actual_length;
|
command->control.length = device->actual_length;
|
||||||
benaphore_unlock(&device->lock);
|
benaphore_unlock(&device->lock);
|
||||||
@@ -475,11 +468,6 @@ usb_raw_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
|
|||||||
|
|
||||||
case RAW_COMMAND_INTERRUPT_TRANSFER:
|
case RAW_COMMAND_INTERRUPT_TRANSFER:
|
||||||
case RAW_COMMAND_BULK_TRANSFER: {
|
case RAW_COMMAND_BULK_TRANSFER: {
|
||||||
if (command->transfer.length > B_PAGE_SIZE) {
|
|
||||||
command->transfer.status = RAW_STATUS_FAILED;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
const usb_configuration_info *configurationInfo =
|
const usb_configuration_info *configurationInfo =
|
||||||
gUSBModule->get_configuration(device->device);
|
gUSBModule->get_configuration(device->device);
|
||||||
if (!configurationInfo) {
|
if (!configurationInfo) {
|
||||||
@@ -512,17 +500,16 @@ usb_raw_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
benaphore_lock(&device->lock);
|
benaphore_lock(&device->lock);
|
||||||
memcpy(device->buffer, command->transfer.data, command->transfer.length);
|
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
if (op == RAW_COMMAND_INTERRUPT_TRANSFER) {
|
if (op == RAW_COMMAND_INTERRUPT_TRANSFER) {
|
||||||
status = gUSBModule->queue_interrupt(endpointInfo->handle,
|
status = gUSBModule->queue_interrupt(endpointInfo->handle,
|
||||||
device->buffer, command->transfer.length, usb_raw_callback,
|
command->transfer.data, command->transfer.length,
|
||||||
device);
|
usb_raw_callback, device);
|
||||||
} else {
|
} else {
|
||||||
status = gUSBModule->queue_bulk(endpointInfo->handle,
|
status = gUSBModule->queue_bulk(endpointInfo->handle,
|
||||||
device->buffer, command->transfer.length, usb_raw_callback,
|
command->transfer.data, command->transfer.length,
|
||||||
device);
|
usb_raw_callback, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status < B_OK) {
|
if (status < B_OK) {
|
||||||
@@ -533,7 +520,6 @@ usb_raw_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
acquire_sem(device->notify);
|
acquire_sem(device->notify);
|
||||||
memcpy(command->transfer.data, device->buffer, command->transfer.length);
|
|
||||||
command->transfer.status = device->status;
|
command->transfer.status = device->status;
|
||||||
command->transfer.length = device->actual_length;
|
command->transfer.length = device->actual_length;
|
||||||
benaphore_unlock(&device->lock);
|
benaphore_unlock(&device->lock);
|
||||||
|
|||||||
@@ -141,8 +141,6 @@ typedef struct {
|
|||||||
sem_id notify;
|
sem_id notify;
|
||||||
status_t status;
|
status_t status;
|
||||||
size_t actual_length;
|
size_t actual_length;
|
||||||
|
|
||||||
uint8 buffer[B_PAGE_SIZE];
|
|
||||||
} raw_device;
|
} raw_device;
|
||||||
|
|
||||||
#endif // _USB_RAW_H_
|
#endif // _USB_RAW_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user