mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-28 04:17:47 +00:00
Staging: ced1401: Fixes 'open brace should be on the previous line'.
Fixes checkpatch warnings 'open brace should be on the previous line'. Signed-off-by: Elena Ufimtseva <ufimtseva@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d9f8374ba0
commit
e035b590a6
@ -118,8 +118,7 @@ int SendString(DEVICE_EXTENSION *pdx, const char __user *pData,
|
||||
buffer[n] = 0; /* terminate for debug purposes */
|
||||
|
||||
mutex_lock(&pdx->io_mutex); /* Protect disconnect from new i/o */
|
||||
if (n > 0) /* do nothing if nowt to do! */
|
||||
{
|
||||
if (n > 0) { /* do nothing if nowt to do! */
|
||||
dev_dbg(&pdx->interface->dev, "%s n=%d>%s<", __func__, n,
|
||||
buffer);
|
||||
iReturn = PutChars(pdx, buffer, n);
|
||||
@ -198,8 +197,7 @@ int Get1401State(DEVICE_EXTENSION *pdx, __u32 *state, __u32 *error)
|
||||
*error = pdx->statBuf[1];
|
||||
|
||||
nDevice = pdx->udev->descriptor.bcdDevice >> 8; /* 1401 type code value */
|
||||
switch (nDevice) /* so we can clean up current state */
|
||||
{
|
||||
switch (nDevice) { /* so we can clean up current state */
|
||||
case 0:
|
||||
pdx->sCurrentState = U14ERR_U1401;
|
||||
break;
|
||||
@ -232,8 +230,7 @@ int ReadWrite_Cancel(DEVICE_EXTENSION *pdx)
|
||||
/* We can fill this in when we know how we will implement the staged transfer stuff */
|
||||
spin_lock_irq(&pdx->stagedLock);
|
||||
|
||||
if (pdx->bStagedUrbPending) /* anything to be cancelled? May need more... */
|
||||
{
|
||||
if (pdx->bStagedUrbPending) { /* anything to be cancelled? May need more... */
|
||||
dev_info(&pdx->interface - dev,
|
||||
"ReadWrite_Cancel about to cancel Urb");
|
||||
/* Clear the staging done flag */
|
||||
@ -321,20 +318,17 @@ bool Is1401(DEVICE_EXTENSION *pdx)
|
||||
/* release the io_mutex because if we don't, we will deadlock due to system */
|
||||
/* calls back into the driver. */
|
||||
mutex_unlock(&pdx->io_mutex); /* locked, so we will not get system calls */
|
||||
if (iReturn >= 0) /* if we failed */
|
||||
{
|
||||
if (iReturn >= 0) { /* if we failed */
|
||||
iReturn = usb_reset_device(pdx->udev); /* try to do the reset */
|
||||
usb_unlock_device(pdx->udev); /* undo the lock */
|
||||
}
|
||||
|
||||
mutex_lock(&pdx->io_mutex); /* hold stuff off while we wait */
|
||||
pdx->dwDMAFlag = MODE_CHAR; /* Clear DMA mode flag regardless! */
|
||||
if (iReturn == 0) /* if all is OK still */
|
||||
{
|
||||
if (iReturn == 0) { /* if all is OK still */
|
||||
unsigned int state;
|
||||
iReturn = InSelfTest(pdx, &state); /* see if likely in self test */
|
||||
if (iReturn > 0) /* do we need to wait for self-test? */
|
||||
{
|
||||
if (iReturn > 0) { /* do we need to wait for self-test? */
|
||||
unsigned long ulTimeOut = jiffies + 30 * HZ; /* when to give up */
|
||||
while ((iReturn > 0) && time_before(jiffies, ulTimeOut)) {
|
||||
schedule(); /* let other stuff run */
|
||||
@ -380,26 +374,23 @@ bool QuickCheck(DEVICE_EXTENSION *pdx, bool bTestBuff, bool bCanReset)
|
||||
bTestBuff, bShortTest);
|
||||
|
||||
if ((bTestBuff) && /* Buffer check requested, and... */
|
||||
(pdx->dwNumInput || pdx->dwNumOutput)) /* ...characters were in the buffer? */
|
||||
{
|
||||
(pdx->dwNumInput || pdx->dwNumOutput)) { /* ...characters were in the buffer? */
|
||||
bShortTest = false; /* Then do the full test */
|
||||
dev_dbg(&pdx->interface->dev,
|
||||
"%s will reset as buffers not empty", __func__);
|
||||
}
|
||||
|
||||
if (bShortTest || !bCanReset) /* Still OK to try the short test? */
|
||||
{ /* Always test if no reset - we want state update */
|
||||
if (bShortTest || !bCanReset) { /* Still OK to try the short test? */
|
||||
/* Always test if no reset - we want state update */
|
||||
unsigned int state, error;
|
||||
dev_dbg(&pdx->interface->dev, "%s->Get1401State", __func__);
|
||||
if (Get1401State(pdx, &state, &error) == U14ERR_NOERROR) /* Check on the 1401 state */
|
||||
{
|
||||
if (Get1401State(pdx, &state, &error) == U14ERR_NOERROR) { /* Check on the 1401 state */
|
||||
if ((state & 0xFF) == 0) /* If call worked, check the status value */
|
||||
bRet = true; /* If that was zero, all is OK, no reset needed */
|
||||
}
|
||||
}
|
||||
|
||||
if (!bRet && bCanReset) /* If all not OK, then */
|
||||
{
|
||||
if (!bRet && bCanReset) { /* If all not OK, then */
|
||||
dev_info(&pdx->interface->dev, "%s->Is1401 %d %d %d %d",
|
||||
__func__, bShortTest, pdx->sCurrentState, bTestBuff,
|
||||
pdx->bForceReset);
|
||||
@ -439,8 +430,7 @@ int GetChar(DEVICE_EXTENSION *pdx)
|
||||
SendChars(pdx); /* and send any buffered chars */
|
||||
|
||||
spin_lock_irq(&pdx->charInLock);
|
||||
if (pdx->dwNumInput > 0) /* worth looking */
|
||||
{
|
||||
if (pdx->dwNumInput > 0) { /* worth looking */
|
||||
iReturn = pdx->inputBuffer[pdx->dwInBuffGet++];
|
||||
if (pdx->dwInBuffGet >= INBUF_SZ)
|
||||
pdx->dwInBuffGet = 0;
|
||||
@ -482,8 +472,7 @@ int GetString(DEVICE_EXTENSION *pdx, char __user *pUser, int n)
|
||||
if (nAvailable > n) /* read max of space in pUser... */
|
||||
nAvailable = n; /* ...or input characters */
|
||||
|
||||
if (nAvailable > 0) /* worth looking? */
|
||||
{
|
||||
if (nAvailable > 0) { /* worth looking? */
|
||||
char buffer[INBUF_SZ + 1]; /* space for a linear copy of data */
|
||||
int nGot = 0;
|
||||
int nCopyToUser; /* number to copy to user */
|
||||
@ -497,12 +486,10 @@ int GetString(DEVICE_EXTENSION *pdx, char __user *pUser, int n)
|
||||
pdx->dwInBuffGet = 0; /* wrap buffer pointer */
|
||||
|
||||
buffer[nGot++] = cData; /* save the output */
|
||||
}
|
||||
while ((nGot < nAvailable) && cData);
|
||||
} while ((nGot < nAvailable) && cData);
|
||||
|
||||
nCopyToUser = nGot; /* what to copy... */
|
||||
if (cData) /* do we need null */
|
||||
{
|
||||
if (cData) { /* do we need null */
|
||||
buffer[nGot] = (char)0; /* make it tidy */
|
||||
if (nGot < n) /* if space in user buffer... */
|
||||
++nCopyToUser; /* ...copy the 0 as well. */
|
||||
@ -556,8 +543,7 @@ int LineCount(DEVICE_EXTENSION *pdx)
|
||||
SendChars(pdx); /* and send any buffered chars */
|
||||
spin_lock_irq(&pdx->charInLock); /* Get protection */
|
||||
|
||||
if (pdx->dwNumInput > 0) /* worth looking? */
|
||||
{
|
||||
if (pdx->dwNumInput > 0) { /* worth looking? */
|
||||
unsigned int dwIndex = pdx->dwInBuffGet; /* start at first available */
|
||||
unsigned int dwEnd = pdx->dwInBuffPut; /* Position for search end */
|
||||
do {
|
||||
@ -566,8 +552,7 @@ int LineCount(DEVICE_EXTENSION *pdx)
|
||||
|
||||
if (dwIndex >= INBUF_SZ) /* see if we fall off buff */
|
||||
dwIndex = 0;
|
||||
}
|
||||
while (dwIndex != dwEnd); /* go to last available */
|
||||
} while (dwIndex != dwEnd); /* go to last available */
|
||||
}
|
||||
|
||||
spin_unlock_irq(&pdx->charInLock);
|
||||
@ -645,8 +630,7 @@ int ClearArea(DEVICE_EXTENSION *pdx, int nArea)
|
||||
}
|
||||
spin_unlock_irq(&pdx->stagedLock);
|
||||
|
||||
if (pPages) /* if we decided to release the memory */
|
||||
{
|
||||
if (pPages) { /* if we decided to release the memory */
|
||||
/* Now we must undo the pinning down of the pages. We will assume the worst and mark */
|
||||
/* all the pages as dirty. Don't be tempted to move this up above as you must not be */
|
||||
/* holding a spin lock to do this stuff as it is not atomic. */
|
||||
@ -714,8 +698,7 @@ static int SetArea(DEVICE_EXTENSION *pdx, int nArea, char __user *puBuf,
|
||||
up_read(¤t->mm->mmap_sem); /* release the semaphore */
|
||||
dev_dbg(&pdx->interface->dev, "%s nPages = %d", __func__, nPages);
|
||||
|
||||
if (nPages > 0) /* if we succeeded */
|
||||
{
|
||||
if (nPages > 0) { /* if we succeeded */
|
||||
/* If you are tempted to use page_address (form LDD3), forget it. You MUST use */
|
||||
/* kmap() or kmap_atomic() to get a virtual address. page_address will give you */
|
||||
/* (null) or at least it does in this context with an x86 machine. */
|
||||
@ -814,8 +797,7 @@ int SetEvent(DEVICE_EXTENSION *pdx, TRANSFEREVENT __user *pTE)
|
||||
TRANSAREA *pTA = &pdx->rTransDef[te.wAreaNum];
|
||||
mutex_lock(&pdx->io_mutex); /* make sure we have no competitor */
|
||||
spin_lock_irq(&pdx->stagedLock);
|
||||
if (pTA->bUsed) /* area must be in use */
|
||||
{
|
||||
if (pTA->bUsed) { /* area must be in use */
|
||||
pTA->dwEventSt = te.dwStart; /* set area regions */
|
||||
pTA->dwEventSz = te.dwLength; /* set size (0 cancels it) */
|
||||
pTA->bEventToHost = te.wFlags & 1; /* set the direction */
|
||||
@ -1030,8 +1012,8 @@ int CheckSelfTest(DEVICE_EXTENSION *pdx, TGET_SELFTEST __user *pGST)
|
||||
if (iReturn == U14ERR_NOERROR) /* Only accept zero if it happens twice */
|
||||
iReturn = Get1401State(pdx, &state, &error);
|
||||
|
||||
if (iReturn != U14ERR_NOERROR) /* Self-test can cause comms errors */
|
||||
{ /* so we assume still testing */
|
||||
if (iReturn != U14ERR_NOERROR) { /* Self-test can cause comms errors */
|
||||
/* so we assume still testing */
|
||||
dev_err(&pdx->interface->dev,
|
||||
"%s Get1401State=%d, assuming still testing", __func__,
|
||||
iReturn);
|
||||
@ -1040,8 +1022,7 @@ int CheckSelfTest(DEVICE_EXTENSION *pdx, TGET_SELFTEST __user *pGST)
|
||||
iReturn = U14ERR_NOERROR;
|
||||
}
|
||||
|
||||
if ((state == -1) && (error == -1)) /* If Get1401State had problems */
|
||||
{
|
||||
if ((state == -1) && (error == -1)) { /* If Get1401State had problems */
|
||||
dev_err(&pdx->interface->dev,
|
||||
"%s Get1401State failed, assuming still testing",
|
||||
__func__);
|
||||
@ -1049,17 +1030,14 @@ int CheckSelfTest(DEVICE_EXTENSION *pdx, TGET_SELFTEST __user *pGST)
|
||||
error = 0;
|
||||
}
|
||||
|
||||
if ((state & 0xFF) == 0x80) /* If we are still in self-test */
|
||||
{
|
||||
if (state & 0x00FF0000) /* Have we got an error? */
|
||||
{
|
||||
if ((state & 0xFF) == 0x80) { /* If we are still in self-test */
|
||||
if (state & 0x00FF0000) { /* Have we got an error? */
|
||||
gst.code = (state & 0x00FF0000) >> 16; /* read the error code */
|
||||
gst.x = error & 0x0000FFFF; /* Error data X */
|
||||
gst.y = (error & 0xFFFF0000) >> 16; /* and data Y */
|
||||
dev_dbg(&pdx->interface->dev, "Self-test error code %d",
|
||||
gst.code);
|
||||
} else /* No error, check for timeout */
|
||||
{
|
||||
} else { /* No error, check for timeout */
|
||||
unsigned long ulNow = jiffies; /* get current time */
|
||||
if (time_after(ulNow, pdx->ulSelfTestTime)) {
|
||||
gst.code = -2; /* Flag the timeout */
|
||||
@ -1074,8 +1052,8 @@ int CheckSelfTest(DEVICE_EXTENSION *pdx, TGET_SELFTEST __user *pGST)
|
||||
dev_dbg(&pdx->interface->dev, "Self-test done");
|
||||
}
|
||||
|
||||
if (gst.code < 0) /* If we have a problem or finished */
|
||||
{ /* If using the 2890 we should reset properly */
|
||||
if (gst.code < 0) { /* If we have a problem or finished */
|
||||
/* If using the 2890 we should reset properly */
|
||||
if ((pdx->nPipes == 4) && (pdx->s1401Type <= TYPEPOWER))
|
||||
Is1401(pdx); /* Get 1401 reset and OK */
|
||||
else
|
||||
@ -1384,16 +1362,13 @@ int GetCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user *pCB)
|
||||
cb.dwOffset = 0; /* set default result (nothing) */
|
||||
cb.dwSize = 0;
|
||||
|
||||
if (nArea < MAX_TRANSAREAS) /* The area number must be OK */
|
||||
{
|
||||
if (nArea < MAX_TRANSAREAS) { /* The area number must be OK */
|
||||
TRANSAREA *pArea = &pdx->rTransDef[nArea]; /* Pointer to relevant info */
|
||||
spin_lock_irq(&pdx->stagedLock); /* Lock others out */
|
||||
|
||||
if ((pArea->bUsed) && (pArea->bCircular) && /* Must be circular area */
|
||||
(pArea->bCircToHost)) /* For now at least must be to host */
|
||||
{
|
||||
if (pArea->aBlocks[0].dwSize > 0) /* Got anything? */
|
||||
{
|
||||
(pArea->bCircToHost)) { /* For now at least must be to host */
|
||||
if (pArea->aBlocks[0].dwSize > 0) { /* Got anything? */
|
||||
cb.dwOffset = pArea->aBlocks[0].dwOffset;
|
||||
cb.dwSize = pArea->aBlocks[0].dwSize;
|
||||
dev_dbg(&pdx->interface->dev,
|
||||
@ -1438,25 +1413,20 @@ int FreeCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user *pCB)
|
||||
cb.dwOffset = 0; /* then set default result (nothing) */
|
||||
cb.dwSize = 0;
|
||||
|
||||
if (nArea < MAX_TRANSAREAS) /* The area number must be OK */
|
||||
{
|
||||
if (nArea < MAX_TRANSAREAS) { /* The area number must be OK */
|
||||
TRANSAREA *pArea = &pdx->rTransDef[nArea]; /* Pointer to relevant info */
|
||||
spin_lock_irq(&pdx->stagedLock); /* Lock others out */
|
||||
|
||||
if ((pArea->bUsed) && (pArea->bCircular) && /* Must be circular area */
|
||||
(pArea->bCircToHost)) /* For now at least must be to host */
|
||||
{
|
||||
(pArea->bCircToHost)) { /* For now at least must be to host */
|
||||
bool bWaiting = false;
|
||||
|
||||
if ((pArea->aBlocks[0].dwSize >= uSize) && /* Got anything? */
|
||||
(pArea->aBlocks[0].dwOffset == uStart)) /* Must be legal data */
|
||||
{
|
||||
(pArea->aBlocks[0].dwOffset == uStart)) { /* Must be legal data */
|
||||
pArea->aBlocks[0].dwSize -= uSize;
|
||||
pArea->aBlocks[0].dwOffset += uSize;
|
||||
if (pArea->aBlocks[0].dwSize == 0) /* Have we emptied this block? */
|
||||
{
|
||||
if (pArea->aBlocks[1].dwSize) /* Is there a second block? */
|
||||
{
|
||||
if (pArea->aBlocks[0].dwSize == 0) { /* Have we emptied this block? */
|
||||
if (pArea->aBlocks[1].dwSize) { /* Is there a second block? */
|
||||
pArea->aBlocks[0] = pArea->aBlocks[1]; /* Copy down block 2 data */
|
||||
pArea->aBlocks[1].dwSize = 0; /* and mark the second block as unused */
|
||||
pArea->aBlocks[1].dwOffset = 0;
|
||||
@ -1472,8 +1442,7 @@ int FreeCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user *pCB)
|
||||
pdx->bXFerWaiting);
|
||||
|
||||
/* Return the next available block of memory as well */
|
||||
if (pArea->aBlocks[0].dwSize > 0) /* Got anything? */
|
||||
{
|
||||
if (pArea->aBlocks[0].dwSize > 0) { /* Got anything? */
|
||||
cb.dwOffset =
|
||||
pArea->aBlocks[0].dwOffset;
|
||||
cb.dwSize = pArea->aBlocks[0].dwSize;
|
||||
@ -1496,8 +1465,7 @@ int FreeCircBlock(DEVICE_EXTENSION *pdx, TCIRCBLOCK __user *pCB)
|
||||
}
|
||||
|
||||
/* If we have one, kick off pending transfer */
|
||||
if (bWaiting) /* Got a block xfer waiting? */
|
||||
{
|
||||
if (bWaiting) { /* Got a block xfer waiting? */
|
||||
int RWMStat =
|
||||
ReadWriteMem(pdx, !pdx->rDMAInfo.bOutWard,
|
||||
pdx->rDMAInfo.wIdent,
|
||||
|
@ -298,8 +298,7 @@ static void ced_writechar_callback(struct urb *pUrb)
|
||||
if (pdx->dwOutBuffGet >= OUTBUF_SZ) /* Can't do this any earlier as data could be overwritten */
|
||||
pdx->dwOutBuffGet = 0;
|
||||
|
||||
if (pdx->dwNumOutput > 0) /* if more to be done... */
|
||||
{
|
||||
if (pdx->dwNumOutput > 0) { /* if more to be done... */
|
||||
int nPipe = 0; /* The pipe number to use */
|
||||
int iReturn;
|
||||
char *pDat = &pdx->outputBuffer[pdx->dwOutBuffGet];
|
||||
@ -347,8 +346,7 @@ int SendChars(DEVICE_EXTENSION *pdx)
|
||||
|
||||
if ((!pdx->bSendCharsPending) && /* Not currently sending */
|
||||
(pdx->dwNumOutput > 0) && /* has characters to output */
|
||||
(CanAcceptIoRequests(pdx))) /* and current activity is OK */
|
||||
{
|
||||
(CanAcceptIoRequests(pdx))) { /* and current activity is OK */
|
||||
unsigned int dwCount = pdx->dwNumOutput; /* Get a copy of the character count */
|
||||
pdx->bSendCharsPending = true; /* Set flag to lock out other threads */
|
||||
|
||||
@ -543,8 +541,7 @@ static void staged_callback(struct urb *pUrb)
|
||||
pdx->StagedDone, pdx->StagedLength);
|
||||
|
||||
if ((pdx->StagedDone == pdx->StagedLength) || /* If no more to do */
|
||||
(bCancel)) /* or this IRP was cancelled */
|
||||
{
|
||||
(bCancel)) { /* or this IRP was cancelled */
|
||||
TRANSAREA *pArea = &pdx->rTransDef[pdx->StagedId]; /* Transfer area info */
|
||||
dev_dbg(&pdx->interface->dev,
|
||||
"%s transfer done, bytes %d, cancel %d", __func__,
|
||||
@ -555,10 +552,8 @@ static void staged_callback(struct urb *pUrb)
|
||||
/* add this to the end of a growing block or to use it to start a new block unless the code */
|
||||
/* that calculates the offset to use (in ReadWriteMem) is totally duff. */
|
||||
if ((pArea->bCircular) && (pArea->bCircToHost) && (!bCancel) && /* Time to sort out circular buffer info? */
|
||||
(pdx->StagedRead)) /* Only for tohost transfers for now */
|
||||
{
|
||||
if (pArea->aBlocks[1].dwSize > 0) /* If block 1 is in use we must append to it */
|
||||
{
|
||||
(pdx->StagedRead)) { /* Only for tohost transfers for now */
|
||||
if (pArea->aBlocks[1].dwSize > 0) { /* If block 1 is in use we must append to it */
|
||||
if (pdx->StagedOffset ==
|
||||
(pArea->aBlocks[1].dwOffset +
|
||||
pArea->aBlocks[1].dwSize)) {
|
||||
@ -580,10 +575,9 @@ static void staged_callback(struct urb *pUrb)
|
||||
pArea->aBlocks[1].dwSize,
|
||||
pArea->aBlocks[1].dwOffset);
|
||||
}
|
||||
} else /* If block 1 is not used, we try to add to block 0 */
|
||||
{
|
||||
if (pArea->aBlocks[0].dwSize > 0) /* Got stored block 0 information? */
|
||||
{ /* Must append onto the existing block 0 */
|
||||
} else { /* If block 1 is not used, we try to add to block 0 */
|
||||
if (pArea->aBlocks[0].dwSize > 0) { /* Got stored block 0 information? */
|
||||
/* Must append onto the existing block 0 */
|
||||
if (pdx->StagedOffset ==
|
||||
(pArea->aBlocks[0].dwOffset +
|
||||
pArea->aBlocks[0].dwSize)) {
|
||||
@ -594,8 +588,7 @@ static void staged_callback(struct urb *pUrb)
|
||||
dwSize,
|
||||
pArea->aBlocks[0].
|
||||
dwOffset);
|
||||
} else /* If it doesn't append, put into new block 1 */
|
||||
{
|
||||
} else { /* If it doesn't append, put into new block 1 */
|
||||
pArea->aBlocks[1].dwOffset =
|
||||
pdx->StagedOffset;
|
||||
pArea->aBlocks[1].dwSize =
|
||||
@ -607,8 +600,7 @@ static void staged_callback(struct urb *pUrb)
|
||||
pArea->aBlocks[1].
|
||||
dwOffset);
|
||||
}
|
||||
} else /* No info stored yet, just save in block 0 */
|
||||
{
|
||||
} else { /* No info stored yet, just save in block 0 */
|
||||
pArea->aBlocks[0].dwOffset =
|
||||
pdx->StagedOffset;
|
||||
pArea->aBlocks[0].dwSize =
|
||||
@ -621,21 +613,19 @@ static void staged_callback(struct urb *pUrb)
|
||||
}
|
||||
}
|
||||
|
||||
if (!bCancel) /* Don't generate an event if cancelled */
|
||||
{
|
||||
if (!bCancel) { /* Don't generate an event if cancelled */
|
||||
dev_dbg(&pdx->interface->dev,
|
||||
"RWM_Complete, bCircular %d, bToHost %d, eStart %d, eSize %d",
|
||||
pArea->bCircular, pArea->bEventToHost,
|
||||
pArea->dwEventSt, pArea->dwEventSz);
|
||||
if ((pArea->dwEventSz) && /* Set a user-mode event... */
|
||||
(pdx->StagedRead == pArea->bEventToHost)) /* ...on transfers in this direction? */
|
||||
{
|
||||
(pdx->StagedRead == pArea->bEventToHost)) { /* ...on transfers in this direction? */
|
||||
int iWakeUp = 0; /* assume */
|
||||
/* If we have completed the right sort of DMA transfer then set the event to notify */
|
||||
/* the user code to wake up anyone that is waiting. */
|
||||
if ((pArea->bCircular) && /* Circular areas use a simpler test */
|
||||
(pArea->bCircToHost)) /* only in supported direction */
|
||||
{ /* Is total data waiting up to size limit? */
|
||||
(pArea->bCircToHost)) { /* only in supported direction */
|
||||
/* Is total data waiting up to size limit? */
|
||||
unsigned int dwTotal =
|
||||
pArea->aBlocks[0].dwSize +
|
||||
pArea->aBlocks[1].dwSize;
|
||||
@ -661,11 +651,9 @@ static void staged_callback(struct urb *pUrb)
|
||||
|
||||
pdx->dwDMAFlag = MODE_CHAR; /* Switch back to char mode before ReadWriteMem call */
|
||||
|
||||
if (!bCancel) /* Don't look for waiting transfer if cancelled */
|
||||
{
|
||||
if (!bCancel) { /* Don't look for waiting transfer if cancelled */
|
||||
/* If we have a transfer waiting, kick it off */
|
||||
if (pdx->bXFerWaiting) /* Got a block xfer waiting? */
|
||||
{
|
||||
if (pdx->bXFerWaiting) { /* Got a block xfer waiting? */
|
||||
int iReturn;
|
||||
dev_info(&pdx->interface->dev,
|
||||
"*** RWM_Complete *** pending transfer will now be set up!!!");
|
||||
@ -719,8 +707,7 @@ static int StageChunk(DEVICE_EXTENSION *pdx)
|
||||
if (nPipe < 0) /* and trap case that should never happen */
|
||||
return U14ERR_FAIL;
|
||||
|
||||
if (!CanAcceptIoRequests(pdx)) /* got sudden remove? */
|
||||
{
|
||||
if (!CanAcceptIoRequests(pdx)) { /* got sudden remove? */
|
||||
dev_info(&pdx->interface->dev, "%s sudden remove, giving up",
|
||||
__func__);
|
||||
return U14ERR_FAIL; /* could do with a better error */
|
||||
@ -777,8 +764,7 @@ int ReadWriteMem(DEVICE_EXTENSION *pdx, bool Read, unsigned short wIdent,
|
||||
{
|
||||
TRANSAREA *pArea = &pdx->rTransDef[wIdent]; /* Transfer area info */
|
||||
|
||||
if (!CanAcceptIoRequests(pdx)) /* Are we in a state to accept new requests? */
|
||||
{
|
||||
if (!CanAcceptIoRequests(pdx)) { /* Are we in a state to accept new requests? */
|
||||
dev_err(&pdx->interface->dev, "%s can't accept requests",
|
||||
__func__);
|
||||
return U14ERR_FAIL;
|
||||
@ -798,36 +784,32 @@ int ReadWriteMem(DEVICE_EXTENSION *pdx, bool Read, unsigned short wIdent,
|
||||
return U14ERR_NOERROR;
|
||||
}
|
||||
|
||||
if (dwLen == 0) /* allow 0-len read or write; just return success */
|
||||
{
|
||||
if (dwLen == 0) { /* allow 0-len read or write; just return success */
|
||||
dev_dbg(&pdx->interface->dev,
|
||||
"%s OK; zero-len read/write request", __func__);
|
||||
return U14ERR_NOERROR;
|
||||
}
|
||||
|
||||
if ((pArea->bCircular) && /* Circular transfer? */
|
||||
(pArea->bCircToHost) && (Read)) /* In a supported direction */
|
||||
{ /* If so, we sort out offset ourself */
|
||||
(pArea->bCircToHost) && (Read)) { /* In a supported direction */
|
||||
/* If so, we sort out offset ourself */
|
||||
bool bWait = false; /* Flag for transfer having to wait */
|
||||
|
||||
dev_dbg(&pdx->interface->dev,
|
||||
"Circular buffers are %d at %d and %d at %d",
|
||||
pArea->aBlocks[0].dwSize, pArea->aBlocks[0].dwOffset,
|
||||
pArea->aBlocks[1].dwSize, pArea->aBlocks[1].dwOffset);
|
||||
if (pArea->aBlocks[1].dwSize > 0) /* Using the second block already? */
|
||||
{
|
||||
if (pArea->aBlocks[1].dwSize > 0) { /* Using the second block already? */
|
||||
dwOffs = pArea->aBlocks[1].dwOffset + pArea->aBlocks[1].dwSize; /* take offset from that */
|
||||
bWait = (dwOffs + dwLen) > pArea->aBlocks[0].dwOffset; /* Wait if will overwrite block 0? */
|
||||
bWait |= (dwOffs + dwLen) > pArea->dwLength; /* or if it overflows the buffer */
|
||||
} else /* Area 1 not in use, try to use area 0 */
|
||||
{
|
||||
} else { /* Area 1 not in use, try to use area 0 */
|
||||
if (pArea->aBlocks[0].dwSize == 0) /* Reset block 0 if not in use */
|
||||
pArea->aBlocks[0].dwOffset = 0;
|
||||
dwOffs =
|
||||
pArea->aBlocks[0].dwOffset +
|
||||
pArea->aBlocks[0].dwSize;
|
||||
if ((dwOffs + dwLen) > pArea->dwLength) /* Off the end of the buffer? */
|
||||
{
|
||||
if ((dwOffs + dwLen) > pArea->dwLength) { /* Off the end of the buffer? */
|
||||
pArea->aBlocks[1].dwOffset = 0; /* Set up to use second block */
|
||||
dwOffs = 0;
|
||||
bWait = (dwOffs + dwLen) > pArea->aBlocks[0].dwOffset; /* Wait if will overwrite block 0? */
|
||||
@ -835,8 +817,7 @@ int ReadWriteMem(DEVICE_EXTENSION *pdx, bool Read, unsigned short wIdent,
|
||||
}
|
||||
}
|
||||
|
||||
if (bWait) /* This transfer will have to wait? */
|
||||
{
|
||||
if (bWait) { /* This transfer will have to wait? */
|
||||
pdx->bXFerWaiting = true; /* Flag we are waiting */
|
||||
dev_dbg(&pdx->interface->dev,
|
||||
"%s xfer waiting for circular buffer space",
|
||||
@ -877,8 +858,7 @@ static bool ReadChar(unsigned char *pChar, char *pBuf, unsigned int *pdDone,
|
||||
bool bRead = false;
|
||||
unsigned int dDone = *pdDone;
|
||||
|
||||
if (dDone < dGot) /* If there is more data */
|
||||
{
|
||||
if (dDone < dGot) { /* If there is more data */
|
||||
*pChar = (unsigned char)pBuf[dDone]; /* Extract the next char */
|
||||
dDone++; /* Increment the done count */
|
||||
*pdDone = dDone;
|
||||
@ -1057,13 +1037,12 @@ static int Handle1401Esc(DEVICE_EXTENSION *pdx, char *pCh,
|
||||
/* I have no idea what this next test is about. '?' is 0x3f, which is area 3, code */
|
||||
/* 15. At the moment, this is not used, so it does no harm, but unless someone can */
|
||||
/* tell me what this is for, it should be removed from this and the Windows driver. */
|
||||
if (pCh[0] == '?') /* Is this an information response */
|
||||
{ /* Parse and save the information */
|
||||
if (pCh[0] == '?') { /* Is this an information response */
|
||||
/* Parse and save the information */
|
||||
} else {
|
||||
spin_lock(&pdx->stagedLock); /* Lock others out */
|
||||
|
||||
if (ReadDMAInfo(&pdx->rDMAInfo, pdx, pCh, dwCount)) /* Get DMA parameters */
|
||||
{
|
||||
if (ReadDMAInfo(&pdx->rDMAInfo, pdx, pCh, dwCount)) { /* Get DMA parameters */
|
||||
unsigned short wTransType = pdx->rDMAInfo.wTransType; /* check transfer type */
|
||||
|
||||
dev_dbg(&pdx->interface->dev,
|
||||
@ -1071,11 +1050,11 @@ static int Handle1401Esc(DEVICE_EXTENSION *pdx, char *pCh,
|
||||
pdx->rDMAInfo.bOutWard ? "1401" : "host",
|
||||
pdx->rDMAInfo.dwOffset, pdx->rDMAInfo.dwSize);
|
||||
|
||||
if (pdx->bXFerWaiting) /* Check here for badly out of kilter... */
|
||||
{ /* This can never happen, really */
|
||||
if (pdx->bXFerWaiting) { /* Check here for badly out of kilter... */
|
||||
/* This can never happen, really */
|
||||
dev_err(&pdx->interface->dev,
|
||||
"ERROR: DMA setup while transfer still waiting");
|
||||
spin_unlock(&pdx->stagedLock);
|
||||
spin_unlock(&pdx->stagedLock);
|
||||
} else {
|
||||
if ((wTransType == TM_EXTTOHOST)
|
||||
|| (wTransType == TM_EXTTO1401)) {
|
||||
@ -1115,8 +1094,7 @@ static void ced_readchar_callback(struct urb *pUrb)
|
||||
DEVICE_EXTENSION *pdx = pUrb->context;
|
||||
int nGot = pUrb->actual_length; /* what we transferred */
|
||||
|
||||
if (pUrb->status) /* Do we have a problem to handle? */
|
||||
{
|
||||
if (pUrb->status) { /* Do we have a problem to handle? */
|
||||
int nPipe = pdx->nPipes == 4 ? 1 : 0; /* The pipe number to use for error */
|
||||
/* sync/async unlink faults aren't errors... just saying device removed or stopped */
|
||||
if (!
|
||||
@ -1138,8 +1116,7 @@ static void ced_readchar_callback(struct urb *pUrb)
|
||||
spin_lock(&pdx->charInLock); /* already at irq level */
|
||||
pdx->bPipeError[nPipe] = 1; /* Flag an error for later */
|
||||
} else {
|
||||
if ((nGot > 1) && ((pdx->pCoherCharIn[0] & 0x7f) == 0x1b)) /* Esc sequence? */
|
||||
{
|
||||
if ((nGot > 1) && ((pdx->pCoherCharIn[0] & 0x7f) == 0x1b)) { /* Esc sequence? */
|
||||
Handle1401Esc(pdx, &pdx->pCoherCharIn[1], nGot - 1); /* handle it */
|
||||
spin_lock(&pdx->charInLock); /* already at irq level */
|
||||
} else {
|
||||
@ -1197,8 +1174,8 @@ int Allowi(DEVICE_EXTENSION *pdx)
|
||||
(pdx->dwNumInput < (INBUF_SZ / 2)) && /* and there is some space */
|
||||
(pdx->dwDMAFlag == MODE_CHAR) && /* not doing any DMA */
|
||||
(!pdx->bXFerWaiting) && /* no xfer waiting to start */
|
||||
(CanAcceptIoRequests(pdx))) /* and activity is generally OK */
|
||||
{ /* then off we go */
|
||||
(CanAcceptIoRequests(pdx))) { /* and activity is generally OK */
|
||||
/* then off we go */
|
||||
unsigned int nMax = INBUF_SZ - pdx->dwNumInput; /* max we could read */
|
||||
int nPipe = pdx->nPipes == 4 ? 1 : 0; /* The pipe number to use */
|
||||
|
||||
@ -1394,8 +1371,7 @@ static int ced_probe(struct usb_interface *interface,
|
||||
if (!pdx)
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < MAX_TRANSAREAS; ++i) /* Initialise the wait queues */
|
||||
{
|
||||
for (i = 0; i < MAX_TRANSAREAS; ++i) { /* Initialise the wait queues */
|
||||
init_waitqueue_head(&pdx->rTransDef[i].wqEvent);
|
||||
}
|
||||
|
||||
@ -1471,8 +1447,7 @@ static int ced_probe(struct usb_interface *interface,
|
||||
pdx->bInterval);
|
||||
}
|
||||
/* Detect USB2 by checking last ep size (64 if USB1) */
|
||||
if (i == pdx->nPipes - 1) /* if this is the last ep (bulk) */
|
||||
{
|
||||
if (i == pdx->nPipes - 1) { /* if this is the last ep (bulk) */
|
||||
pdx->bIsUSB2 =
|
||||
le16_to_cpu(endpoint->wMaxPacketSize) > 64;
|
||||
dev_info(&pdx->interface->dev, "USB%d",
|
||||
|
@ -93,16 +93,14 @@
|
||||
#define CR_CHAR_80 0x8d /* and with bit 7 set */
|
||||
|
||||
/* A structure holding information about a block of memory for use in circular transfers */
|
||||
typedef struct circBlk
|
||||
{
|
||||
typedef struct circBlk {
|
||||
volatile UINT dwOffset; /* Offset within area of block start */
|
||||
volatile UINT dwSize; /* Size of the block, in bytes (0 = unused) */
|
||||
} CIRCBLK;
|
||||
|
||||
/* A structure holding all of the information about a transfer area - an area of */
|
||||
/* memory set up for use either as a source or destination in DMA transfers. */
|
||||
typedef struct transarea
|
||||
{
|
||||
typedef struct transarea {
|
||||
void *lpvBuff; /* User address of xfer area saved for completeness */
|
||||
UINT dwBaseOffset; /* offset to start of xfer area in first page */
|
||||
UINT dwLength; /* Length of xfer area, in bytes */
|
||||
@ -121,8 +119,7 @@ typedef struct transarea
|
||||
|
||||
/* The DMADESC structure is used to hold information on the transfer in progress. It */
|
||||
/* is set up by ReadDMAInfo, using information sent by the 1401 in an escape sequence. */
|
||||
typedef struct dmadesc
|
||||
{
|
||||
typedef struct dmadesc {
|
||||
unsigned short wTransType; /* transfer type as TM_xxx above */
|
||||
unsigned short wIdent; /* identifier word */
|
||||
unsigned int dwSize; /* bytes to transfer */
|
||||
@ -136,8 +133,7 @@ typedef struct dmadesc
|
||||
|
||||
/* Structure to hold all of our device specific stuff. We are making this as similar as we */
|
||||
/* can to the Windows driver to help in our understanding of what is going on. */
|
||||
typedef struct _DEVICE_EXTENSION
|
||||
{
|
||||
typedef struct _DEVICE_EXTENSION {
|
||||
char inputBuffer[INBUF_SZ]; /* The two buffers */
|
||||
char outputBuffer[OUTBUF_SZ]; /* accessed by the host functions */
|
||||
volatile unsigned int dwNumInput; /* num of chars in input buffer */
|
||||
|
@ -269,8 +269,7 @@ typedef union /* to communicate with 1401 driver status & control funcs */
|
||||
|
||||
typedef TCSBLOCK* LPTCSBLOCK;
|
||||
|
||||
typedef struct paramBlk
|
||||
{
|
||||
typedef struct paramBlk {
|
||||
short sState;
|
||||
TCSBLOCK csBlock;
|
||||
} PARAMBLK;
|
||||
|
Loading…
Reference in New Issue
Block a user