* Check for the removed case before doing any transfers.

* Cancel possibly active transfers when removed.
* Do not interpret the transfer buffer in case of an error or removal.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25658 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2008-05-25 22:29:41 +00:00
parent 9e48bf8e42
commit 32ab216c85
3 changed files with 28 additions and 0 deletions
@@ -275,6 +275,7 @@ void
HIDDevice::Removed()
{
fRemoved = true;
gUSBModule->cancel_queued_transfers(fInterruptPipe);
}
@@ -297,6 +298,8 @@ HIDDevice::_ScheduleTransfer()
{
if (fTransferUnprocessed)
return B_BUSY;
if (fRemoved)
return B_ERROR;
status_t result = gUSBModule->queue_interrupt(fInterruptPipe,
fTransferBuffer, fTotalReportSize, _TransferCallback, this);
@@ -106,6 +106,9 @@ KeyboardDevice::_WriteKey(uint32 key, bool down)
status_t
KeyboardDevice::_SetLEDs(uint8 *data)
{
if (IsRemoved())
return B_ERROR;
uint8 leds = 0;
if (data[0] == 1)
leds |= (1 << 0);
@@ -126,6 +129,17 @@ KeyboardDevice::_SetLEDs(uint8 *data)
status_t
KeyboardDevice::_InterpretBuffer()
{
if (fTransferStatus != B_OK) {
if (IsRemoved())
return B_ERROR;
if (gUSBModule->clear_feature(fInterruptPipe,
USB_FEATURE_ENDPOINT_HALT) != B_OK)
return B_ERROR;
return B_OK;
}
static uint32 sModifierTable[] = {
KEY_ControlL,
KEY_ShiftL,
@@ -78,6 +78,17 @@ MouseDevice::Control(uint32 op, void *buffer, size_t length)
status_t
MouseDevice::_InterpretBuffer()
{
if (fTransferStatus != B_OK) {
if (IsRemoved())
return B_ERROR;
if (gUSBModule->clear_feature(fInterruptPipe,
USB_FEATURE_ENDPOINT_HALT) != B_OK)
return B_ERROR;
return B_OK;
}
mouse_movement info;
memset(&info, 0, sizeof(info));
for (size_t i = 0; i < fInstructionCount; i++) {