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

staging: ced1401: fix ced_read_write_mem()

Rename camel case arguments and locals in function ced_read_write_mem()
Signed-off-by: default avatarLuca Ellero <luca.ellero@brickedbrain.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 31e6a5bf
...@@ -825,19 +825,20 @@ static int ced_stage_chunk(struct ced_data *ced) ...@@ -825,19 +825,20 @@ static int ced_stage_chunk(struct ced_data *ced)
** **
** Arguments: ** Arguments:
** DeviceObject - pointer to our FDO (Functional Device Object) ** DeviceObject - pointer to our FDO (Functional Device Object)
** Read - TRUE for read, FALSE for write. This is from POV of the driver ** read - TRUE for read, FALSE for write. This is from POV of the driver
** wIdent - the transfer area number - defines memory area and more. ** ident - the transfer area number - defines memory area and more.
** dwOffs - the start offset within the transfer area of the start of this ** offs - the start offset within the transfer area of the start of this
** transfer. ** transfer.
** dwLen - the number of bytes to transfer. ** len - the number of bytes to transfer.
*/ */
int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent, int ced_read_write_mem(struct ced_data *ced, bool read, unsigned short ident,
unsigned int dwOffs, unsigned int dwLen) unsigned int offs, unsigned int len)
{ {
/* Transfer area info */ /* Transfer area info */
struct transarea *pArea = &ced->trans_def[wIdent]; struct transarea *ta = &ced->trans_def[ident];
if (!can_accept_io_requests(ced)) { /* Are we in a state to accept new requests? */ /* Are we in a state to accept new requests? */
if (!can_accept_io_requests(ced)) {
dev_err(&ced->interface->dev, "%s: can't accept requests\n", dev_err(&ced->interface->dev, "%s: can't accept requests\n",
__func__); __func__);
return U14ERR_FAIL; return U14ERR_FAIL;
...@@ -845,10 +846,11 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent, ...@@ -845,10 +846,11 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent,
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: xfer %d bytes to %s, offset %d, area %d\n", "%s: xfer %d bytes to %s, offset %d, area %d\n",
__func__, dwLen, Read ? "host" : "1401", dwOffs, wIdent); __func__, len, read ? "host" : "1401", offs, ident);
/* Amazingly, we can get an escape sequence back before the current staged Urb is done, so we */ /* Amazingly, we can get an escape sequence back before the current */
/* have to check for this situation and, if so, wait until all is OK. */ /* staged Urb is done, so we have to check for this situation and, if */
/* so, wait until all is OK. */
if (ced->staged_urb_pending) { if (ced->staged_urb_pending) {
ced->xfer_waiting = true; /* Flag we are waiting */ ced->xfer_waiting = true; /* Flag we are waiting */
dev_info(&ced->interface->dev, dev_info(&ced->interface->dev,
...@@ -857,36 +859,46 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent, ...@@ -857,36 +859,46 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent,
return U14ERR_NOERROR; return U14ERR_NOERROR;
} }
if (dwLen == 0) { /* allow 0-len read or write; just return success */ if (len == 0) { /* allow 0-len read or write; just return success */
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: OK; zero-len read/write request\n", __func__); "%s: OK; zero-len read/write request\n", __func__);
return U14ERR_NOERROR; return U14ERR_NOERROR;
} }
if ((pArea->circular) && /* Circular transfer? */ if ((ta->circular) && /* Circular transfer? */
(pArea->circ_to_host) && (Read)) { /* In a supported direction */ (ta->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->blocks[0].size, pArea->blocks[0].offset, ta->blocks[0].size, ta->blocks[0].offset,
pArea->blocks[1].size, pArea->blocks[1].offset); ta->blocks[1].size, ta->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 */ /* Using the second block already? */
bWait = (dwOffs + dwLen) > pArea->blocks[0].offset; /* Wait if will overwrite block 0? */ if (ta->blocks[1].size > 0) {
bWait |= (dwOffs + dwLen) > pArea->length; /* or if it overflows the buffer */ /* take offset from that */
} else { /* Area 1 not in use, try to use area 0 */ offs = ta->blocks[1].offset + ta->blocks[1].size;
if (pArea->blocks[0].size == 0) /* Reset block 0 if not in use */ /* Wait if will overwrite block 0? */
pArea->blocks[0].offset = 0; bWait = (offs + len) > ta->blocks[0].offset;
dwOffs = /* or if it overflows the buffer */
pArea->blocks[0].offset + bWait |= (offs + len) > ta->length;
pArea->blocks[0].size; } else { /* Area 1 not in use, try to use area 0 */
if ((dwOffs + dwLen) > pArea->length) { /* Off the end of the buffer? */ /* Reset block 0 if not in use */
pArea->blocks[1].offset = 0; /* Set up to use second block */ if (ta->blocks[0].size == 0)
dwOffs = 0; ta->blocks[0].offset = 0;
bWait = (dwOffs + dwLen) > pArea->blocks[0].offset; /* Wait if will overwrite block 0? */ offs =
bWait |= (dwOffs + dwLen) > pArea->length; /* or if it overflows the buffer */ ta->blocks[0].offset +
ta->blocks[0].size;
/* Off the end of the buffer? */
if ((offs + len) > ta->length) {
/* Set up to use second block */
ta->blocks[1].offset = 0;
offs = 0;
/* Wait if will overwrite block 0? */
bWait = (offs + len) > ta->blocks[0].offset;
/* or if it overflows the buffer */
bWait |= (offs + len) > ta->length;
} }
} }
...@@ -900,18 +912,18 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent, ...@@ -900,18 +912,18 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent,
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: circular xfer, %d bytes starting at %d\n", "%s: circular xfer, %d bytes starting at %d\n",
__func__, dwLen, dwOffs); __func__, len, offs);
} }
/* Save the parameters for the read\write transfer */ /* Save the parameters for the read\write transfer */
ced->staged_read = Read; /* Save the parameters for this read */ ced->staged_read = read; /* Save the parameters for this read */
ced->staged_id = wIdent; /* ID allows us to get transfer area info */ ced->staged_id = ident; /* ID allows us to get transfer area info */
ced->staged_offset = dwOffs; /* The area within the transfer area */ ced->staged_offset = offs; /* The area within the transfer area */
ced->staged_length = dwLen; ced->staged_length = len;
ced->staged_done = 0; /* Initialise the byte count */ ced->staged_done = 0; /* Initialise the byte count */
ced->dma_flag = MODE_LINEAR; /* Set DMA mode flag at this point */ ced->dma_flag = MODE_LINEAR; /* Set DMA mode flag at this point */
ced->xfer_waiting = false; /* Clearly not a transfer waiting now */ ced->xfer_waiting = false; /* Clearly not a transfer waiting now */
/* KeClearEvent(&ced->StagingDoneEvent); // Clear the transfer done event */ /* KeClearEvent(&ced->StagingDoneEvent); // Clear the transfer done event */
ced_stage_chunk(ced); /* fire off the first chunk */ ced_stage_chunk(ced); /* fire off the first chunk */
return U14ERR_NOERROR; return U14ERR_NOERROR;
......
...@@ -216,8 +216,9 @@ struct ced_data { ...@@ -216,8 +216,9 @@ struct ced_data {
extern int ced_allowi(struct ced_data * ced); extern int ced_allowi(struct ced_data * ced);
extern int ced_send_chars(struct ced_data *ced); extern int ced_send_chars(struct ced_data *ced);
extern void ced_draw_down(struct ced_data *ced); extern void ced_draw_down(struct ced_data *ced);
extern int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent, extern int ced_read_write_mem(struct ced_data *ced, bool read,
unsigned int dwOffs, unsigned int dwLen); unsigned short ident, unsigned int offs,
unsigned int len);
/* in ced_ioc.c */ /* in ced_ioc.c */
extern int ced_clear_area(struct ced_data *ced, int nArea); extern int ced_clear_area(struct ced_data *ced, int nArea);
......
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