pTA->bCircular = bCircular;
pTA->bCircToHost = bCircToHost;
- pTA->aBlocks[0].dwOffset = 0;
- pTA->aBlocks[0].dwSize = 0;
- pTA->aBlocks[1].dwOffset = 0;
- pTA->aBlocks[1].dwSize = 0;
+ 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 */
spin_unlock_irq(&ced->stagedLock);
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? */
- cb.dwOffset = pArea->aBlocks[0].dwOffset;
- cb.dwSize = pArea->aBlocks[0].dwSize;
+ if (pArea->aBlocks[0].size > 0) { /* Got anything? */
+ cb.dwOffset = pArea->aBlocks[0].offset;
+ cb.dwSize = pArea->aBlocks[0].size;
dev_dbg(&ced->interface->dev,
"%s: return block 0: %d bytes at %d\n",
__func__, cb.dwSize, cb.dwOffset);
(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].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].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].dwSize = 0; /* and mark the second block as unused */
- pArea->aBlocks[1].dwOffset = 0;
+ pArea->aBlocks[1].size = 0; /* and mark the second block as unused */
+ pArea->aBlocks[1].offset = 0;
} else
- pArea->aBlocks[0].dwOffset = 0;
+ pArea->aBlocks[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].dwSize,
- pArea->aBlocks[0].dwOffset,
+ pArea->aBlocks[0].size,
+ pArea->aBlocks[0].offset,
ced->bXFerWaiting);
/* Return the next available block of memory as well */
- if (pArea->aBlocks[0].dwSize > 0) { /* Got anything? */
+ if (pArea->aBlocks[0].size > 0) { /* Got anything? */
cb.dwOffset =
- pArea->aBlocks[0].dwOffset;
- cb.dwSize = pArea->aBlocks[0].dwSize;
+ pArea->aBlocks[0].offset;
+ cb.dwSize = pArea->aBlocks[0].size;
}
bWaiting = ced->bXFerWaiting;
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].dwSize,
- pArea->aBlocks[0].dwOffset);
+ pArea->aBlocks[0].size,
+ pArea->aBlocks[0].offset);
iReturn = U14ERR_NOMEMORY;
}
/* 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? */
(ced->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 (pArea->aBlocks[1].size > 0) { /* If block 1 is in use we must append to it */
if (ced->StagedOffset ==
- (pArea->aBlocks[1].dwOffset +
- pArea->aBlocks[1].dwSize)) {
- pArea->aBlocks[1].dwSize +=
+ (pArea->aBlocks[1].offset +
+ pArea->aBlocks[1].size)) {
+ pArea->aBlocks[1].size +=
ced->StagedLength;
dev_dbg(&ced->interface->dev,
"RWM_Complete, circ block 1 now %d bytes at %d\n",
- pArea->aBlocks[1].dwSize,
- pArea->aBlocks[1].dwOffset);
+ pArea->aBlocks[1].size,
+ pArea->aBlocks[1].offset);
} else {
/* Here things have gone very, very, wrong, but I cannot see how this can actually be achieved */
- pArea->aBlocks[1].dwOffset =
+ pArea->aBlocks[1].offset =
ced->StagedOffset;
- pArea->aBlocks[1].dwSize =
+ pArea->aBlocks[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].dwSize,
- pArea->aBlocks[1].dwOffset);
+ pArea->aBlocks[1].size,
+ pArea->aBlocks[1].offset);
}
} 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? */
+ if (pArea->aBlocks[0].size > 0) { /* Got stored block 0 information? */
/* Must append onto the existing block 0 */
if (ced->StagedOffset ==
- (pArea->aBlocks[0].dwOffset +
- pArea->aBlocks[0].dwSize)) {
- pArea->aBlocks[0].dwSize += ced->StagedLength; /* Just add this transfer in */
+ (pArea->aBlocks[0].offset +
+ pArea->aBlocks[0].size)) {
+ pArea->aBlocks[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].
- dwSize,
+ size,
pArea->aBlocks[0].
- dwOffset);
+ offset);
} else { /* If it doesn't append, put into new block 1 */
- pArea->aBlocks[1].dwOffset =
+ pArea->aBlocks[1].offset =
ced->StagedOffset;
- pArea->aBlocks[1].dwSize =
+ pArea->aBlocks[1].size =
ced->StagedLength;
dev_dbg(&ced->interface->dev,
"RWM_Complete, circ block 1 started %d bytes at %d\n",
pArea->aBlocks[1].
- dwSize,
+ size,
pArea->aBlocks[1].
- dwOffset);
+ offset);
}
} else { /* No info stored yet, just save in block 0 */
- pArea->aBlocks[0].dwOffset =
+ pArea->aBlocks[0].offset =
ced->StagedOffset;
- pArea->aBlocks[0].dwSize =
+ pArea->aBlocks[0].size =
ced->StagedLength;
dev_dbg(&ced->interface->dev,
"RWM_Complete, circ block 0 started %d bytes at %d\n",
- pArea->aBlocks[0].dwSize,
- pArea->aBlocks[0].dwOffset);
+ pArea->aBlocks[0].size,
+ pArea->aBlocks[0].offset);
}
}
}
(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;
+ pArea->aBlocks[0].size +
+ pArea->aBlocks[1].size;
iWakeUp = (dwTotal >= pArea->dwEventSz);
} else {
unsigned int transEnd =
dev_dbg(&ced->interface->dev,
"Circular buffers are %d at %d and %d at %d\n",
- 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? */
- 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? */
+ 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 */
} 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;
+ if (pArea->aBlocks[0].size == 0) /* Reset block 0 if not in use */
+ pArea->aBlocks[0].offset = 0;
dwOffs =
- pArea->aBlocks[0].dwOffset +
- pArea->aBlocks[0].dwSize;
+ pArea->aBlocks[0].offset +
+ pArea->aBlocks[0].size;
if ((dwOffs + dwLen) > pArea->dwLength) { /* Off the end of the buffer? */
- pArea->aBlocks[1].dwOffset = 0; /* Set up to use second block */
+ pArea->aBlocks[1].offset = 0; /* Set up to use second block */
dwOffs = 0;
- bWait = (dwOffs + dwLen) > pArea->aBlocks[0].dwOffset; /* Wait if will overwrite block 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 */
}
}