staging: ced1401: rename members of struct transarea
Rename members with CamelCase and Hungarian notation Signed-off-by: Luca Ellero <luca.ellero@brickedbrain.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
077e02d039
commit
3d50f62ae3
3 changed files with 152 additions and 142 deletions
|
@ -595,7 +595,7 @@ int ced_clear_area(struct ced_data *ced, int nArea)
|
|||
} else {
|
||||
/* to save typing */
|
||||
struct transarea *pTA = &ced->rTransDef[nArea];
|
||||
if (!pTA->bUsed) /* if not used... */
|
||||
if (!pTA->used) /* if not used... */
|
||||
iReturn = U14ERR_NOTSET; /* ...nothing to be done */
|
||||
else {
|
||||
/* We must save the memory we return as we shouldn't mess with memory while */
|
||||
|
@ -614,17 +614,17 @@ int ced_clear_area(struct ced_data *ced, int nArea)
|
|||
"%s: call on area %d while active\n",
|
||||
__func__, nArea);
|
||||
} else {
|
||||
pPages = pTA->pPages; /* save page address list */
|
||||
nPages = pTA->nPages; /* and page count */
|
||||
if (pTA->dwEventSz) /* if events flagging in use */
|
||||
wake_up_interruptible(&pTA->wqEvent); /* release anything that was waiting */
|
||||
pPages = pTA->pages; /* save page address list */
|
||||
nPages = pTA->n_pages; /* and page count */
|
||||
if (pTA->event_sz) /* if events flagging in use */
|
||||
wake_up_interruptible(&pTA->event); /* release anything that was waiting */
|
||||
|
||||
if (ced->bXFerWaiting
|
||||
&& (ced->rDMAInfo.wIdent == nArea))
|
||||
ced->bXFerWaiting = false; /* Cannot have pending xfer if area cleared */
|
||||
|
||||
/* Clean out the struct transarea except for the wait queue, which is at the end */
|
||||
/* This sets bUsed to false and dwEventSz to 0 to say area not used and no events. */
|
||||
/* This sets used to false and event_sz to 0 to say area not used and no events. */
|
||||
memset(pTA, 0,
|
||||
sizeof(struct transarea) -
|
||||
sizeof(wait_queue_head_t));
|
||||
|
@ -701,20 +701,20 @@ static int ced_set_area(struct ced_data *ced, int nArea, char __user *puBuf,
|
|||
/* 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. */
|
||||
spin_lock_irq(&ced->stagedLock);
|
||||
pTA->lpvBuff = puBuf; /* keep start of region (user address) */
|
||||
pTA->dwBaseOffset = ulOffset; /* save offset in first page to start of xfer */
|
||||
pTA->dwLength = dwLength; /* Size if the region in bytes */
|
||||
pTA->pPages = pPages; /* list of pages that are used by buffer */
|
||||
pTA->nPages = nPages; /* number of pages */
|
||||
pTA->buff = puBuf; /* keep start of region (user address) */
|
||||
pTA->base_offset = ulOffset; /* save offset in first page to start of xfer */
|
||||
pTA->length = dwLength; /* Size if the region in bytes */
|
||||
pTA->pages = pPages; /* list of pages that are used by buffer */
|
||||
pTA->n_pages = nPages; /* number of pages */
|
||||
|
||||
pTA->bCircular = bCircular;
|
||||
pTA->bCircToHost = bCircToHost;
|
||||
pTA->circular = bCircular;
|
||||
pTA->circ_to_host = bCircToHost;
|
||||
|
||||
pTA->aBlocks[0].offset = 0;
|
||||
pTA->aBlocks[0].size = 0;
|
||||
pTA->aBlocks[1].offset = 0;
|
||||
pTA->aBlocks[1].size = 0;
|
||||
pTA->bUsed = true; /* This is now a used block */
|
||||
pTA->blocks[0].offset = 0;
|
||||
pTA->blocks[0].size = 0;
|
||||
pTA->blocks[1].offset = 0;
|
||||
pTA->blocks[1].size = 0;
|
||||
pTA->used = true; /* This is now a used block */
|
||||
|
||||
spin_unlock_irq(&ced->stagedLock);
|
||||
iReturn = U14ERR_NOERROR; /* say all was well */
|
||||
|
@ -795,11 +795,11 @@ int ced_set_event(struct ced_data *ced, struct transfer_event __user *pTE)
|
|||
struct transarea *pTA = &ced->rTransDef[te.wAreaNum];
|
||||
mutex_lock(&ced->io_mutex); /* make sure we have no competitor */
|
||||
spin_lock_irq(&ced->stagedLock);
|
||||
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 */
|
||||
pTA->iWakeUp = 0; /* zero the wake up count */
|
||||
if (pTA->used) { /* area must be in use */
|
||||
pTA->event_st = te.dwStart; /* set area regions */
|
||||
pTA->event_sz = te.dwLength; /* set size (0 cancels it) */
|
||||
pTA->event_to_host = te.wFlags & 1; /* set the direction */
|
||||
pTA->wake_up = 0; /* zero the wake up count */
|
||||
} else
|
||||
iReturn = U14ERR_NOTSET;
|
||||
spin_unlock_irq(&ced->stagedLock);
|
||||
|
@ -830,27 +830,27 @@ int ced_wait_event(struct ced_data *ced, int nArea, int msTimeOut)
|
|||
/* releasing it and the wait call. However, this would have to clear the */
|
||||
/* iWakeUp flag. However, the !pTA-bUsed may help us in this case. */
|
||||
mutex_lock(&ced->io_mutex); /* make sure we have no competitor */
|
||||
if (!pTA->bUsed || !pTA->dwEventSz) /* check something to wait for... */
|
||||
if (!pTA->used || !pTA->event_sz) /* check something to wait for... */
|
||||
return U14ERR_NOTSET; /* ...else we do nothing */
|
||||
mutex_unlock(&ced->io_mutex);
|
||||
|
||||
if (msTimeOut)
|
||||
iWait =
|
||||
wait_event_interruptible_timeout(pTA->wqEvent,
|
||||
pTA->iWakeUp
|
||||
|| !pTA->bUsed,
|
||||
wait_event_interruptible_timeout(pTA->event,
|
||||
pTA->wake_up
|
||||
|| !pTA->used,
|
||||
msTimeOut);
|
||||
else
|
||||
iWait =
|
||||
wait_event_interruptible(pTA->wqEvent, pTA->iWakeUp
|
||||
|| !pTA->bUsed);
|
||||
wait_event_interruptible(pTA->event, pTA->wake_up
|
||||
|| !pTA->used);
|
||||
if (iWait)
|
||||
iReturn = -ERESTARTSYS; /* oops - we have had a SIGNAL */
|
||||
else
|
||||
iReturn = pTA->iWakeUp; /* else the wakeup count */
|
||||
iReturn = pTA->wake_up; /* else the wakeup count */
|
||||
|
||||
spin_lock_irq(&ced->stagedLock);
|
||||
pTA->iWakeUp = 0; /* clear the flag */
|
||||
pTA->wake_up = 0; /* clear the flag */
|
||||
spin_unlock_irq(&ced->stagedLock);
|
||||
}
|
||||
return iReturn;
|
||||
|
@ -871,8 +871,8 @@ int ced_test_event(struct ced_data *ced, int nArea)
|
|||
struct transarea *pTA = &ced->rTransDef[nArea];
|
||||
mutex_lock(&ced->io_mutex); /* make sure we have no competitor */
|
||||
spin_lock_irq(&ced->stagedLock);
|
||||
iReturn = pTA->iWakeUp; /* get wakeup count since last call */
|
||||
pTA->iWakeUp = 0; /* clear the count */
|
||||
iReturn = pTA->wake_up; /* get wakeup count since last call */
|
||||
pTA->wake_up = 0; /* clear the count */
|
||||
spin_unlock_irq(&ced->stagedLock);
|
||||
mutex_unlock(&ced->io_mutex);
|
||||
}
|
||||
|
@ -901,8 +901,8 @@ int ced_get_transfer(struct ced_data *ced, TGET_TX_BLOCK __user *pTX)
|
|||
mutex_unlock(&ced->io_mutex);
|
||||
return -ENOMEM;
|
||||
}
|
||||
tx->size = ced->rTransDef[dwIdent].dwLength;
|
||||
tx->linear = (long long)((long)ced->rTransDef[dwIdent].lpvBuff);
|
||||
tx->size = ced->rTransDef[dwIdent].length;
|
||||
tx->linear = (long long)((long)ced->rTransDef[dwIdent].buff);
|
||||
tx->avail = GET_TX_MAXENTRIES; /* how many blocks we could return */
|
||||
tx->used = 1; /* number we actually return */
|
||||
tx->entries[0].physical =
|
||||
|
@ -1359,11 +1359,11 @@ int ced_get_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
|
|||
struct transarea *pArea = &ced->rTransDef[nArea];
|
||||
spin_lock_irq(&ced->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].size > 0) { /* Got anything? */
|
||||
cb.dwOffset = pArea->aBlocks[0].offset;
|
||||
cb.dwSize = pArea->aBlocks[0].size;
|
||||
if ((pArea->used) && (pArea->circular) && /* Must be circular area */
|
||||
(pArea->circ_to_host)) { /* For now at least must be to host */
|
||||
if (pArea->blocks[0].size > 0) { /* Got anything? */
|
||||
cb.dwOffset = pArea->blocks[0].offset;
|
||||
cb.dwSize = pArea->blocks[0].size;
|
||||
dev_dbg(&ced->interface->dev,
|
||||
"%s: return block 0: %d bytes at %d\n",
|
||||
__func__, cb.dwSize, cb.dwOffset);
|
||||
|
@ -1411,35 +1411,35 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
|
|||
struct transarea *pArea = &ced->rTransDef[nArea];
|
||||
spin_lock_irq(&ced->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->used) && (pArea->circular) && /* Must be circular area */
|
||||
(pArea->circ_to_host)) { /* For now at least must be to host */
|
||||
bool bWaiting = false;
|
||||
|
||||
if ((pArea->aBlocks[0].size >= uSize) && /* Got anything? */
|
||||
(pArea->aBlocks[0].offset == uStart)) { /* Must be legal data */
|
||||
pArea->aBlocks[0].size -= uSize;
|
||||
pArea->aBlocks[0].offset += uSize;
|
||||
if (pArea->aBlocks[0].size == 0) { /* Have we emptied this block? */
|
||||
if (pArea->aBlocks[1].size) { /* Is there a second block? */
|
||||
pArea->aBlocks[0] = pArea->aBlocks[1]; /* Copy down block 2 data */
|
||||
pArea->aBlocks[1].size = 0; /* and mark the second block as unused */
|
||||
pArea->aBlocks[1].offset = 0;
|
||||
if ((pArea->blocks[0].size >= uSize) && /* Got anything? */
|
||||
(pArea->blocks[0].offset == uStart)) { /* Must be legal data */
|
||||
pArea->blocks[0].size -= uSize;
|
||||
pArea->blocks[0].offset += uSize;
|
||||
if (pArea->blocks[0].size == 0) { /* Have we emptied this block? */
|
||||
if (pArea->blocks[1].size) { /* Is there a second block? */
|
||||
pArea->blocks[0] = pArea->blocks[1]; /* Copy down block 2 data */
|
||||
pArea->blocks[1].size = 0; /* and mark the second block as unused */
|
||||
pArea->blocks[1].offset = 0;
|
||||
} else
|
||||
pArea->aBlocks[0].offset = 0;
|
||||
pArea->blocks[0].offset = 0;
|
||||
}
|
||||
|
||||
dev_dbg(&ced->interface->dev,
|
||||
"%s: free %d bytes at %d, return %d bytes at %d, wait=%d\n",
|
||||
__func__, uSize, uStart,
|
||||
pArea->aBlocks[0].size,
|
||||
pArea->aBlocks[0].offset,
|
||||
pArea->blocks[0].size,
|
||||
pArea->blocks[0].offset,
|
||||
ced->bXFerWaiting);
|
||||
|
||||
/* Return the next available block of memory as well */
|
||||
if (pArea->aBlocks[0].size > 0) { /* Got anything? */
|
||||
if (pArea->blocks[0].size > 0) { /* Got anything? */
|
||||
cb.dwOffset =
|
||||
pArea->aBlocks[0].offset;
|
||||
cb.dwSize = pArea->aBlocks[0].size;
|
||||
pArea->blocks[0].offset;
|
||||
cb.dwSize = pArea->blocks[0].size;
|
||||
}
|
||||
|
||||
bWaiting = ced->bXFerWaiting;
|
||||
|
@ -1453,8 +1453,8 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
|
|||
dev_err(&ced->interface->dev,
|
||||
"%s: ERROR: freeing %d bytes at %d, block 0 is %d bytes at %d\n",
|
||||
__func__, uSize, uStart,
|
||||
pArea->aBlocks[0].size,
|
||||
pArea->aBlocks[0].offset);
|
||||
pArea->blocks[0].size,
|
||||
pArea->blocks[0].offset);
|
||||
iReturn = U14ERR_NOMEMORY;
|
||||
}
|
||||
|
||||
|
|
|
@ -444,9 +444,9 @@ static void ced_copy_user_space(struct ced_data *ced, int n)
|
|||
/* area to be used */
|
||||
struct transarea *pArea = &ced->rTransDef[nArea];
|
||||
unsigned int dwOffset =
|
||||
ced->StagedDone + ced->StagedOffset + pArea->dwBaseOffset;
|
||||
ced->StagedDone + ced->StagedOffset + pArea->base_offset;
|
||||
char *pCoherBuf = ced->pCoherStagedIO; /* coherent buffer */
|
||||
if (!pArea->bUsed) {
|
||||
if (!pArea->used) {
|
||||
dev_err(&ced->interface->dev, "%s: area %d unused\n",
|
||||
__func__, nArea);
|
||||
return;
|
||||
|
@ -454,9 +454,9 @@ static void ced_copy_user_space(struct ced_data *ced, int n)
|
|||
|
||||
while (n) {
|
||||
int nPage = dwOffset >> PAGE_SHIFT; /* page number in table */
|
||||
if (nPage < pArea->nPages) {
|
||||
if (nPage < pArea->n_pages) {
|
||||
char *pvAddress =
|
||||
(char *)kmap_atomic(pArea->pPages[nPage]);
|
||||
(char *)kmap_atomic(pArea->pages[nPage]);
|
||||
if (pvAddress) {
|
||||
unsigned int uiPageOff = dwOffset & (PAGE_SIZE - 1); /* offset into the page */
|
||||
size_t uiXfer = PAGE_SIZE - uiPageOff; /* max to transfer on this page */
|
||||
|
@ -552,64 +552,64 @@ static void staged_callback(struct urb *pUrb)
|
|||
/* a completed transfer that can be assumed to fit into the transfer area. We should be able to */
|
||||
/* 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 ced_read_write_mem) is totally duff. */
|
||||
if ((pArea->bCircular) && (pArea->bCircToHost) && (!bCancel) && /* Time to sort out circular buffer info? */
|
||||
if ((pArea->circular) && (pArea->circ_to_host) && (!bCancel) && /* Time to sort out circular buffer info? */
|
||||
(ced->StagedRead)) { /* Only for tohost transfers for now */
|
||||
if (pArea->aBlocks[1].size > 0) { /* If block 1 is in use we must append to it */
|
||||
if (pArea->blocks[1].size > 0) { /* If block 1 is in use we must append to it */
|
||||
if (ced->StagedOffset ==
|
||||
(pArea->aBlocks[1].offset +
|
||||
pArea->aBlocks[1].size)) {
|
||||
pArea->aBlocks[1].size +=
|
||||
(pArea->blocks[1].offset +
|
||||
pArea->blocks[1].size)) {
|
||||
pArea->blocks[1].size +=
|
||||
ced->StagedLength;
|
||||
dev_dbg(&ced->interface->dev,
|
||||
"RWM_Complete, circ block 1 now %d bytes at %d\n",
|
||||
pArea->aBlocks[1].size,
|
||||
pArea->aBlocks[1].offset);
|
||||
pArea->blocks[1].size,
|
||||
pArea->blocks[1].offset);
|
||||
} else {
|
||||
/* Here things have gone very, very, wrong, but I cannot see how this can actually be achieved */
|
||||
pArea->aBlocks[1].offset =
|
||||
pArea->blocks[1].offset =
|
||||
ced->StagedOffset;
|
||||
pArea->aBlocks[1].size =
|
||||
pArea->blocks[1].size =
|
||||
ced->StagedLength;
|
||||
dev_err(&ced->interface->dev,
|
||||
"%s: ERROR, circ block 1 re-started %d bytes at %d\n",
|
||||
__func__,
|
||||
pArea->aBlocks[1].size,
|
||||
pArea->aBlocks[1].offset);
|
||||
pArea->blocks[1].size,
|
||||
pArea->blocks[1].offset);
|
||||
}
|
||||
} else { /* If block 1 is not used, we try to add to block 0 */
|
||||
if (pArea->aBlocks[0].size > 0) { /* Got stored block 0 information? */
|
||||
if (pArea->blocks[0].size > 0) { /* Got stored block 0 information? */
|
||||
/* Must append onto the existing block 0 */
|
||||
if (ced->StagedOffset ==
|
||||
(pArea->aBlocks[0].offset +
|
||||
pArea->aBlocks[0].size)) {
|
||||
pArea->aBlocks[0].size += ced->StagedLength; /* Just add this transfer in */
|
||||
(pArea->blocks[0].offset +
|
||||
pArea->blocks[0].size)) {
|
||||
pArea->blocks[0].size += ced->StagedLength; /* Just add this transfer in */
|
||||
dev_dbg(&ced->interface->dev,
|
||||
"RWM_Complete, circ block 0 now %d bytes at %d\n",
|
||||
pArea->aBlocks[0].
|
||||
pArea->blocks[0].
|
||||
size,
|
||||
pArea->aBlocks[0].
|
||||
pArea->blocks[0].
|
||||
offset);
|
||||
} else { /* If it doesn't append, put into new block 1 */
|
||||
pArea->aBlocks[1].offset =
|
||||
pArea->blocks[1].offset =
|
||||
ced->StagedOffset;
|
||||
pArea->aBlocks[1].size =
|
||||
pArea->blocks[1].size =
|
||||
ced->StagedLength;
|
||||
dev_dbg(&ced->interface->dev,
|
||||
"RWM_Complete, circ block 1 started %d bytes at %d\n",
|
||||
pArea->aBlocks[1].
|
||||
pArea->blocks[1].
|
||||
size,
|
||||
pArea->aBlocks[1].
|
||||
pArea->blocks[1].
|
||||
offset);
|
||||
}
|
||||
} else { /* No info stored yet, just save in block 0 */
|
||||
pArea->aBlocks[0].offset =
|
||||
pArea->blocks[0].offset =
|
||||
ced->StagedOffset;
|
||||
pArea->aBlocks[0].size =
|
||||
pArea->blocks[0].size =
|
||||
ced->StagedLength;
|
||||
dev_dbg(&ced->interface->dev,
|
||||
"RWM_Complete, circ block 0 started %d bytes at %d\n",
|
||||
pArea->aBlocks[0].size,
|
||||
pArea->aBlocks[0].offset);
|
||||
pArea->blocks[0].size,
|
||||
pArea->blocks[0].offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -617,35 +617,38 @@ static void staged_callback(struct urb *pUrb)
|
|||
if (!bCancel) { /* Don't generate an event if cancelled */
|
||||
dev_dbg(&ced->interface->dev,
|
||||
"RWM_Complete, bCircular %d, bToHost %d, eStart %d, eSize %d\n",
|
||||
pArea->bCircular, pArea->bEventToHost,
|
||||
pArea->dwEventSt, pArea->dwEventSz);
|
||||
if ((pArea->dwEventSz) && /* Set a user-mode event... */
|
||||
(ced->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 */
|
||||
pArea->circular, pArea->event_to_host,
|
||||
pArea->event_st, pArea->event_sz);
|
||||
if ((pArea->event_sz) && /* Set a user-mode event... */
|
||||
(ced->StagedRead == pArea->event_to_host)) { /* ...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->circular) && /* Circular areas use a simpler test */
|
||||
(pArea->circ_to_host)) { /* only in supported direction */
|
||||
/* Is total data waiting up to size limit? */
|
||||
unsigned int dwTotal =
|
||||
pArea->aBlocks[0].size +
|
||||
pArea->aBlocks[1].size;
|
||||
iWakeUp = (dwTotal >= pArea->dwEventSz);
|
||||
pArea->blocks[0].size +
|
||||
pArea->blocks[1].size;
|
||||
iWakeUp = (dwTotal >= pArea->event_sz);
|
||||
} else {
|
||||
unsigned int transEnd =
|
||||
ced->StagedOffset +
|
||||
ced->StagedLength;
|
||||
unsigned int eventEnd =
|
||||
pArea->dwEventSt + pArea->dwEventSz;
|
||||
pArea->event_st + pArea->event_sz;
|
||||
iWakeUp = (ced->StagedOffset < eventEnd)
|
||||
&& (transEnd > pArea->dwEventSt);
|
||||
&& (transEnd > pArea->event_st);
|
||||
}
|
||||
|
||||
if (iWakeUp) {
|
||||
dev_dbg(&ced->interface->dev,
|
||||
"About to set event to notify app\n");
|
||||
wake_up_interruptible(&pArea->wqEvent); /* wake up waiting processes */
|
||||
++pArea->iWakeUp; /* increment wakeup count */
|
||||
wake_up_interruptible(&pArea->event); /* wake up waiting processes */
|
||||
++pArea->wake_up; /* increment wakeup count */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -792,30 +795,30 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent,
|
|||
return U14ERR_NOERROR;
|
||||
}
|
||||
|
||||
if ((pArea->bCircular) && /* Circular transfer? */
|
||||
(pArea->bCircToHost) && (Read)) { /* In a supported direction */
|
||||
if ((pArea->circular) && /* Circular transfer? */
|
||||
(pArea->circ_to_host) && (Read)) { /* In a supported direction */
|
||||
/* If so, we sort out offset ourself */
|
||||
bool bWait = false; /* Flag for transfer having to wait */
|
||||
|
||||
dev_dbg(&ced->interface->dev,
|
||||
"Circular buffers are %d at %d and %d at %d\n",
|
||||
pArea->aBlocks[0].size, pArea->aBlocks[0].offset,
|
||||
pArea->aBlocks[1].size, pArea->aBlocks[1].offset);
|
||||
if (pArea->aBlocks[1].size > 0) { /* Using the second block already? */
|
||||
dwOffs = pArea->aBlocks[1].offset + pArea->aBlocks[1].size; /* take offset from that */
|
||||
bWait = (dwOffs + dwLen) > pArea->aBlocks[0].offset; /* Wait if will overwrite block 0? */
|
||||
bWait |= (dwOffs + dwLen) > pArea->dwLength; /* or if it overflows the buffer */
|
||||
pArea->blocks[0].size, pArea->blocks[0].offset,
|
||||
pArea->blocks[1].size, pArea->blocks[1].offset);
|
||||
if (pArea->blocks[1].size > 0) { /* Using the second block already? */
|
||||
dwOffs = pArea->blocks[1].offset + pArea->blocks[1].size; /* take offset from that */
|
||||
bWait = (dwOffs + dwLen) > pArea->blocks[0].offset; /* Wait if will overwrite block 0? */
|
||||
bWait |= (dwOffs + dwLen) > pArea->length; /* or if it overflows the buffer */
|
||||
} else { /* Area 1 not in use, try to use area 0 */
|
||||
if (pArea->aBlocks[0].size == 0) /* Reset block 0 if not in use */
|
||||
pArea->aBlocks[0].offset = 0;
|
||||
if (pArea->blocks[0].size == 0) /* Reset block 0 if not in use */
|
||||
pArea->blocks[0].offset = 0;
|
||||
dwOffs =
|
||||
pArea->aBlocks[0].offset +
|
||||
pArea->aBlocks[0].size;
|
||||
if ((dwOffs + dwLen) > pArea->dwLength) { /* Off the end of the buffer? */
|
||||
pArea->aBlocks[1].offset = 0; /* Set up to use second block */
|
||||
pArea->blocks[0].offset +
|
||||
pArea->blocks[0].size;
|
||||
if ((dwOffs + dwLen) > pArea->length) { /* Off the end of the buffer? */
|
||||
pArea->blocks[1].offset = 0; /* Set up to use second block */
|
||||
dwOffs = 0;
|
||||
bWait = (dwOffs + dwLen) > pArea->aBlocks[0].offset; /* Wait if will overwrite block 0? */
|
||||
bWait |= (dwOffs + dwLen) > pArea->dwLength; /* or if it overflows the buffer */
|
||||
bWait = (dwOffs + dwLen) > pArea->blocks[0].offset; /* Wait if will overwrite block 0? */
|
||||
bWait |= (dwOffs + dwLen) > pArea->length; /* or if it overflows the buffer */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -985,22 +988,22 @@ static bool ced_read_dma_info(volatile struct dmadesc *pDmaDesc,
|
|||
pDmaDesc->dwSize);
|
||||
|
||||
if ((wIdent >= MAX_TRANSAREAS) || /* Illegal area number, or... */
|
||||
(!ced->rTransDef[wIdent].bUsed) || /* area not set up, or... */
|
||||
(pDmaDesc->dwOffset > ced->rTransDef[wIdent].dwLength) || /* range/size */
|
||||
(!ced->rTransDef[wIdent].used) || /* area not set up, or... */
|
||||
(pDmaDesc->dwOffset > ced->rTransDef[wIdent].length) || /* range/size */
|
||||
((pDmaDesc->dwOffset +
|
||||
pDmaDesc->dwSize) >
|
||||
(ced->rTransDef[wIdent].
|
||||
dwLength))) {
|
||||
length))) {
|
||||
bResult = false; /* bad parameter(s) */
|
||||
dev_dbg(&ced->interface->dev,
|
||||
"%s: bad param - id %d, bUsed %d, offset %d, size %d, area length %d\n",
|
||||
__func__, wIdent,
|
||||
ced->rTransDef[wIdent].
|
||||
bUsed,
|
||||
used,
|
||||
pDmaDesc->dwOffset,
|
||||
pDmaDesc->dwSize,
|
||||
ced->rTransDef[wIdent].
|
||||
dwLength);
|
||||
length);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1376,7 +1379,7 @@ static int ced_probe(struct usb_interface *interface,
|
|||
goto error;
|
||||
|
||||
for (i = 0; i < MAX_TRANSAREAS; ++i) { /* Initialise the wait queues */
|
||||
init_waitqueue_head(&ced->rTransDef[i].wqEvent);
|
||||
init_waitqueue_head(&ced->rTransDef[i].event);
|
||||
}
|
||||
|
||||
/* Put initialises for our stuff here. Note that all of *ced is zero, so */
|
||||
|
|
|
@ -99,23 +99,30 @@ struct circ_blk {
|
|||
volatile UINT size; /* Size of the block, in bytes (0 = unused) */
|
||||
};
|
||||
|
||||
/* 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. */
|
||||
/* 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. */
|
||||
struct transarea {
|
||||
void __user *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 */
|
||||
struct page **pPages; /* Points at array of locked down pages */
|
||||
int nPages; /* number of pages that are locked down */
|
||||
bool bUsed; /* Is this structure in use? */
|
||||
bool bCircular; /* Is this area for circular transfers? */
|
||||
bool bCircToHost; /* Flag for direction of circular transfer */
|
||||
bool bEventToHost; /* Set event on transfer to host? */
|
||||
int iWakeUp; /* Set 1 on event, cleared by TestEvent() */
|
||||
UINT dwEventSt; /* Defines section within xfer area for... */
|
||||
UINT dwEventSz; /* ...notification by the event SZ is 0 if unset */
|
||||
struct circ_blk aBlocks[2]; /* Info on a pair of circular blocks */
|
||||
wait_queue_head_t wqEvent; /* The wait queue for events in this area MUST BE LAST */
|
||||
/* User address of xfer area saved for completeness */
|
||||
void __user *buff;
|
||||
|
||||
/* offset to start of xfer area in first page */
|
||||
UINT base_offset;
|
||||
|
||||
UINT length; /* Length of xfer area, in bytes */
|
||||
struct page **pages; /* Points at array of locked down pages */
|
||||
int n_pages; /* number of pages that are locked down */
|
||||
bool used; /* Is this structure in use? */
|
||||
bool circular; /* Is this area for circular transfers? */
|
||||
bool circ_to_host; /* Flag for direction of circular transfer */
|
||||
bool event_to_host; /* Set event on transfer to host? */
|
||||
int wake_up; /* Set 1 on event, cleared by TestEvent() */
|
||||
UINT event_st; /* Defines section within xfer area for... */
|
||||
UINT event_sz; /* notification by the event SZ is 0 if unset */
|
||||
struct circ_blk blocks[2]; /* Info on a pair of circular blocks */
|
||||
|
||||
wait_queue_head_t event; /* The wait queue for events in this */
|
||||
/* area MUST BE LAST */
|
||||
};
|
||||
|
||||
/* The DMADESC structure is used to hold information on the transfer in progress. It */
|
||||
|
|
Loading…
Add table
Reference in a new issue