* Initialize all of the fields in the UHCI class so in case of an error in the

constructor the object can be safely deleted (as documented for bug #1473)
* Some simplifications by caching the Pipe object for a transfer
* Minor cleanup

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24954 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2008-04-13 05:56:10 +00:00
parent 6ad23dbbf4
commit 656af4e869
+15 -13
View File
@@ -292,14 +292,19 @@ UHCI::UHCI(pci_info *info, Stack *stack)
fStack(stack), fStack(stack),
fFrameArea(-1), fFrameArea(-1),
fFrameList(NULL), fFrameList(NULL),
fFrameBandwidth(NULL),
fFirstIsochronousDescriptor(NULL),
fLastIsochronousDescriptor(NULL),
fQueueCount(0), fQueueCount(0),
fQueues(NULL), fQueues(NULL),
fFirstTransfer(NULL), fFirstTransfer(NULL),
fLastTransfer(NULL), fLastTransfer(NULL),
fFinishTransfersSem(-1),
fFinishThread(-1), fFinishThread(-1),
fStopFinishThread(false), fStopFinishThread(false),
fFirstIsochronousTransfer(NULL), fFirstIsochronousTransfer(NULL),
fLastIsochronousTransfer(NULL), fLastIsochronousTransfer(NULL),
fFinishIsochronousTransfersSem(-1),
fFinishIsochronousThread(-1), fFinishIsochronousThread(-1),
fStopFinishIsochronousThread(false), fStopFinishIsochronousThread(false),
fRootHub(NULL), fRootHub(NULL),
@@ -561,16 +566,17 @@ status_t
UHCI::SubmitTransfer(Transfer *transfer) UHCI::SubmitTransfer(Transfer *transfer)
{ {
// Short circuit the root hub // Short circuit the root hub
if (transfer->TransferPipe()->DeviceAddress() == fRootHubAddress) Pipe *pipe = transfer->TransferPipe();
if (pipe->DeviceAddress() == fRootHubAddress)
return fRootHub->ProcessTransfer(this, transfer); return fRootHub->ProcessTransfer(this, transfer);
TRACE(("usb_uhci: submit transfer called for device %d\n", TRACE(("usb_uhci: submit transfer called for device %d\n",
transfer->TransferPipe()->DeviceAddress())); pipe->DeviceAddress()));
if (transfer->TransferPipe()->Type() & USB_OBJECT_CONTROL_PIPE) if (pipe->Type() & USB_OBJECT_CONTROL_PIPE)
return SubmitRequest(transfer); return SubmitRequest(transfer);
// Process isochronous transfers // Process isochronous transfers
if (transfer->TransferPipe()->Type() & USB_OBJECT_ISO_PIPE) if (pipe->Type() & USB_OBJECT_ISO_PIPE)
return SubmitIsochronous(transfer); return SubmitIsochronous(transfer);
uhci_td *firstDescriptor = NULL; uhci_td *firstDescriptor = NULL;
@@ -581,12 +587,10 @@ UHCI::SubmitTransfer(Transfer *transfer)
return result; return result;
Queue *queue = NULL; Queue *queue = NULL;
Pipe *pipe = transfer->TransferPipe(); if (pipe->Type() & USB_OBJECT_INTERRUPT_PIPE)
if (pipe->Type() & USB_OBJECT_INTERRUPT_PIPE) {
queue = fQueues[UHCI_INTERRUPT_QUEUE]; queue = fQueues[UHCI_INTERRUPT_QUEUE];
} else { else
queue = fQueues[UHCI_BULK_QUEUE]; queue = fQueues[UHCI_BULK_QUEUE];
}
bool directionIn = (pipe->Direction() == Pipe::In); bool directionIn = (pipe->Direction() == Pipe::In);
result = AddPendingTransfer(transfer, queue, transferQueue, result = AddPendingTransfer(transfer, queue, transferQueue,
@@ -727,11 +731,10 @@ UHCI::SubmitRequest(Transfer *transfer)
} }
Queue *queue = NULL; Queue *queue = NULL;
if (pipe->Speed() == USB_SPEED_LOWSPEED) { if (pipe->Speed() == USB_SPEED_LOWSPEED)
queue = fQueues[UHCI_LOW_SPEED_CONTROL_QUEUE]; queue = fQueues[UHCI_LOW_SPEED_CONTROL_QUEUE];
} else { else
queue = fQueues[UHCI_FULL_SPEED_CONTROL_QUEUE]; queue = fQueues[UHCI_FULL_SPEED_CONTROL_QUEUE];
}
uhci_qh *transferQueue = CreateTransferQueue(setupDescriptor); uhci_qh *transferQueue = CreateTransferQueue(setupDescriptor);
status_t result = AddPendingTransfer(transfer, queue, transferQueue, status_t result = AddPendingTransfer(transfer, queue, transferQueue,
@@ -844,8 +847,7 @@ UHCI::SubmitIsochronous(Transfer *transfer)
packetSize /= isochronousData->packet_count; packetSize /= isochronousData->packet_count;
uint16 currentFrame; uint16 currentFrame;
if (packetSize > pipe->MaxPacketSize()) if (packetSize > pipe->MaxPacketSize()) {
{
TRACE_ERROR(("usb_uhci: isochronous packetSize is bigger" TRACE_ERROR(("usb_uhci: isochronous packetSize is bigger"
" than pipe MaxPacketSize\n")); " than pipe MaxPacketSize\n"));
return B_BAD_VALUE; return B_BAD_VALUE;