Commit 3d50f62a authored by Luca Ellero's avatar Luca Ellero Committed by Greg Kroah-Hartman

staging: ced1401: rename members of struct transarea

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