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

staging: ced1401: rename members of struct ced_data

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 0dfcb0b9
...@@ -38,17 +38,19 @@ ...@@ -38,17 +38,19 @@
****************************************************************************/ ****************************************************************************/
static void ced_flush_out_buff(struct ced_data *ced) static void ced_flush_out_buff(struct ced_data *ced)
{ {
dev_dbg(&ced->interface->dev, "%s: currentState=%d\n", dev_dbg(&ced->interface->dev, "%s: current_state=%d\n",
__func__, ced->sCurrentState); __func__, ced->current_state);
if (ced->sCurrentState == U14ERR_TIME) /* Do nothing if hardware in trouble */
/* Do nothing if hardware in trouble */
if (ced->current_state == U14ERR_TIME)
return; return;
/* Kill off any pending I/O */ /* Kill off any pending I/O */
/* CharSend_Cancel(ced); */ /* CharSend_Cancel(ced); */
spin_lock_irq(&ced->charOutLock); spin_lock_irq(&ced->char_out_lock);
ced->dwNumOutput = 0; ced->num_output = 0;
ced->dwOutBuffGet = 0; ced->out_buff_get = 0;
ced->dwOutBuffPut = 0; ced->out_buff_put = 0;
spin_unlock_irq(&ced->charOutLock); spin_unlock_irq(&ced->char_out_lock);
} }
/**************************************************************************** /****************************************************************************
...@@ -59,17 +61,17 @@ static void ced_flush_out_buff(struct ced_data *ced) ...@@ -59,17 +61,17 @@ static void ced_flush_out_buff(struct ced_data *ced)
****************************************************************************/ ****************************************************************************/
static void ced_flush_in_buff(struct ced_data *ced) static void ced_flush_in_buff(struct ced_data *ced)
{ {
dev_dbg(&ced->interface->dev, "%s: currentState=%d\n", dev_dbg(&ced->interface->dev, "%s: current_state=%d\n",
__func__, ced->sCurrentState); __func__, ced->current_state);
if (ced->sCurrentState == U14ERR_TIME) /* Do nothing if hardware in trouble */ if (ced->current_state == U14ERR_TIME) /* Do nothing if hardware in trouble */
return; return;
/* Kill off any pending I/O */ /* Kill off any pending I/O */
/* CharRead_Cancel(pDevObject); */ /* CharRead_Cancel(pDevObject); */
spin_lock_irq(&ced->charInLock); spin_lock_irq(&ced->char_in_lock);
ced->dwNumInput = 0; ced->num_input = 0;
ced->dwInBuffGet = 0; ced->in_buff_get = 0;
ced->dwInBuffPut = 0; ced->in_buff_put = 0;
spin_unlock_irq(&ced->charInLock); spin_unlock_irq(&ced->char_in_lock);
} }
/**************************************************************************** /****************************************************************************
...@@ -82,20 +84,20 @@ static int ced_put_chars(struct ced_data *ced, const char *pCh, ...@@ -82,20 +84,20 @@ static int ced_put_chars(struct ced_data *ced, const char *pCh,
unsigned int uCount) unsigned int uCount)
{ {
int iReturn; int iReturn;
spin_lock_irq(&ced->charOutLock); /* get the output spin lock */ spin_lock_irq(&ced->char_out_lock); /* get the output spin lock */
if ((OUTBUF_SZ - ced->dwNumOutput) >= uCount) { if ((OUTBUF_SZ - ced->num_output) >= uCount) {
unsigned int u; unsigned int u;
for (u = 0; u < uCount; u++) { for (u = 0; u < uCount; u++) {
ced->outputBuffer[ced->dwOutBuffPut++] = pCh[u]; ced->output_buffer[ced->out_buff_put++] = pCh[u];
if (ced->dwOutBuffPut >= OUTBUF_SZ) if (ced->out_buff_put >= OUTBUF_SZ)
ced->dwOutBuffPut = 0; ced->out_buff_put = 0;
} }
ced->dwNumOutput += uCount; ced->num_output += uCount;
spin_unlock_irq(&ced->charOutLock); spin_unlock_irq(&ced->char_out_lock);
iReturn = ced_send_chars(ced); /* ...give a chance to transmit data */ iReturn = ced_send_chars(ced); /* ...give a chance to transmit data */
} else { } else {
iReturn = U14ERR_NOOUT; /* no room at the out (ha-ha) */ iReturn = U14ERR_NOOUT; /* no room at the out (ha-ha) */
spin_unlock_irq(&ced->charOutLock); spin_unlock_irq(&ced->char_out_lock);
} }
return iReturn; return iReturn;
} }
...@@ -179,38 +181,38 @@ int ced_get_state(struct ced_data *ced, __u32 *state, __u32 *error) ...@@ -179,38 +181,38 @@ int ced_get_state(struct ced_data *ced, __u32 *state, __u32 *error)
*state = 0xFFFFFFFF; /* Start off with invalid state */ *state = 0xFFFFFFFF; /* Start off with invalid state */
nGot = usb_control_msg(ced->udev, usb_rcvctrlpipe(ced->udev, 0), nGot = usb_control_msg(ced->udev, usb_rcvctrlpipe(ced->udev, 0),
GET_STATUS, (D_TO_H | VENDOR | DEVREQ), 0, 0, GET_STATUS, (D_TO_H | VENDOR | DEVREQ), 0, 0,
ced->statBuf, sizeof(ced->statBuf), HZ); ced->stat_buf, sizeof(ced->stat_buf), HZ);
if (nGot != sizeof(ced->statBuf)) { if (nGot != sizeof(ced->stat_buf)) {
dev_err(&ced->interface->dev, dev_err(&ced->interface->dev,
"%s: FAILED, return code %d\n", __func__, nGot); "%s: FAILED, return code %d\n", __func__, nGot);
ced->sCurrentState = U14ERR_TIME; /* Indicate that things are very wrong indeed */ ced->current_state = U14ERR_TIME; /* Indicate that things are very wrong indeed */
*state = 0; /* Force status values to a known state */ *state = 0; /* Force status values to a known state */
*error = 0; *error = 0;
} else { } else {
int nDevice; int nDevice;
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: Success, state: 0x%x, 0x%x\n", "%s: Success, state: 0x%x, 0x%x\n",
__func__, ced->statBuf[0], ced->statBuf[1]); __func__, ced->stat_buf[0], ced->stat_buf[1]);
*state = ced->statBuf[0]; /* Return the state values to the calling code */ *state = ced->stat_buf[0]; /* Return the state values to the calling code */
*error = ced->statBuf[1]; *error = ced->stat_buf[1];
nDevice = ced->udev->descriptor.bcdDevice >> 8; /* 1401 type code value */ nDevice = ced->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: case 0:
ced->sCurrentState = U14ERR_U1401; ced->current_state = U14ERR_U1401;
break; break;
default: /* allow lots of device codes for future 1401s */ default: /* allow lots of device codes for future 1401s */
if ((nDevice >= 1) && (nDevice <= 23)) if ((nDevice >= 1) && (nDevice <= 23))
ced->sCurrentState = (short)(nDevice + 6); ced->current_state = (short)(nDevice + 6);
else else
ced->sCurrentState = U14ERR_ILL; ced->current_state = U14ERR_ILL;
break; break;
} }
} }
return ced->sCurrentState >= 0 ? U14ERR_NOERROR : ced->sCurrentState; return ced->current_state >= 0 ? U14ERR_NOERROR : ced->current_state;
} }
/**************************************************************************** /****************************************************************************
...@@ -221,15 +223,15 @@ int ced_get_state(struct ced_data *ced, __u32 *state, __u32 *error) ...@@ -221,15 +223,15 @@ int ced_get_state(struct ced_data *ced, __u32 *state, __u32 *error)
int ced_read_write_cancel(struct ced_data *ced) int ced_read_write_cancel(struct ced_data *ced)
{ {
dev_dbg(&ced->interface->dev, "%s: entry %d\n", dev_dbg(&ced->interface->dev, "%s: entry %d\n",
__func__, ced->bStagedUrbPending); __func__, ced->staged_urb_pending);
#ifdef NOT_WRITTEN_YET #ifdef NOT_WRITTEN_YET
int ntStatus = STATUS_SUCCESS; int ntStatus = STATUS_SUCCESS;
bool bResult = false; bool bResult = false;
unsigned int i; unsigned int i;
/* We can fill this in when we know how we will implement the staged transfer stuff */ /* We can fill this in when we know how we will implement the staged transfer stuff */
spin_lock_irq(&ced->stagedLock); spin_lock_irq(&ced->staged_lock);
if (ced->bStagedUrbPending) { /* anything to be cancelled? May need more... */ if (ced->staged_urb_pending) { /* anything to be cancelled? May need more... */
dev_info(&ced->interface - dev, dev_info(&ced->interface - dev,
"ced_read_write_cancel about to cancel Urb\n"); "ced_read_write_cancel about to cancel Urb\n");
/* Clear the staging done flag */ /* Clear the staging done flag */
...@@ -238,7 +240,7 @@ int ced_read_write_cancel(struct ced_data *ced) ...@@ -238,7 +240,7 @@ int ced_read_write_cancel(struct ced_data *ced)
/* Release the spinlock first otherwise the completion routine may hang */ /* Release the spinlock first otherwise the completion routine may hang */
/* on the spinlock while this function hands waiting for the event. */ /* on the spinlock while this function hands waiting for the event. */
spin_unlock_irq(&ced->stagedLock); spin_unlock_irq(&ced->staged_lock);
bResult = IoCancelIrp(ced->pStagedIrp); /* Actually do the cancel */ bResult = IoCancelIrp(ced->pStagedIrp); /* Actually do the cancel */
if (bResult) { if (bResult) {
LARGE_INTEGER timeout; LARGE_INTEGER timeout;
...@@ -258,7 +260,7 @@ int ced_read_write_cancel(struct ced_data *ced) ...@@ -258,7 +260,7 @@ int ced_read_write_cancel(struct ced_data *ced)
("ced_read_write_cancel ntStatus = 0x%x decimal %d\n", ("ced_read_write_cancel ntStatus = 0x%x decimal %d\n",
ntStatus, ntStatus)); ntStatus, ntStatus));
} else } else
spin_unlock_irq(&ced->stagedLock); spin_unlock_irq(&ced->staged_lock);
dev_info(&ced->interface - dev, "%s: done\n", __func__); dev_info(&ced->interface - dev, "%s: done\n", __func__);
return ntStatus; return ntStatus;
...@@ -286,7 +288,7 @@ static int ced_in_self_test(struct ced_data *ced, unsigned int *pState) ...@@ -286,7 +288,7 @@ static int ced_in_self_test(struct ced_data *ced, unsigned int *pState)
/*************************************************************************** /***************************************************************************
** ced_is_1401 - ALWAYS CALLED HOLDING THE io_mutex ** ced_is_1401 - ALWAYS CALLED HOLDING THE io_mutex
** **
** Tests for the current state of the 1401. Sets sCurrentState: ** Tests for the current state of the 1401. Sets current_state:
** **
** U14ERR_NOIF 1401 i/f card not installed (not done here) ** U14ERR_NOIF 1401 i/f card not installed (not done here)
** U14ERR_OFF 1401 apparently not switched on ** U14ERR_OFF 1401 apparently not switched on
...@@ -323,7 +325,7 @@ static bool ced_is_1401(struct ced_data *ced) ...@@ -323,7 +325,7 @@ static bool ced_is_1401(struct ced_data *ced)
} }
mutex_lock(&ced->io_mutex); /* hold stuff off while we wait */ mutex_lock(&ced->io_mutex); /* hold stuff off while we wait */
ced->dwDMAFlag = MODE_CHAR; /* Clear DMA mode flag regardless! */ ced->dma_flag = 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; unsigned int state;
iReturn = ced_in_self_test(ced, &state); /* see if likely in self test */ iReturn = ced_in_self_test(ced, &state); /* see if likely in self test */
...@@ -339,7 +341,7 @@ static bool ced_is_1401(struct ced_data *ced) ...@@ -339,7 +341,7 @@ static bool ced_is_1401(struct ced_data *ced)
iReturn = state == 0; /* then success is that the state is 0 */ iReturn = state == 0; /* then success is that the state is 0 */
} else } else
iReturn = 0; /* we failed */ iReturn = 0; /* we failed */
ced->bForceReset = false; /* Clear forced reset flag now */ ced->force_reset = false; /* Clear forced reset flag now */
return iReturn > 0; return iReturn > 0;
} }
...@@ -363,17 +365,17 @@ static bool ced_quick_check(struct ced_data *ced, bool bTestBuff, bool bCanReset ...@@ -363,17 +365,17 @@ static bool ced_quick_check(struct ced_data *ced, bool bTestBuff, bool bCanReset
bool bRet = false; /* assume it will fail and we will reset */ bool bRet = false; /* assume it will fail and we will reset */
bool bShortTest; bool bShortTest;
bShortTest = ((ced->dwDMAFlag == MODE_CHAR) && /* no DMA running */ bShortTest = ((ced->dma_flag == MODE_CHAR) && /* no DMA running */
(!ced->bForceReset) && /* Not had a real reset forced */ (!ced->force_reset) && /* Not had a real reset forced */
(ced->sCurrentState >= U14ERR_STD)); /* No 1401 errors stored */ (ced->current_state >= U14ERR_STD)); /* No 1401 errors stored */
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: DMAFlag:%d, state:%d, force:%d, testBuff:%d, short:%d\n", "%s: DMAFlag:%d, state:%d, force:%d, testBuff:%d, short:%d\n",
__func__, ced->dwDMAFlag, ced->sCurrentState, ced->bForceReset, __func__, ced->dma_flag, ced->current_state, ced->force_reset,
bTestBuff, bShortTest); bTestBuff, bShortTest);
if ((bTestBuff) && /* Buffer check requested, and... */ if ((bTestBuff) && /* Buffer check requested, and... */
(ced->dwNumInput || ced->dwNumOutput)) { /* ...characters were in the buffer? */ (ced->num_input || ced->num_output)) { /* ...characters were in the buffer? */
bShortTest = false; /* Then do the full test */ bShortTest = false; /* Then do the full test */
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: will reset as buffers not empty\n", __func__); "%s: will reset as buffers not empty\n", __func__);
...@@ -391,8 +393,8 @@ static bool ced_quick_check(struct ced_data *ced, bool bTestBuff, bool bCanReset ...@@ -391,8 +393,8 @@ static bool ced_quick_check(struct ced_data *ced, bool bTestBuff, bool bCanReset
if (!bRet && bCanReset) { /* If all not OK, then */ if (!bRet && bCanReset) { /* If all not OK, then */
dev_info(&ced->interface->dev, "%s: ced_is_1401 %d %d %d %d\n", dev_info(&ced->interface->dev, "%s: ced_is_1401 %d %d %d %d\n",
__func__, bShortTest, ced->sCurrentState, bTestBuff, __func__, bShortTest, ced->current_state, bTestBuff,
ced->bForceReset); ced->force_reset);
bRet = ced_is_1401(ced); /* do full test */ bRet = ced_is_1401(ced); /* do full test */
} }
...@@ -429,15 +431,15 @@ int ced_get_char(struct ced_data *ced) ...@@ -429,15 +431,15 @@ int ced_get_char(struct ced_data *ced)
ced_allowi(ced); /* Make sure char reads are running */ ced_allowi(ced); /* Make sure char reads are running */
ced_send_chars(ced); /* and send any buffered chars */ ced_send_chars(ced); /* and send any buffered chars */
spin_lock_irq(&ced->charInLock); spin_lock_irq(&ced->char_in_lock);
if (ced->dwNumInput > 0) { /* worth looking */ if (ced->num_input > 0) { /* worth looking */
iReturn = ced->inputBuffer[ced->dwInBuffGet++]; iReturn = ced->input_buffer[ced->in_buff_get++];
if (ced->dwInBuffGet >= INBUF_SZ) if (ced->in_buff_get >= INBUF_SZ)
ced->dwInBuffGet = 0; ced->in_buff_get = 0;
ced->dwNumInput--; ced->num_input--;
} else } else
iReturn = U14ERR_NOIN; /* no input data to read */ iReturn = U14ERR_NOIN; /* no input data to read */
spin_unlock_irq(&ced->charInLock); spin_unlock_irq(&ced->char_in_lock);
ced_allowi(ced); /* Make sure char reads are running */ ced_allowi(ced); /* Make sure char reads are running */
...@@ -467,8 +469,8 @@ int ced_get_string(struct ced_data *ced, char __user *pUser, int n) ...@@ -467,8 +469,8 @@ int ced_get_string(struct ced_data *ced, char __user *pUser, int n)
ced_allowi(ced); /* Make sure char reads are running */ ced_allowi(ced); /* Make sure char reads are running */
ced_send_chars(ced); /* and send any buffered chars */ ced_send_chars(ced); /* and send any buffered chars */
spin_lock_irq(&ced->charInLock); spin_lock_irq(&ced->char_in_lock);
nAvailable = ced->dwNumInput; /* characters available now */ nAvailable = ced->num_input; /* characters available now */
if (nAvailable > n) /* read max of space in pUser... */ if (nAvailable > n) /* read max of space in pUser... */
nAvailable = n; /* ...or input characters */ nAvailable = n; /* ...or input characters */
...@@ -478,12 +480,12 @@ int ced_get_string(struct ced_data *ced, char __user *pUser, int n) ...@@ -478,12 +480,12 @@ int ced_get_string(struct ced_data *ced, char __user *pUser, int n)
int nCopyToUser; /* number to copy to user */ int nCopyToUser; /* number to copy to user */
char cData; char cData;
do { do {
cData = ced->inputBuffer[ced->dwInBuffGet++]; cData = ced->input_buffer[ced->in_buff_get++];
if (cData == CR_CHAR) /* replace CR with zero */ if (cData == CR_CHAR) /* replace CR with zero */
cData = (char)0; cData = (char)0;
if (ced->dwInBuffGet >= INBUF_SZ) if (ced->in_buff_get >= INBUF_SZ)
ced->dwInBuffGet = 0; /* wrap buffer pointer */ ced->in_buff_get = 0; /* wrap buffer pointer */
buffer[nGot++] = cData; /* save the output */ buffer[nGot++] = cData; /* save the output */
} while ((nGot < nAvailable) && cData); } while ((nGot < nAvailable) && cData);
...@@ -495,8 +497,8 @@ int ced_get_string(struct ced_data *ced, char __user *pUser, int n) ...@@ -495,8 +497,8 @@ int ced_get_string(struct ced_data *ced, char __user *pUser, int n)
++nCopyToUser; /* ...copy the 0 as well. */ ++nCopyToUser; /* ...copy the 0 as well. */
} }
ced->dwNumInput -= nGot; ced->num_input -= nGot;
spin_unlock_irq(&ced->charInLock); spin_unlock_irq(&ced->char_in_lock);
dev_dbg(&ced->interface->dev, "%s: read %d characters >%s<\n", dev_dbg(&ced->interface->dev, "%s: read %d characters >%s<\n",
__func__, nGot, buffer); __func__, nGot, buffer);
...@@ -505,7 +507,7 @@ int ced_get_string(struct ced_data *ced, char __user *pUser, int n) ...@@ -505,7 +507,7 @@ int ced_get_string(struct ced_data *ced, char __user *pUser, int n)
else else
iReturn = nGot; /* report characters read */ iReturn = nGot; /* report characters read */
} else } else
spin_unlock_irq(&ced->charInLock); spin_unlock_irq(&ced->char_in_lock);
ced_allowi(ced); /* Make sure char reads are running */ ced_allowi(ced); /* Make sure char reads are running */
mutex_unlock(&ced->io_mutex); /* Protect disconnect from new i/o */ mutex_unlock(&ced->io_mutex); /* Protect disconnect from new i/o */
...@@ -522,7 +524,7 @@ int ced_stat_1401(struct ced_data *ced) ...@@ -522,7 +524,7 @@ int ced_stat_1401(struct ced_data *ced)
mutex_lock(&ced->io_mutex); /* Protect disconnect from new i/o */ mutex_lock(&ced->io_mutex); /* Protect disconnect from new i/o */
ced_allowi(ced); /* make sure we allow pending chars */ ced_allowi(ced); /* make sure we allow pending chars */
ced_send_chars(ced); /* in both directions */ ced_send_chars(ced); /* in both directions */
iReturn = ced->dwNumInput; /* no lock as single read */ iReturn = ced->num_input; /* no lock as single read */
mutex_unlock(&ced->io_mutex); /* Protect disconnect from new i/o */ mutex_unlock(&ced->io_mutex); /* Protect disconnect from new i/o */
return iReturn; return iReturn;
} }
...@@ -541,13 +543,13 @@ int ced_line_count(struct ced_data *ced) ...@@ -541,13 +543,13 @@ int ced_line_count(struct ced_data *ced)
mutex_lock(&ced->io_mutex); /* Protect disconnect from new i/o */ mutex_lock(&ced->io_mutex); /* Protect disconnect from new i/o */
ced_allowi(ced); /* Make sure char reads are running */ ced_allowi(ced); /* Make sure char reads are running */
ced_send_chars(ced); /* and send any buffered chars */ ced_send_chars(ced); /* and send any buffered chars */
spin_lock_irq(&ced->charInLock); /* Get protection */ spin_lock_irq(&ced->char_in_lock); /* Get protection */
if (ced->dwNumInput > 0) { /* worth looking? */ if (ced->num_input > 0) { /* worth looking? */
unsigned int dwIndex = ced->dwInBuffGet; /* start at first available */ unsigned int dwIndex = ced->in_buff_get; /* start at first available */
unsigned int dwEnd = ced->dwInBuffPut; /* Position for search end */ unsigned int dwEnd = ced->in_buff_put; /* Position for search end */
do { do {
if (ced->inputBuffer[dwIndex++] == CR_CHAR) if (ced->input_buffer[dwIndex++] == CR_CHAR)
++iReturn; /* inc count if CR */ ++iReturn; /* inc count if CR */
if (dwIndex >= INBUF_SZ) /* see if we fall off buff */ if (dwIndex >= INBUF_SZ) /* see if we fall off buff */
...@@ -555,7 +557,7 @@ int ced_line_count(struct ced_data *ced) ...@@ -555,7 +557,7 @@ int ced_line_count(struct ced_data *ced)
} while (dwIndex != dwEnd); /* go to last available */ } while (dwIndex != dwEnd); /* go to last available */
} }
spin_unlock_irq(&ced->charInLock); spin_unlock_irq(&ced->char_in_lock);
dev_dbg(&ced->interface->dev, "%s: returned %d\n", __func__, iReturn); dev_dbg(&ced->interface->dev, "%s: returned %d\n", __func__, iReturn);
mutex_unlock(&ced->io_mutex); /* Protect disconnect from new i/o */ mutex_unlock(&ced->io_mutex); /* Protect disconnect from new i/o */
return iReturn; return iReturn;
...@@ -571,7 +573,7 @@ int ced_get_out_buf_space(struct ced_data *ced) ...@@ -571,7 +573,7 @@ int ced_get_out_buf_space(struct ced_data *ced)
int iReturn; int iReturn;
mutex_lock(&ced->io_mutex); /* Protect disconnect from new i/o */ mutex_lock(&ced->io_mutex); /* Protect disconnect from new i/o */
ced_send_chars(ced); /* send any buffered chars */ ced_send_chars(ced); /* send any buffered chars */
iReturn = (int)(OUTBUF_SZ - ced->dwNumOutput); /* no lock needed for single read */ iReturn = (int)(OUTBUF_SZ - ced->num_output); /* no lock needed for single read */
dev_dbg(&ced->interface->dev, "%s: %d\n", __func__, iReturn); dev_dbg(&ced->interface->dev, "%s: %d\n", __func__, iReturn);
mutex_unlock(&ced->io_mutex); /* Protect disconnect from new i/o */ mutex_unlock(&ced->io_mutex); /* Protect disconnect from new i/o */
return iReturn; return iReturn;
...@@ -594,7 +596,7 @@ int ced_clear_area(struct ced_data *ced, int nArea) ...@@ -594,7 +596,7 @@ int ced_clear_area(struct ced_data *ced, int nArea)
__func__, nArea); __func__, nArea);
} else { } else {
/* to save typing */ /* to save typing */
struct transarea *pTA = &ced->rTransDef[nArea]; struct transarea *pTA = &ced->trans_def[nArea];
if (!pTA->used) /* 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 {
...@@ -606,9 +608,9 @@ int ced_clear_area(struct ced_data *ced, int nArea) ...@@ -606,9 +608,9 @@ int ced_clear_area(struct ced_data *ced, int nArea)
dev_dbg(&ced->interface->dev, "%s: area %d\n", dev_dbg(&ced->interface->dev, "%s: area %d\n",
__func__, nArea); __func__, nArea);
spin_lock_irq(&ced->stagedLock); spin_lock_irq(&ced->staged_lock);
if ((ced->StagedId == nArea) if ((ced->staged_id == nArea)
&& (ced->dwDMAFlag > MODE_CHAR)) { && (ced->dma_flag > MODE_CHAR)) {
iReturn = U14ERR_UNLOCKFAIL; /* cannot delete as in use */ iReturn = U14ERR_UNLOCKFAIL; /* cannot delete as in use */
dev_err(&ced->interface->dev, dev_err(&ced->interface->dev,
"%s: call on area %d while active\n", "%s: call on area %d while active\n",
...@@ -619,9 +621,9 @@ int ced_clear_area(struct ced_data *ced, int nArea) ...@@ -619,9 +621,9 @@ int ced_clear_area(struct ced_data *ced, int nArea)
if (pTA->event_sz) /* if events flagging in use */ if (pTA->event_sz) /* if events flagging in use */
wake_up_interruptible(&pTA->event); /* release anything that was waiting */ wake_up_interruptible(&pTA->event); /* release anything that was waiting */
if (ced->bXFerWaiting if (ced->xfer_waiting
&& (ced->rDMAInfo.ident == nArea)) && (ced->dma_info.ident == nArea))
ced->bXFerWaiting = false; /* Cannot have pending xfer if area cleared */ ced->xfer_waiting = 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 used to false and event_sz 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. */
...@@ -629,7 +631,7 @@ int ced_clear_area(struct ced_data *ced, int nArea) ...@@ -629,7 +631,7 @@ int ced_clear_area(struct ced_data *ced, int nArea)
sizeof(struct transarea) - sizeof(struct transarea) -
sizeof(wait_queue_head_t)); sizeof(wait_queue_head_t));
} }
spin_unlock_irq(&ced->stagedLock); spin_unlock_irq(&ced->staged_lock);
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 */ /* Now we must undo the pinning down of the pages. We will assume the worst and mark */
...@@ -671,7 +673,7 @@ static int ced_set_area(struct ced_data *ced, int nArea, char __user *puBuf, ...@@ -671,7 +673,7 @@ static int ced_set_area(struct ced_data *ced, int nArea, char __user *puBuf,
unsigned int ulOffset = ((unsigned long)puBuf) & (PAGE_SIZE - 1); unsigned int ulOffset = ((unsigned long)puBuf) & (PAGE_SIZE - 1);
int len = (dwLength + ulOffset + PAGE_SIZE - 1) >> PAGE_SHIFT; int len = (dwLength + ulOffset + PAGE_SIZE - 1) >> PAGE_SHIFT;
struct transarea *pTA = &ced->rTransDef[nArea]; /* to save typing */ struct transarea *pTA = &ced->trans_def[nArea]; /* to save typing */
struct page **pPages = NULL; /* space for page tables */ struct page **pPages = NULL; /* space for page tables */
int nPages = 0; /* and number of pages */ int nPages = 0; /* and number of pages */
...@@ -700,7 +702,7 @@ static int ced_set_area(struct ced_data *ced, int nArea, char __user *puBuf, ...@@ -700,7 +702,7 @@ static int ced_set_area(struct ced_data *ced, int nArea, char __user *puBuf,
/* If you are tempted to use page_address (form LDD3), forget it. You MUST use */ /* 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 */ /* 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->staged_lock);
pTA->buff = puBuf; /* keep start of region (user address) */ pTA->buff = puBuf; /* keep start of region (user address) */
pTA->base_offset = ulOffset; /* save offset in first page to start of xfer */ pTA->base_offset = ulOffset; /* save offset in first page to start of xfer */
pTA->length = dwLength; /* Size if the region in bytes */ pTA->length = dwLength; /* Size if the region in bytes */
...@@ -716,7 +718,7 @@ static int ced_set_area(struct ced_data *ced, int nArea, char __user *puBuf, ...@@ -716,7 +718,7 @@ static int ced_set_area(struct ced_data *ced, int nArea, char __user *puBuf,
pTA->blocks[1].size = 0; pTA->blocks[1].size = 0;
pTA->used = 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->staged_lock);
iReturn = U14ERR_NOERROR; /* say all was well */ iReturn = U14ERR_NOERROR; /* say all was well */
} else { } else {
iReturn = U14ERR_LOCKFAIL; iReturn = U14ERR_LOCKFAIL;
...@@ -792,9 +794,9 @@ int ced_set_event(struct ced_data *ced, struct transfer_event __user *pTE) ...@@ -792,9 +794,9 @@ int ced_set_event(struct ced_data *ced, struct transfer_event __user *pTE)
if (te.wAreaNum >= MAX_TRANSAREAS) /* the area must exist */ if (te.wAreaNum >= MAX_TRANSAREAS) /* the area must exist */
return U14ERR_BADAREA; return U14ERR_BADAREA;
else { else {
struct transarea *pTA = &ced->rTransDef[te.wAreaNum]; struct transarea *pTA = &ced->trans_def[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->staged_lock);
if (pTA->used) { /* area must be in use */ if (pTA->used) { /* area must be in use */
pTA->event_st = te.dwStart; /* set area regions */ pTA->event_st = te.dwStart; /* set area regions */
pTA->event_sz = te.dwLength; /* set size (0 cancels it) */ pTA->event_sz = te.dwLength; /* set size (0 cancels it) */
...@@ -802,7 +804,7 @@ int ced_set_event(struct ced_data *ced, struct transfer_event __user *pTE) ...@@ -802,7 +804,7 @@ int ced_set_event(struct ced_data *ced, struct transfer_event __user *pTE)
pTA->wake_up = 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->staged_lock);
mutex_unlock(&ced->io_mutex); mutex_unlock(&ced->io_mutex);
} }
return iReturn == return iReturn ==
...@@ -822,7 +824,7 @@ int ced_wait_event(struct ced_data *ced, int nArea, int msTimeOut) ...@@ -822,7 +824,7 @@ int ced_wait_event(struct ced_data *ced, int nArea, int msTimeOut)
return U14ERR_BADAREA; return U14ERR_BADAREA;
else { else {
int iWait; int iWait;
struct transarea *pTA = &ced->rTransDef[nArea]; struct transarea *pTA = &ced->trans_def[nArea];
msTimeOut = (msTimeOut * HZ + 999) / 1000; /* convert timeout to jiffies */ msTimeOut = (msTimeOut * HZ + 999) / 1000; /* convert timeout to jiffies */
/* We cannot wait holding the mutex, but we check the flags while holding */ /* We cannot wait holding the mutex, but we check the flags while holding */
...@@ -849,9 +851,9 @@ int ced_wait_event(struct ced_data *ced, int nArea, int msTimeOut) ...@@ -849,9 +851,9 @@ int ced_wait_event(struct ced_data *ced, int nArea, int msTimeOut)
else else
iReturn = pTA->wake_up; /* else the wakeup count */ iReturn = pTA->wake_up; /* else the wakeup count */
spin_lock_irq(&ced->stagedLock); spin_lock_irq(&ced->staged_lock);
pTA->wake_up = 0; /* clear the flag */ pTA->wake_up = 0; /* clear the flag */
spin_unlock_irq(&ced->stagedLock); spin_unlock_irq(&ced->staged_lock);
} }
return iReturn; return iReturn;
} }
...@@ -868,12 +870,12 @@ int ced_test_event(struct ced_data *ced, int nArea) ...@@ -868,12 +870,12 @@ int ced_test_event(struct ced_data *ced, int nArea)
if ((unsigned)nArea >= MAX_TRANSAREAS) if ((unsigned)nArea >= MAX_TRANSAREAS)
iReturn = U14ERR_BADAREA; iReturn = U14ERR_BADAREA;
else { else {
struct transarea *pTA = &ced->rTransDef[nArea]; struct transarea *pTA = &ced->trans_def[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->staged_lock);
iReturn = pTA->wake_up; /* get wakeup count since last call */ iReturn = pTA->wake_up; /* get wakeup count since last call */
pTA->wake_up = 0; /* clear the count */ pTA->wake_up = 0; /* clear the count */
spin_unlock_irq(&ced->stagedLock); spin_unlock_irq(&ced->staged_lock);
mutex_unlock(&ced->io_mutex); mutex_unlock(&ced->io_mutex);
} }
return iReturn; return iReturn;
...@@ -889,7 +891,7 @@ int ced_get_transfer(struct ced_data *ced, TGET_TX_BLOCK __user *pTX) ...@@ -889,7 +891,7 @@ int ced_get_transfer(struct ced_data *ced, TGET_TX_BLOCK __user *pTX)
unsigned int dwIdent; unsigned int dwIdent;
mutex_lock(&ced->io_mutex); mutex_lock(&ced->io_mutex);
dwIdent = ced->StagedId; /* area ident for last xfer */ dwIdent = ced->staged_id; /* area ident for last xfer */
if (dwIdent >= MAX_TRANSAREAS) if (dwIdent >= MAX_TRANSAREAS)
iReturn = U14ERR_BADAREA; iReturn = U14ERR_BADAREA;
else { else {
...@@ -901,12 +903,12 @@ int ced_get_transfer(struct ced_data *ced, TGET_TX_BLOCK __user *pTX) ...@@ -901,12 +903,12 @@ 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].length; tx->size = ced->trans_def[dwIdent].length;
tx->linear = (long long)((long)ced->rTransDef[dwIdent].buff); tx->linear = (long long)((long)ced->trans_def[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 =
(long long)(tx->linear + ced->StagedOffset); (long long)(tx->linear + ced->staged_offset);
tx->entries[0].size = tx->size; tx->entries[0].size = tx->size;
if (copy_to_user(pTX, tx, sizeof(*tx))) if (copy_to_user(pTX, tx, sizeof(*tx)))
...@@ -943,7 +945,7 @@ int ced_state_of_1401(struct ced_data *ced) ...@@ -943,7 +945,7 @@ int ced_state_of_1401(struct ced_data *ced)
mutex_lock(&ced->io_mutex); mutex_lock(&ced->io_mutex);
ced_quick_check(ced, false, false); /* get state up to date, no reset */ ced_quick_check(ced, false, false); /* get state up to date, no reset */
iReturn = ced->sCurrentState; iReturn = ced->current_state;
mutex_unlock(&ced->io_mutex); mutex_unlock(&ced->io_mutex);
dev_dbg(&ced->interface->dev, "%s: %d\n", __func__, iReturn); dev_dbg(&ced->interface->dev, "%s: %d\n", __func__, iReturn);
...@@ -968,12 +970,12 @@ int ced_start_self_test(struct ced_data *ced) ...@@ -968,12 +970,12 @@ int ced_start_self_test(struct ced_data *ced)
ced_flush_out_buff(ced); /* Clear output buffer & pipe */ ced_flush_out_buff(ced); /* Clear output buffer & pipe */
/* so things stay tidy */ /* so things stay tidy */
/* ced_read_write_cancel(pDeviceObject); */ /* ced_read_write_cancel(pDeviceObject); */
ced->dwDMAFlag = MODE_CHAR; /* Clear DMA mode flags here */ ced->dma_flag = MODE_CHAR; /* Clear DMA mode flags here */
nGot = usb_control_msg(ced->udev, usb_rcvctrlpipe(ced->udev, 0), nGot = usb_control_msg(ced->udev, usb_rcvctrlpipe(ced->udev, 0),
DB_SELFTEST, (H_TO_D | VENDOR | DEVREQ), DB_SELFTEST, (H_TO_D | VENDOR | DEVREQ),
0, 0, NULL, 0, HZ); /* allow 1 second timeout */ 0, 0, NULL, 0, HZ); /* allow 1 second timeout */
ced->ulSelfTestTime = jiffies + HZ * 30; /* 30 seconds into the future */ ced->self_test_time = jiffies + HZ * 30; /* 30 seconds into the future */
mutex_unlock(&ced->io_mutex); mutex_unlock(&ced->io_mutex);
if (nGot < 0) if (nGot < 0)
...@@ -1027,7 +1029,7 @@ int ced_check_self_test(struct ced_data *ced, TGET_SELFTEST __user *pGST) ...@@ -1027,7 +1029,7 @@ int ced_check_self_test(struct ced_data *ced, TGET_SELFTEST __user *pGST)
"Self-test error code %d\n", gst.code); "Self-test error code %d\n", gst.code);
} else { /* No error, check for timeout */ } else { /* No error, check for timeout */
unsigned long ulNow = jiffies; /* get current time */ unsigned long ulNow = jiffies; /* get current time */
if (time_after(ulNow, ced->ulSelfTestTime)) { if (time_after(ulNow, ced->self_test_time)) {
gst.code = -2; /* Flag the timeout */ gst.code = -2; /* Flag the timeout */
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"Self-test timed-out\n"); "Self-test timed-out\n");
...@@ -1042,7 +1044,7 @@ int ced_check_self_test(struct ced_data *ced, TGET_SELFTEST __user *pGST) ...@@ -1042,7 +1044,7 @@ int ced_check_self_test(struct ced_data *ced, TGET_SELFTEST __user *pGST)
if (gst.code < 0) { /* If we have a problem or finished */ if (gst.code < 0) { /* If we have a problem or finished */
/* If using the 2890 we should reset properly */ /* If using the 2890 we should reset properly */
if ((ced->nPipes == 4) && (ced->s1401Type <= TYPEPOWER)) if ((ced->n_pipes == 4) && (ced->type <= TYPEPOWER))
ced_is_1401(ced); /* Get 1401 reset and OK */ ced_is_1401(ced); /* Get 1401 reset and OK */
else else
ced_quick_check(ced, true, true); /* Otherwise check without reset unless problems */ ced_quick_check(ced, true, true); /* Otherwise check without reset unless problems */
...@@ -1066,7 +1068,7 @@ int ced_type_of_1401(struct ced_data *ced) ...@@ -1066,7 +1068,7 @@ int ced_type_of_1401(struct ced_data *ced)
mutex_lock(&ced->io_mutex); mutex_lock(&ced->io_mutex);
dev_dbg(&ced->interface->dev, "%s\n", __func__); dev_dbg(&ced->interface->dev, "%s\n", __func__);
switch (ced->s1401Type) { switch (ced->type) {
case TYPE1401: case TYPE1401:
iReturn = U14ERR_STD; iReturn = U14ERR_STD;
break; /* Handle these types directly */ break; /* Handle these types directly */
...@@ -1077,8 +1079,8 @@ int ced_type_of_1401(struct ced_data *ced) ...@@ -1077,8 +1079,8 @@ int ced_type_of_1401(struct ced_data *ced)
iReturn = U14ERR_U1401; iReturn = U14ERR_U1401;
break; break;
default: default:
if ((ced->s1401Type >= TYPEPOWER) && (ced->s1401Type <= 25)) if ((ced->type >= TYPEPOWER) && (ced->type <= 25))
iReturn = ced->s1401Type + 4; /* We can calculate types */ iReturn = ced->type + 4; /* We can calculate types */
else /* for up-coming 1401 designs */ else /* for up-coming 1401 designs */
iReturn = TYPEUNKNOWN; /* Don't know or not there */ iReturn = TYPEUNKNOWN; /* Don't know or not there */
} }
...@@ -1099,7 +1101,7 @@ int ced_transfer_flags(struct ced_data *ced) ...@@ -1099,7 +1101,7 @@ int ced_transfer_flags(struct ced_data *ced)
U14TF_NOTIFY | U14TF_CIRCTH; /* diagnostics, notify and circular */ U14TF_NOTIFY | U14TF_CIRCTH; /* diagnostics, notify and circular */
dev_dbg(&ced->interface->dev, "%s\n", __func__); dev_dbg(&ced->interface->dev, "%s\n", __func__);
mutex_lock(&ced->io_mutex); mutex_lock(&ced->io_mutex);
if (ced->bIsUSB2) /* Set flag for USB2 if appropriate */ if (ced->is_usb2) /* Set flag for USB2 if appropriate */
iReturn |= U14TF_USB2; iReturn |= U14TF_USB2;
mutex_unlock(&ced->io_mutex); mutex_unlock(&ced->io_mutex);
...@@ -1356,8 +1358,8 @@ int ced_get_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB) ...@@ -1356,8 +1358,8 @@ int ced_get_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
if (nArea < MAX_TRANSAREAS) { /* The area number must be OK */ if (nArea < MAX_TRANSAREAS) { /* The area number must be OK */
/* Pointer to relevant info */ /* Pointer to relevant info */
struct transarea *pArea = &ced->rTransDef[nArea]; struct transarea *pArea = &ced->trans_def[nArea];
spin_lock_irq(&ced->stagedLock); /* Lock others out */ spin_lock_irq(&ced->staged_lock); /* Lock others out */
if ((pArea->used) && (pArea->circular) && /* Must be circular area */ if ((pArea->used) && (pArea->circular) && /* Must be circular area */
(pArea->circ_to_host)) { /* For now at least must be to host */ (pArea->circ_to_host)) { /* For now at least must be to host */
...@@ -1371,7 +1373,7 @@ int ced_get_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB) ...@@ -1371,7 +1373,7 @@ int ced_get_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
} else } else
iReturn = U14ERR_NOTSET; iReturn = U14ERR_NOTSET;
spin_unlock_irq(&ced->stagedLock); spin_unlock_irq(&ced->staged_lock);
} else } else
iReturn = U14ERR_BADAREA; iReturn = U14ERR_BADAREA;
...@@ -1408,8 +1410,8 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB) ...@@ -1408,8 +1410,8 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
if (nArea < MAX_TRANSAREAS) { /* The area number must be OK */ if (nArea < MAX_TRANSAREAS) { /* The area number must be OK */
/* Pointer to relevant info */ /* Pointer to relevant info */
struct transarea *pArea = &ced->rTransDef[nArea]; struct transarea *pArea = &ced->trans_def[nArea];
spin_lock_irq(&ced->stagedLock); /* Lock others out */ spin_lock_irq(&ced->staged_lock); /* Lock others out */
if ((pArea->used) && (pArea->circular) && /* Must be circular area */ if ((pArea->used) && (pArea->circular) && /* Must be circular area */
(pArea->circ_to_host)) { /* For now at least must be to host */ (pArea->circ_to_host)) { /* For now at least must be to host */
...@@ -1433,7 +1435,7 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB) ...@@ -1433,7 +1435,7 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
__func__, uSize, uStart, __func__, uSize, uStart,
pArea->blocks[0].size, pArea->blocks[0].size,
pArea->blocks[0].offset, pArea->blocks[0].offset,
ced->bXFerWaiting); ced->xfer_waiting);
/* Return the next available block of memory as well */ /* Return the next available block of memory as well */
if (pArea->blocks[0].size > 0) { /* Got anything? */ if (pArea->blocks[0].size > 0) { /* Got anything? */
...@@ -1442,8 +1444,8 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB) ...@@ -1442,8 +1444,8 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
cb.dwSize = pArea->blocks[0].size; cb.dwSize = pArea->blocks[0].size;
} }
bWaiting = ced->bXFerWaiting; bWaiting = ced->xfer_waiting;
if (bWaiting && ced->bStagedUrbPending) { if (bWaiting && ced->staged_urb_pending) {
dev_err(&ced->interface->dev, dev_err(&ced->interface->dev,
"%s: ERROR: waiting xfer and staged Urb pending!\n", "%s: ERROR: waiting xfer and staged Urb pending!\n",
__func__); __func__);
...@@ -1462,10 +1464,10 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB) ...@@ -1462,10 +1464,10 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
if (bWaiting) { /* Got a block xfer waiting? */ if (bWaiting) { /* Got a block xfer waiting? */
int RWMStat = int RWMStat =
ced_read_write_mem(ced, ced_read_write_mem(ced,
!ced->rDMAInfo.outward, !ced->dma_info.outward,
ced->rDMAInfo.ident, ced->dma_info.ident,
ced->rDMAInfo.offset, ced->dma_info.offset,
ced->rDMAInfo.size); ced->dma_info.size);
if (RWMStat != U14ERR_NOERROR) if (RWMStat != U14ERR_NOERROR)
dev_err(&ced->interface->dev, dev_err(&ced->interface->dev,
"%s: rw setup failed %d\n", "%s: rw setup failed %d\n",
...@@ -1474,7 +1476,7 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB) ...@@ -1474,7 +1476,7 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
} else } else
iReturn = U14ERR_NOTSET; iReturn = U14ERR_NOTSET;
spin_unlock_irq(&ced->stagedLock); spin_unlock_irq(&ced->staged_lock);
} else } else
iReturn = U14ERR_BADAREA; iReturn = U14ERR_BADAREA;
......
...@@ -127,19 +127,19 @@ static void ced_delete(struct kref *kref) ...@@ -127,19 +127,19 @@ static void ced_delete(struct kref *kref)
/* Free up the output buffer, then free the output urb. Note that the interface member */ /* Free up the output buffer, then free the output urb. Note that the interface member */
/* of ced will probably be NULL, so cannot be used to get to dev. */ /* of ced will probably be NULL, so cannot be used to get to dev. */
usb_free_coherent(ced->udev, OUTBUF_SZ, ced->pCoherCharOut, usb_free_coherent(ced->udev, OUTBUF_SZ, ced->coher_char_out,
ced->pUrbCharOut->transfer_dma); ced->urb_char_out->transfer_dma);
usb_free_urb(ced->pUrbCharOut); usb_free_urb(ced->urb_char_out);
/* Do the same for chan input */ /* Do the same for chan input */
usb_free_coherent(ced->udev, INBUF_SZ, ced->pCoherCharIn, usb_free_coherent(ced->udev, INBUF_SZ, ced->coher_char_in,
ced->pUrbCharIn->transfer_dma); ced->urb_char_in->transfer_dma);
usb_free_urb(ced->pUrbCharIn); usb_free_urb(ced->urb_char_in);
/* Do the same for the block transfers */ /* Do the same for the block transfers */
usb_free_coherent(ced->udev, STAGED_SZ, ced->pCoherStagedIO, usb_free_coherent(ced->udev, STAGED_SZ, ced->coher_staged_io,
ced->pStagedUrb->transfer_dma); ced->staged_urb->transfer_dma);
usb_free_urb(ced->pStagedUrb); usb_free_urb(ced->staged_urb);
usb_put_dev(ced->udev); usb_put_dev(ced->udev);
kfree(ced); kfree(ced);
...@@ -225,7 +225,7 @@ static int ced_flush(struct file *file, fl_owner_t id) ...@@ -225,7 +225,7 @@ static int ced_flush(struct file *file, fl_owner_t id)
return -ENODEV; return -ENODEV;
dev_dbg(&ced->interface->dev, "%s: char in pend=%d\n", dev_dbg(&ced->interface->dev, "%s: char in pend=%d\n",
__func__, ced->bReadCharsPending); __func__, ced->read_chars_pending);
/* wait for io to stop */ /* wait for io to stop */
mutex_lock(&ced->io_mutex); mutex_lock(&ced->io_mutex);
...@@ -279,56 +279,61 @@ static void ced_writechar_callback(struct urb *pUrb) ...@@ -279,56 +279,61 @@ static void ced_writechar_callback(struct urb *pUrb)
spin_unlock(&ced->err_lock); spin_unlock(&ced->err_lock);
nGot = 0; /* and tidy up again if so */ nGot = 0; /* and tidy up again if so */
spin_lock(&ced->charOutLock); /* already at irq level */ spin_lock(&ced->char_out_lock); /* already at irq level */
ced->dwOutBuffGet = 0; /* Reset the output buffer */ ced->out_buff_get = 0; /* Reset the output buffer */
ced->dwOutBuffPut = 0; ced->out_buff_put = 0;
ced->dwNumOutput = 0; /* Clear the char count */ ced->num_output = 0; /* Clear the char count */
ced->bPipeError[0] = 1; /* Flag an error for later */ ced->pipe_error[0] = 1; /* Flag an error for later */
ced->bSendCharsPending = false; /* Allow other threads again */ ced->send_chars_pending = false; /* Allow other threads again */
spin_unlock(&ced->charOutLock); /* already at irq level */ spin_unlock(&ced->char_out_lock); /* already at irq level */
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: char out done, 0 chars sent\n", __func__); "%s: char out done, 0 chars sent\n", __func__);
} else { } else {
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: char out done, %d chars sent\n", __func__, nGot); "%s: char out done, %d chars sent\n", __func__, nGot);
spin_lock(&ced->charOutLock); /* already at irq level */ spin_lock(&ced->char_out_lock); /* already at irq level */
ced->dwNumOutput -= nGot; /* Now adjust the char send buffer */ ced->num_output -= nGot; /* Now adjust the char send buffer */
ced->dwOutBuffGet += nGot; /* to match what we did */ ced->out_buff_get += nGot; /* to match what we did */
if (ced->dwOutBuffGet >= OUTBUF_SZ) /* Can't do this any earlier as data could be overwritten */ if (ced->out_buff_get >= OUTBUF_SZ) /* Can't do this any earlier as data could be overwritten */
ced->dwOutBuffGet = 0; ced->out_buff_get = 0;
if (ced->dwNumOutput > 0) { /* if more to be done... */ if (ced->num_output > 0) { /* if more to be done... */
int nPipe = 0; /* The pipe number to use */ int nPipe = 0; /* The pipe number to use */
int iReturn; int iReturn;
char *pDat = &ced->outputBuffer[ced->dwOutBuffGet]; char *pDat = &ced->output_buffer[ced->out_buff_get];
unsigned int dwCount = ced->dwNumOutput; /* maximum to send */ unsigned int dwCount = ced->num_output; /* maximum to send */
if ((ced->dwOutBuffGet + dwCount) > OUTBUF_SZ) /* does it cross buffer end? */ if ((ced->out_buff_get + dwCount) > OUTBUF_SZ) /* does it cross buffer end? */
dwCount = OUTBUF_SZ - ced->dwOutBuffGet; dwCount = OUTBUF_SZ - ced->out_buff_get;
spin_unlock(&ced->charOutLock); /* we are done with stuff that changes */
memcpy(ced->pCoherCharOut, pDat, dwCount); /* copy output data to the buffer */ /* we are done with stuff that changes */
usb_fill_bulk_urb(ced->pUrbCharOut, ced->udev, spin_unlock(&ced->char_out_lock);
memcpy(ced->coher_char_out, pDat, dwCount); /* copy output data to the buffer */
usb_fill_bulk_urb(ced->urb_char_out, ced->udev,
usb_sndbulkpipe(ced->udev, usb_sndbulkpipe(ced->udev,
ced->epAddr[0]), ced->ep_addr[0]),
ced->pCoherCharOut, dwCount, ced->coher_char_out, dwCount,
ced_writechar_callback, ced); ced_writechar_callback, ced);
ced->pUrbCharOut->transfer_flags |= ced->urb_char_out->transfer_flags |=
URB_NO_TRANSFER_DMA_MAP; URB_NO_TRANSFER_DMA_MAP;
usb_anchor_urb(ced->pUrbCharOut, &ced->submitted); /* in case we need to kill it */ usb_anchor_urb(ced->urb_char_out, &ced->submitted); /* in case we need to kill it */
iReturn = usb_submit_urb(ced->pUrbCharOut, GFP_ATOMIC); iReturn = usb_submit_urb(ced->urb_char_out, GFP_ATOMIC);
dev_dbg(&ced->interface->dev, "%s: n=%d>%s<\n", dev_dbg(&ced->interface->dev, "%s: n=%d>%s<\n",
__func__, dwCount, pDat); __func__, dwCount, pDat);
spin_lock(&ced->charOutLock); /* grab lock for errors */ spin_lock(&ced->char_out_lock); /* grab lock for errors */
if (iReturn) { if (iReturn) {
ced->bPipeError[nPipe] = 1; /* Flag an error to be handled later */ ced->pipe_error[nPipe] = 1; /* Flag an error to be handled later */
ced->bSendCharsPending = false; /* Allow other threads again */ ced->send_chars_pending = false; /* Allow other threads again */
usb_unanchor_urb(ced->pUrbCharOut); usb_unanchor_urb(ced->urb_char_out);
dev_err(&ced->interface->dev, dev_err(&ced->interface->dev,
"%s: usb_submit_urb() returned %d\n", "%s: usb_submit_urb() returned %d\n",
__func__, iReturn); __func__, iReturn);
} }
} else } else
ced->bSendCharsPending = false; /* Allow other threads again */ /* Allow other threads again */
spin_unlock(&ced->charOutLock); /* already at irq level */ ced->send_chars_pending = false;
spin_unlock(&ced->char_out_lock); /* already at irq level */
} }
} }
...@@ -341,25 +346,26 @@ int ced_send_chars(struct ced_data *ced) ...@@ -341,25 +346,26 @@ int ced_send_chars(struct ced_data *ced)
{ {
int iReturn = U14ERR_NOERROR; int iReturn = U14ERR_NOERROR;
spin_lock_irq(&ced->charOutLock); /* Protect ourselves */ spin_lock_irq(&ced->char_out_lock); /* Protect ourselves */
if ((!ced->bSendCharsPending) && /* Not currently sending */ if ((!ced->send_chars_pending) && /* Not currently sending */
(ced->dwNumOutput > 0) && /* has characters to output */ (ced->num_output > 0) && /* has characters to output */
(can_accept_io_requests(ced))) { /* and current activity is OK */ (can_accept_io_requests(ced))) { /* and current activity is OK */
unsigned int dwCount = ced->dwNumOutput; /* Get a copy of the character count */ unsigned int dwCount = ced->num_output; /* Get a copy of the */
ced->bSendCharsPending = true; /* Set flag to lock out other threads */ /* character count */
ced->send_chars_pending = true; /* Set flag to lock out other threads */
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"Send %d chars to 1401, EP0 flag %d\n", "Send %d chars to 1401, EP0 flag %d\n",
dwCount, ced->nPipes == 3); dwCount, ced->n_pipes == 3);
/* If we have only 3 end points we must send the characters to the 1401 using EP0. */ /* If we have only 3 end points we must send the characters to the 1401 using EP0. */
if (ced->nPipes == 3) { if (ced->n_pipes == 3) {
/* For EP0 character transmissions to the 1401, we have to hang about until they */ /* For EP0 character transmissions to the 1401, we have to hang about until they */
/* are gone, as otherwise without more character IO activity they will never go. */ /* are gone, as otherwise without more character IO activity they will never go. */
unsigned int count = dwCount; /* Local char counter */ unsigned int count = dwCount; /* Local char counter */
unsigned int index = 0; /* The index into the char buffer */ unsigned int index = 0; /* The index into the char buffer */
spin_unlock_irq(&ced->charOutLock); /* Free spinlock as we call USBD */ spin_unlock_irq(&ced->char_out_lock); /* Free spinlock as we call USBD */
while ((count > 0) && (iReturn == U14ERR_NOERROR)) { while ((count > 0) && (iReturn == U14ERR_NOERROR)) {
/* We have to break the transfer up into 64-byte chunks because of a 2270 problem */ /* We have to break the transfer up into 64-byte chunks because of a 2270 problem */
...@@ -369,7 +375,7 @@ int ced_send_chars(struct ced_data *ced) ...@@ -369,7 +375,7 @@ int ced_send_chars(struct ced_data *ced)
DB_CHARS, /* bRequest */ DB_CHARS, /* bRequest */
(H_TO_D | VENDOR | DEVREQ), /* to the device, vendor request to the device */ (H_TO_D | VENDOR | DEVREQ), /* to the device, vendor request to the device */
0, 0, /* value and index are both 0 */ 0, 0, /* value and index are both 0 */
&ced->outputBuffer[index], /* where to send from */ &ced->output_buffer[index], /* where to send from */
n, /* how much to send */ n, /* how much to send */
1000); /* timeout in jiffies */ 1000); /* timeout in jiffies */
if (nSent <= 0) { if (nSent <= 0) {
...@@ -385,50 +391,53 @@ int ced_send_chars(struct ced_data *ced) ...@@ -385,50 +391,53 @@ int ced_send_chars(struct ced_data *ced)
} }
} }
spin_lock_irq(&ced->charOutLock); /* Protect ced changes, released by general code */ spin_lock_irq(&ced->char_out_lock); /* Protect ced changes, released by general code */
ced->dwOutBuffGet = 0; /* so reset the output buffer */ ced->out_buff_get = 0; /* so reset the output buffer */
ced->dwOutBuffPut = 0; ced->out_buff_put = 0;
ced->dwNumOutput = 0; /* and clear the buffer count */ ced->num_output = 0; /* and clear the buffer count */
ced->bSendCharsPending = false; /* Allow other threads again */ ced->send_chars_pending = false; /* Allow other threads again */
} else { /* Here for sending chars normally - we hold the spin lock */ } else { /* Here for sending chars normally - we hold the spin lock */
int nPipe = 0; /* The pipe number to use */ int nPipe = 0; /* The pipe number to use */
char *pDat = &ced->outputBuffer[ced->dwOutBuffGet]; char *pDat = &ced->output_buffer[ced->out_buff_get];
if ((ced->dwOutBuffGet + dwCount) > OUTBUF_SZ) /* does it cross buffer end? */ if ((ced->out_buff_get + dwCount) > OUTBUF_SZ) /* does it cross buffer end? */
dwCount = OUTBUF_SZ - ced->dwOutBuffGet; dwCount = OUTBUF_SZ - ced->out_buff_get;
spin_unlock_irq(&ced->charOutLock); /* we are done with stuff that changes */ spin_unlock_irq(&ced->char_out_lock); /* we are done with stuff that changes */
memcpy(ced->pCoherCharOut, pDat, dwCount); /* copy output data to the buffer */ memcpy(ced->coher_char_out, pDat, dwCount); /* copy output data to the buffer */
usb_fill_bulk_urb(ced->pUrbCharOut, ced->udev, usb_fill_bulk_urb(ced->urb_char_out, ced->udev,
usb_sndbulkpipe(ced->udev, usb_sndbulkpipe(ced->udev,
ced->epAddr[0]), ced->ep_addr[0]),
ced->pCoherCharOut, dwCount, ced->coher_char_out, dwCount,
ced_writechar_callback, ced); ced_writechar_callback, ced);
ced->pUrbCharOut->transfer_flags |= ced->urb_char_out->transfer_flags |=
URB_NO_TRANSFER_DMA_MAP; URB_NO_TRANSFER_DMA_MAP;
usb_anchor_urb(ced->pUrbCharOut, &ced->submitted); usb_anchor_urb(ced->urb_char_out, &ced->submitted);
iReturn = usb_submit_urb(ced->pUrbCharOut, GFP_KERNEL); iReturn = usb_submit_urb(ced->urb_char_out, GFP_KERNEL);
spin_lock_irq(&ced->charOutLock); /* grab lock for errors */
/* grab lock for errors */
spin_lock_irq(&ced->char_out_lock);
if (iReturn) { if (iReturn) {
ced->bPipeError[nPipe] = 1; /* Flag an error to be handled later */ ced->pipe_error[nPipe] = 1; /* Flag an error to be handled later */
ced->bSendCharsPending = false; /* Allow other threads again */ ced->send_chars_pending = false; /* Allow other threads again */
usb_unanchor_urb(ced->pUrbCharOut); /* remove from list of active urbs */ usb_unanchor_urb(ced->urb_char_out); /* remove from list of active urbs */
} }
} }
} else if (ced->bSendCharsPending && (ced->dwNumOutput > 0)) } else if (ced->send_chars_pending && (ced->num_output > 0))
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: bSendCharsPending:true\n", __func__); "%s: send_chars_pending:true\n", __func__);
dev_dbg(&ced->interface->dev, "%s: exit code: %d\n", __func__, iReturn); dev_dbg(&ced->interface->dev, "%s: exit code: %d\n", __func__, iReturn);
spin_unlock_irq(&ced->charOutLock); /* Now let go of the spinlock */ spin_unlock_irq(&ced->char_out_lock); /* Now let go of the spinlock */
return iReturn; return iReturn;
} }
/*************************************************************************** /***************************************************************************
** ced_copy_user_space ** ced_copy_user_space
** This moves memory between pinned down user space and the pCoherStagedIO ** This moves memory between pinned down user space and the coher_staged_io
** memory buffer we use for transfers. Copy n bytes in the directions that ** memory buffer we use for transfers. Copy n bytes in the directions that
** is defined by ced->StagedRead. The user space is determined by the area ** is defined by ced->staged_read. The user space is determined by the area
** in ced->StagedId and the offset in ced->StagedDone. The user ** in ced->staged_id and the offset in ced->staged_done. The user
** area may well not start on a page boundary, so allow for that. ** area may well not start on a page boundary, so allow for that.
** **
** We have a table of physical pages that describe the area, so we can use ** We have a table of physical pages that describe the area, so we can use
...@@ -439,13 +448,13 @@ int ced_send_chars(struct ced_data *ced) ...@@ -439,13 +448,13 @@ int ced_send_chars(struct ced_data *ced)
***************************************************************************/ ***************************************************************************/
static void ced_copy_user_space(struct ced_data *ced, int n) static void ced_copy_user_space(struct ced_data *ced, int n)
{ {
unsigned int nArea = ced->StagedId; unsigned int nArea = ced->staged_id;
if (nArea < MAX_TRANSAREAS) { if (nArea < MAX_TRANSAREAS) {
/* area to be used */ /* area to be used */
struct transarea *pArea = &ced->rTransDef[nArea]; struct transarea *pArea = &ced->trans_def[nArea];
unsigned int dwOffset = unsigned int dwOffset =
ced->StagedDone + ced->StagedOffset + pArea->base_offset; ced->staged_done + ced->staged_offset + pArea->base_offset;
char *pCoherBuf = ced->pCoherStagedIO; /* coherent buffer */ char *pCoherBuf = ced->coher_staged_io; /* coherent buffer */
if (!pArea->used) { 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);
...@@ -462,7 +471,7 @@ static void ced_copy_user_space(struct ced_data *ced, int n) ...@@ -462,7 +471,7 @@ static void ced_copy_user_space(struct ced_data *ced, int n)
size_t uiXfer = PAGE_SIZE - uiPageOff; /* max to transfer on this page */ size_t uiXfer = PAGE_SIZE - uiPageOff; /* max to transfer on this page */
if (uiXfer > n) /* limit byte count if too much */ if (uiXfer > n) /* limit byte count if too much */
uiXfer = n; /* for the page */ uiXfer = n; /* for the page */
if (ced->StagedRead) if (ced->staged_read)
memcpy(pvAddress + uiPageOff, memcpy(pvAddress + uiPageOff,
pCoherBuf, uiXfer); pCoherBuf, uiXfer);
else else
...@@ -506,8 +515,9 @@ static void staged_callback(struct urb *pUrb) ...@@ -506,8 +515,9 @@ static void staged_callback(struct urb *pUrb)
bool bCancel = false; bool bCancel = false;
bool bRestartCharInput; /* used at the end */ bool bRestartCharInput; /* used at the end */
spin_lock(&ced->stagedLock); /* stop ced_read_write_mem() action while this routine is running */ spin_lock(&ced->staged_lock); /* stop ced_read_write_mem() action */
ced->bStagedUrbPending = false; /* clear the flag for staged IRP pending */ /* while this routine is running */
ced->staged_urb_pending = false; /* clear the flag for staged IRP pending */
if (pUrb->status) { /* sync/async unlink faults aren't errors */ if (pUrb->status) { /* sync/async unlink faults aren't errors */
if (! if (!
...@@ -528,38 +538,38 @@ static void staged_callback(struct urb *pUrb) ...@@ -528,38 +538,38 @@ static void staged_callback(struct urb *pUrb)
} else { } else {
dev_dbg(&ced->interface->dev, "%s: %d chars xferred\n", dev_dbg(&ced->interface->dev, "%s: %d chars xferred\n",
__func__, nGot); __func__, nGot);
if (ced->StagedRead) /* if reading, save to user space */ if (ced->staged_read) /* if reading, save to user space */
ced_copy_user_space(ced, nGot); /* copy from buffer to user */ ced_copy_user_space(ced, nGot); /* copy from buffer to user */
if (nGot == 0) if (nGot == 0)
dev_dbg(&ced->interface->dev, "%s: ZLP\n", __func__); dev_dbg(&ced->interface->dev, "%s: ZLP\n", __func__);
} }
/* Update the transfer length based on the TransferBufferLength value in the URB */ /* Update the transfer length based on the TransferBufferLength value in the URB */
ced->StagedDone += nGot; ced->staged_done += nGot;
dev_dbg(&ced->interface->dev, "%s: done %d bytes of %d\n", dev_dbg(&ced->interface->dev, "%s: done %d bytes of %d\n",
__func__, ced->StagedDone, ced->StagedLength); __func__, ced->staged_done, ced->staged_length);
if ((ced->StagedDone == ced->StagedLength) || /* If no more to do */ if ((ced->staged_done == ced->staged_length) || /* If no more to do */
(bCancel)) { /* or this IRP was cancelled */ (bCancel)) { /* or this IRP was cancelled */
/* Transfer area info */ /* Transfer area info */
struct transarea *pArea = &ced->rTransDef[ced->StagedId]; struct transarea *pArea = &ced->trans_def[ced->staged_id];
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: transfer done, bytes %d, cancel %d\n", "%s: transfer done, bytes %d, cancel %d\n",
__func__, ced->StagedDone, bCancel); __func__, ced->staged_done, bCancel);
/* Here is where we sort out what to do with this transfer if using a circular buffer. We have */ /* Here is where we sort out what to do with this transfer if using a circular buffer. We have */
/* 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->circular) && (pArea->circ_to_host) && (!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->staged_read)) {/* Only for tohost transfers for now */
if (pArea->blocks[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->staged_offset ==
(pArea->blocks[1].offset + (pArea->blocks[1].offset +
pArea->blocks[1].size)) { pArea->blocks[1].size)) {
pArea->blocks[1].size += pArea->blocks[1].size +=
ced->StagedLength; ced->staged_length;
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->blocks[1].size, pArea->blocks[1].size,
...@@ -567,9 +577,9 @@ static void staged_callback(struct urb *pUrb) ...@@ -567,9 +577,9 @@ static void staged_callback(struct urb *pUrb)
} 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->blocks[1].offset = pArea->blocks[1].offset =
ced->StagedOffset; ced->staged_offset;
pArea->blocks[1].size = pArea->blocks[1].size =
ced->StagedLength; ced->staged_length;
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__,
...@@ -579,10 +589,10 @@ static void staged_callback(struct urb *pUrb) ...@@ -579,10 +589,10 @@ static void staged_callback(struct urb *pUrb)
} 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->blocks[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->staged_offset ==
(pArea->blocks[0].offset + (pArea->blocks[0].offset +
pArea->blocks[0].size)) { pArea->blocks[0].size)) {
pArea->blocks[0].size += ced->StagedLength; /* Just add this transfer in */ pArea->blocks[0].size += ced->staged_length; /* 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->blocks[0]. pArea->blocks[0].
...@@ -591,9 +601,9 @@ static void staged_callback(struct urb *pUrb) ...@@ -591,9 +601,9 @@ static void staged_callback(struct urb *pUrb)
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->blocks[1].offset = pArea->blocks[1].offset =
ced->StagedOffset; ced->staged_offset;
pArea->blocks[1].size = pArea->blocks[1].size =
ced->StagedLength; ced->staged_length;
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->blocks[1]. pArea->blocks[1].
...@@ -603,9 +613,9 @@ static void staged_callback(struct urb *pUrb) ...@@ -603,9 +613,9 @@ static void staged_callback(struct urb *pUrb)
} }
} else { /* No info stored yet, just save in block 0 */ } else { /* No info stored yet, just save in block 0 */
pArea->blocks[0].offset = pArea->blocks[0].offset =
ced->StagedOffset; ced->staged_offset;
pArea->blocks[0].size = pArea->blocks[0].size =
ced->StagedLength; ced->staged_length;
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->blocks[0].size, pArea->blocks[0].size,
...@@ -620,7 +630,7 @@ static void staged_callback(struct urb *pUrb) ...@@ -620,7 +630,7 @@ static void staged_callback(struct urb *pUrb)
pArea->circular, pArea->event_to_host, pArea->circular, pArea->event_to_host,
pArea->event_st, pArea->event_sz); pArea->event_st, pArea->event_sz);
if ((pArea->event_sz) && /* Set a user-mode event... */ if ((pArea->event_sz) && /* Set a user-mode event... */
(ced->StagedRead == pArea->event_to_host)) { /* ...on transfers in this direction? */ (ced->staged_read == 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 */ /* If we have completed the right sort of DMA */
...@@ -636,11 +646,11 @@ static void staged_callback(struct urb *pUrb) ...@@ -636,11 +646,11 @@ static void staged_callback(struct urb *pUrb)
iWakeUp = (dwTotal >= pArea->event_sz); iWakeUp = (dwTotal >= pArea->event_sz);
} else { } else {
unsigned int transEnd = unsigned int transEnd =
ced->StagedOffset + ced->staged_offset +
ced->StagedLength; ced->staged_length;
unsigned int eventEnd = unsigned int eventEnd =
pArea->event_st + pArea->event_sz; pArea->event_st + pArea->event_sz;
iWakeUp = (ced->StagedOffset < eventEnd) iWakeUp = (ced->staged_offset < eventEnd)
&& (transEnd > pArea->event_st); && (transEnd > pArea->event_st);
} }
...@@ -653,19 +663,19 @@ static void staged_callback(struct urb *pUrb) ...@@ -653,19 +663,19 @@ static void staged_callback(struct urb *pUrb)
} }
} }
ced->dwDMAFlag = MODE_CHAR; /* Switch back to char mode before ced_read_write_mem call */ ced->dma_flag = MODE_CHAR; /* Switch back to char mode before ced_read_write_mem 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 we have a transfer waiting, kick it off */
if (ced->bXFerWaiting) { /* Got a block xfer waiting? */ if (ced->xfer_waiting) {/* Got a block xfer waiting? */
int iReturn; int iReturn;
dev_info(&ced->interface->dev, dev_info(&ced->interface->dev,
"*** RWM_Complete *** pending transfer will now be set up!!!\n"); "*** RWM_Complete *** pending transfer will now be set up!!!\n");
iReturn = iReturn =
ced_read_write_mem(ced, !ced->rDMAInfo.outward, ced_read_write_mem(ced, !ced->dma_info.outward,
ced->rDMAInfo.ident, ced->dma_info.ident,
ced->rDMAInfo.offset, ced->dma_info.offset,
ced->rDMAInfo.size); ced->dma_info.size);
if (iReturn) if (iReturn)
dev_err(&ced->interface->dev, dev_err(&ced->interface->dev,
...@@ -677,15 +687,15 @@ static void staged_callback(struct urb *pUrb) ...@@ -677,15 +687,15 @@ static void staged_callback(struct urb *pUrb)
} else /* Here for more to do */ } else /* Here for more to do */
ced_stage_chunk(ced); /* fire off the next bit */ ced_stage_chunk(ced); /* fire off the next bit */
/* While we hold the stagedLock, see if we should reallow character input ints */ /* While we hold the staged_lock, see if we should reallow character input ints */
/* Don't allow if cancelled, or if a new block has started or if there is a waiting block. */ /* Don't allow if cancelled, or if a new block has started or if there is a waiting block. */
/* This feels wrong as we should ask which spin lock protects dwDMAFlag. */ /* This feels wrong as we should ask which spin lock protects dma_flag. */
bRestartCharInput = !bCancel && (ced->dwDMAFlag == MODE_CHAR) bRestartCharInput = !bCancel && (ced->dma_flag == MODE_CHAR) &&
&& !ced->bXFerWaiting; !ced->xfer_waiting;
spin_unlock(&ced->stagedLock); /* Finally release the lock again */ spin_unlock(&ced->staged_lock); /* Finally release the lock again */
/* This is not correct as dwDMAFlag is protected by the staged lock, but it is treated */ /* This is not correct as dma_flag is protected by the staged lock, but it is treated */
/* in ced_allowi as if it were protected by the char lock. In any case, most systems will */ /* in ced_allowi as if it were protected by the char lock. In any case, most systems will */
/* not be upset by char input during DMA... sigh. Needs sorting out. */ /* not be upset by char input during DMA... sigh. Needs sorting out. */
if (bRestartCharInput) /* may be out of date, but... */ if (bRestartCharInput) /* may be out of date, but... */
...@@ -705,8 +715,8 @@ static int ced_stage_chunk(struct ced_data *ced) ...@@ -705,8 +715,8 @@ static int ced_stage_chunk(struct ced_data *ced)
{ {
int iReturn = U14ERR_NOERROR; int iReturn = U14ERR_NOERROR;
unsigned int ChunkSize; unsigned int ChunkSize;
int nPipe = ced->StagedRead ? 3 : 2; /* The pipe number to use for reads or writes */ int nPipe = ced->staged_read ? 3 : 2; /* The pipe number to use for reads or writes */
if (ced->nPipes == 3) if (ced->n_pipes == 3)
nPipe--; /* Adjust for the 3-pipe case */ nPipe--; /* Adjust for the 3-pipe case */
if (nPipe < 0) /* and trap case that should never happen */ if (nPipe < 0) /* and trap case that should never happen */
return U14ERR_FAIL; return U14ERR_FAIL;
...@@ -717,31 +727,32 @@ static int ced_stage_chunk(struct ced_data *ced) ...@@ -717,31 +727,32 @@ static int ced_stage_chunk(struct ced_data *ced)
return U14ERR_FAIL; /* could do with a better error */ return U14ERR_FAIL; /* could do with a better error */
} }
ChunkSize = (ced->StagedLength - ced->StagedDone); /* transfer length remaining */ ChunkSize = (ced->staged_length - ced->staged_done); /* transfer length remaining */
if (ChunkSize > STAGED_SZ) /* make sure to keep legal */ if (ChunkSize > STAGED_SZ) /* make sure to keep legal */
ChunkSize = STAGED_SZ; /* limit to max allowed */ ChunkSize = STAGED_SZ; /* limit to max allowed */
if (!ced->StagedRead) /* if writing... */ if (!ced->staged_read) /* if writing... */
ced_copy_user_space(ced, ChunkSize); /* ...copy data into the buffer */ ced_copy_user_space(ced, ChunkSize); /* ...copy data into the buffer */
usb_fill_bulk_urb(ced->pStagedUrb, ced->udev, usb_fill_bulk_urb(ced->staged_urb, ced->udev,
ced->StagedRead ? usb_rcvbulkpipe(ced->udev, ced->staged_read ? usb_rcvbulkpipe(ced->udev,
ced-> ced->
epAddr[nPipe]) : ep_addr[nPipe]) :
usb_sndbulkpipe(ced->udev, ced->epAddr[nPipe]), usb_sndbulkpipe(ced->udev, ced->ep_addr[nPipe]),
ced->pCoherStagedIO, ChunkSize, staged_callback, ced); ced->coher_staged_io, ChunkSize,
ced->pStagedUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; staged_callback, ced);
usb_anchor_urb(ced->pStagedUrb, &ced->submitted); /* in case we need to kill it */ ced->staged_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
iReturn = usb_submit_urb(ced->pStagedUrb, GFP_ATOMIC); usb_anchor_urb(ced->staged_urb, &ced->submitted); /* in case we need to kill it */
iReturn = usb_submit_urb(ced->staged_urb, GFP_ATOMIC);
if (iReturn) { if (iReturn) {
usb_unanchor_urb(ced->pStagedUrb); /* kill it */ usb_unanchor_urb(ced->staged_urb); /* kill it */
ced->bPipeError[nPipe] = 1; /* Flag an error to be handled later */ ced->pipe_error[nPipe] = 1; /* Flag an error to be handled later */
dev_err(&ced->interface->dev, "%s: submit urb failed, code %d\n", dev_err(&ced->interface->dev, "%s: submit urb failed, code %d\n",
__func__, iReturn); __func__, iReturn);
} else } else
ced->bStagedUrbPending = true; /* Set the flag for staged URB pending */ ced->staged_urb_pending = true; /* Set the flag for staged URB pending */
dev_dbg(&ced->interface->dev, "%s: done so far:%d, this size:%d\n", dev_dbg(&ced->interface->dev, "%s: done so far:%d, this size:%d\n",
__func__, ced->StagedDone, ChunkSize); __func__, ced->staged_done, ChunkSize);
return iReturn; return iReturn;
} }
...@@ -753,7 +764,7 @@ static int ced_stage_chunk(struct ced_data *ced) ...@@ -753,7 +764,7 @@ static int ced_stage_chunk(struct ced_data *ced)
** Breaks up a read or write in to specified sized chunks, as specified by pipe ** Breaks up a read or write in to specified sized chunks, as specified by pipe
** information on maximum transfer size. ** information on maximum transfer size.
** **
** Any code that calls this must be holding the stagedLock ** Any code that calls this must be holding the staged_lock
** **
** Arguments: ** Arguments:
** DeviceObject - pointer to our FDO (Functional Device Object) ** DeviceObject - pointer to our FDO (Functional Device Object)
...@@ -767,7 +778,7 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent, ...@@ -767,7 +778,7 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent,
unsigned int dwOffs, unsigned int dwLen) unsigned int dwOffs, unsigned int dwLen)
{ {
/* Transfer area info */ /* Transfer area info */
struct transarea *pArea = &ced->rTransDef[wIdent]; struct transarea *pArea = &ced->trans_def[wIdent];
if (!can_accept_io_requests(ced)) { /* Are we in a state to accept new requests? */ if (!can_accept_io_requests(ced)) { /* Are we in a state to accept new requests? */
dev_err(&ced->interface->dev, "%s: can't accept requests\n", dev_err(&ced->interface->dev, "%s: can't accept requests\n",
...@@ -781,8 +792,8 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent, ...@@ -781,8 +792,8 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent,
/* 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 staged Urb is done, so we */
/* have to check for this situation and, if so, wait until all is OK. */ /* have to check for this situation and, if so, wait until all is OK. */
if (ced->bStagedUrbPending) { if (ced->staged_urb_pending) {
ced->bXFerWaiting = true; /* Flag we are waiting */ ced->xfer_waiting = true; /* Flag we are waiting */
dev_info(&ced->interface->dev, dev_info(&ced->interface->dev,
"%s: xfer is waiting, as previous staged pending\n", "%s: xfer is waiting, as previous staged pending\n",
__func__); __func__);
...@@ -823,7 +834,7 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent, ...@@ -823,7 +834,7 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent,
} }
if (bWait) { /* This transfer will have to wait? */ if (bWait) { /* This transfer will have to wait? */
ced->bXFerWaiting = true; /* Flag we are waiting */ ced->xfer_waiting = true; /* Flag we are waiting */
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: xfer waiting for circular buffer space\n", "%s: xfer waiting for circular buffer space\n",
__func__); __func__);
...@@ -835,13 +846,13 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent, ...@@ -835,13 +846,13 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent,
__func__, dwLen, dwOffs); __func__, dwLen, dwOffs);
} }
/* Save the parameters for the read\write transfer */ /* Save the parameters for the read\write transfer */
ced->StagedRead = Read; /* Save the parameters for this read */ ced->staged_read = Read; /* Save the parameters for this read */
ced->StagedId = wIdent; /* ID allows us to get transfer area info */ ced->staged_id = wIdent; /* ID allows us to get transfer area info */
ced->StagedOffset = dwOffs; /* The area within the transfer area */ ced->staged_offset = dwOffs; /* The area within the transfer area */
ced->StagedLength = dwLen; ced->staged_length = dwLen;
ced->StagedDone = 0; /* Initialise the byte count */ ced->staged_done = 0; /* Initialise the byte count */
ced->dwDMAFlag = MODE_LINEAR; /* Set DMA mode flag at this point */ ced->dma_flag = MODE_LINEAR; /* Set DMA mode flag at this point */
ced->bXFerWaiting = 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 */
...@@ -988,21 +999,21 @@ static bool ced_read_dma_info(volatile struct dmadesc *pDmaDesc, ...@@ -988,21 +999,21 @@ static bool ced_read_dma_info(volatile struct dmadesc *pDmaDesc,
pDmaDesc->size); pDmaDesc->size);
if ((wIdent >= MAX_TRANSAREAS) || /* Illegal area number, or... */ if ((wIdent >= MAX_TRANSAREAS) || /* Illegal area number, or... */
(!ced->rTransDef[wIdent].used) || /* area not set up, or... */ (!ced->trans_def[wIdent].used) || /* area not set up, or... */
(pDmaDesc->offset > ced->rTransDef[wIdent].length) || /* range/size */ (pDmaDesc->offset > ced->trans_def[wIdent].length) || /* range/size */
((pDmaDesc->offset + ((pDmaDesc->offset +
pDmaDesc->size) > pDmaDesc->size) >
(ced->rTransDef[wIdent]. (ced->trans_def[wIdent].
length))) { 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->trans_def[wIdent].
used, used,
pDmaDesc->offset, pDmaDesc->offset,
pDmaDesc->size, pDmaDesc->size,
ced->rTransDef[wIdent]. ced->trans_def[wIdent].
length); length);
} }
} }
...@@ -1046,18 +1057,19 @@ static int ced_handle_esc(struct ced_data *ced, char *pCh, ...@@ -1046,18 +1057,19 @@ static int ced_handle_esc(struct ced_data *ced, char *pCh,
if (pCh[0] == '?') { /* Is this an information response */ if (pCh[0] == '?') { /* Is this an information response */
/* Parse and save the information */ /* Parse and save the information */
} else { } else {
spin_lock(&ced->stagedLock); /* Lock others out */ spin_lock(&ced->staged_lock); /* Lock others out */
if (ced_read_dma_info(&ced->rDMAInfo, ced, pCh, dwCount)) { /* Get DMA parameters */ if (ced_read_dma_info(&ced->dma_info, ced, pCh, dwCount)) { /* Get DMA parameters */
unsigned short wTransType = ced->rDMAInfo.trans_type; /* check transfer type */ unsigned short wTransType = ced->dma_info.trans_type; /* check transfer type */
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: xfer to %s, offset %d, length %d\n", "%s: xfer to %s, offset %d, length %d\n",
__func__, __func__,
ced->rDMAInfo.outward ? "1401" : "host", ced->dma_info.outward ? "1401" : "host",
ced->rDMAInfo.offset, ced->rDMAInfo.size); ced->dma_info.offset, ced->dma_info.size);
if (ced->bXFerWaiting) { /* Check here for badly out of kilter... */ /* Check here for badly out of kilter... */
if (ced->xfer_waiting) {
/* This can never happen, really */ /* This can never happen, really */
dev_err(&ced->interface->dev, dev_err(&ced->interface->dev,
"ERROR: DMA setup while transfer still waiting\n"); "ERROR: DMA setup while transfer still waiting\n");
...@@ -1066,10 +1078,10 @@ static int ced_handle_esc(struct ced_data *ced, char *pCh, ...@@ -1066,10 +1078,10 @@ static int ced_handle_esc(struct ced_data *ced, char *pCh,
|| (wTransType == TM_EXTTO1401)) { || (wTransType == TM_EXTTO1401)) {
iReturn = iReturn =
ced_read_write_mem(ced, ced_read_write_mem(ced,
!ced->rDMAInfo.outward, !ced->dma_info.outward,
ced->rDMAInfo.ident, ced->dma_info.ident,
ced->rDMAInfo.offset, ced->dma_info.offset,
ced->rDMAInfo.size); ced->dma_info.size);
if (iReturn != U14ERR_NOERROR) if (iReturn != U14ERR_NOERROR)
dev_err(&ced->interface->dev, dev_err(&ced->interface->dev,
"%s: ced_read_write_mem() failed %d\n", "%s: ced_read_write_mem() failed %d\n",
...@@ -1083,7 +1095,7 @@ static int ced_handle_esc(struct ced_data *ced, char *pCh, ...@@ -1083,7 +1095,7 @@ static int ced_handle_esc(struct ced_data *ced, char *pCh,
dev_err(&ced->interface->dev, "%s: ced_read_dma_info() fail\n", dev_err(&ced->interface->dev, "%s: ced_read_dma_info() fail\n",
__func__); __func__);
spin_unlock(&ced->stagedLock); /* OK here */ spin_unlock(&ced->staged_lock); /* OK here */
} }
dev_dbg(&ced->interface->dev, "%s: returns %d\n", __func__, iReturn); dev_dbg(&ced->interface->dev, "%s: returns %d\n", __func__, iReturn);
...@@ -1100,7 +1112,7 @@ static void ced_readchar_callback(struct urb *pUrb) ...@@ -1100,7 +1112,7 @@ static void ced_readchar_callback(struct urb *pUrb)
int nGot = pUrb->actual_length; /* what we transferred */ 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 = ced->nPipes == 4 ? 1 : 0; /* The pipe number to use for error */ int nPipe = ced->n_pipes == 4 ? 1 : 0; /* The pipe number to use for error */
/* sync/async unlink faults aren't errors... just saying device removed or stopped */ /* sync/async unlink faults aren't errors... just saying device removed or stopped */
if (! if (!
(pUrb->status == -ENOENT || pUrb->status == -ECONNRESET (pUrb->status == -ENOENT || pUrb->status == -ECONNRESET
...@@ -1118,41 +1130,41 @@ static void ced_readchar_callback(struct urb *pUrb) ...@@ -1118,41 +1130,41 @@ static void ced_readchar_callback(struct urb *pUrb)
spin_unlock(&ced->err_lock); spin_unlock(&ced->err_lock);
nGot = 0; /* and tidy up again if so */ nGot = 0; /* and tidy up again if so */
spin_lock(&ced->charInLock); /* already at irq level */ spin_lock(&ced->char_in_lock); /* already at irq level */
ced->bPipeError[nPipe] = 1; /* Flag an error for later */ ced->pipe_error[nPipe] = 1; /* Flag an error for later */
} else { } else {
if ((nGot > 1) && ((ced->pCoherCharIn[0] & 0x7f) == 0x1b)) { /* Esc sequence? */ if ((nGot > 1) && ((ced->coher_char_in[0] & 0x7f) == 0x1b)) { /* Esc sequence? */
ced_handle_esc(ced, &ced->pCoherCharIn[1], nGot - 1); /* handle it */ ced_handle_esc(ced, &ced->coher_char_in[1], nGot - 1); /* handle it */
spin_lock(&ced->charInLock); /* already at irq level */ spin_lock(&ced->char_in_lock); /* already at irq level */
} else { } else {
spin_lock(&ced->charInLock); /* already at irq level */ spin_lock(&ced->char_in_lock); /* already at irq level */
if (nGot > 0) { if (nGot > 0) {
unsigned int i; unsigned int i;
if (nGot < INBUF_SZ) { if (nGot < INBUF_SZ) {
ced->pCoherCharIn[nGot] = 0; /* tidy the string */ ced->coher_char_in[nGot] = 0; /* tidy the string */
dev_dbg(&ced->interface->dev, dev_dbg(&ced->interface->dev,
"%s: got %d chars >%s<\n", "%s: got %d chars >%s<\n",
__func__, nGot, __func__, nGot,
ced->pCoherCharIn); ced->coher_char_in);
} }
/* We know that whatever we read must fit in the input buffer */ /* We know that whatever we read must fit in the input buffer */
for (i = 0; i < nGot; i++) { for (i = 0; i < nGot; i++) {
ced->inputBuffer[ced->dwInBuffPut++] = ced->input_buffer[ced->in_buff_put++] =
ced->pCoherCharIn[i] & 0x7F; ced->coher_char_in[i] & 0x7F;
if (ced->dwInBuffPut >= INBUF_SZ) if (ced->in_buff_put >= INBUF_SZ)
ced->dwInBuffPut = 0; ced->in_buff_put = 0;
} }
if ((ced->dwNumInput + nGot) <= INBUF_SZ) if ((ced->num_input + nGot) <= INBUF_SZ)
ced->dwNumInput += nGot; /* Adjust the buffer count accordingly */ ced->num_input += nGot; /* Adjust the buffer count accordingly */
} else } else
dev_dbg(&ced->interface->dev, "%s: read ZLP\n", dev_dbg(&ced->interface->dev, "%s: read ZLP\n",
__func__); __func__);
} }
} }
ced->bReadCharsPending = false; /* No longer have a pending read */ ced->read_chars_pending = false; /* No longer have a pending read */
spin_unlock(&ced->charInLock); /* already at irq level */ spin_unlock(&ced->char_in_lock); /* already at irq level */
ced_allowi(ced); /* see if we can do the next one */ ced_allowi(ced); /* see if we can do the next one */
} }
...@@ -1168,43 +1180,50 @@ int ced_allowi(struct ced_data *ced) ...@@ -1168,43 +1180,50 @@ int ced_allowi(struct ced_data *ced)
{ {
int iReturn = U14ERR_NOERROR; int iReturn = U14ERR_NOERROR;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&ced->charInLock, flags); /* can be called in multiple contexts */
/* can be called in multiple contexts */
spin_lock_irqsave(&ced->char_in_lock, flags);
/* We don't want char input running while DMA is in progress as we know that this */ /* We don't want char input running while DMA is in progress as we know that this */
/* can cause sequencing problems for the 2270. So don't. It will also allow the */ /* can cause sequencing problems for the 2270. So don't. It will also allow the */
/* ERR response to get back to the host code too early on some PCs, even if there */ /* ERR response to get back to the host code too early on some PCs, even if there */
/* is no actual driver failure, so we don't allow this at all. */ /* is no actual driver failure, so we don't allow this at all. */
if (!ced->bInDrawDown && /* stop input if */ if (!ced->in_draw_down && /* stop input if */
!ced->bReadCharsPending && /* If no read request outstanding */ !ced->read_chars_pending && /* If no read request outstanding */
(ced->dwNumInput < (INBUF_SZ / 2)) && /* and there is some space */ (ced->num_input < (INBUF_SZ / 2)) && /* and there is some space */
(ced->dwDMAFlag == MODE_CHAR) && /* not doing any DMA */ (ced->dma_flag == MODE_CHAR) && /* not doing any DMA */
(!ced->bXFerWaiting) && /* no xfer waiting to start */ (!ced->xfer_waiting) && /* no xfer waiting to start */
(can_accept_io_requests(ced))) { /* and activity is generally OK */ (can_accept_io_requests(ced))) { /* and activity is generally OK */
/* then off we go */ /* then off we go */
unsigned int nMax = INBUF_SZ - ced->dwNumInput; /* max we could read */ unsigned int nMax = INBUF_SZ - ced->num_input; /* max we could read */
int nPipe = ced->nPipes == 4 ? 1 : 0; /* The pipe number to use */ int nPipe = ced->n_pipes == 4 ? 1 : 0; /* The pipe number to use */
dev_dbg(&ced->interface->dev, "%s: %d chars in input buffer\n", dev_dbg(&ced->interface->dev, "%s: %d chars in input buffer\n",
__func__, ced->dwNumInput); __func__, ced->num_input);
usb_fill_int_urb(ced->pUrbCharIn, ced->udev, usb_fill_int_urb(ced->urb_char_in, ced->udev,
usb_rcvintpipe(ced->udev, ced->epAddr[nPipe]), usb_rcvintpipe(ced->udev, ced->ep_addr[nPipe]),
ced->pCoherCharIn, nMax, ced_readchar_callback, ced->coher_char_in, nMax, ced_readchar_callback,
ced, ced->bInterval); ced, ced->interval);
ced->pUrbCharIn->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; /* short xfers are OK by default */
usb_anchor_urb(ced->pUrbCharIn, &ced->submitted); /* in case we need to kill it */ /* short xfers are OK by default */
iReturn = usb_submit_urb(ced->pUrbCharIn, GFP_ATOMIC); ced->urb_char_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
/* in case we need to kill it */
usb_anchor_urb(ced->urb_char_in, &ced->submitted);
iReturn = usb_submit_urb(ced->urb_char_in, GFP_ATOMIC);
if (iReturn) { if (iReturn) {
usb_unanchor_urb(ced->pUrbCharIn); /* remove from list of active Urbs */ usb_unanchor_urb(ced->urb_char_in); /* remove from list of active Urbs */
ced->bPipeError[nPipe] = 1; /* Flag an error to be handled later */ ced->pipe_error[nPipe] = 1; /* Flag an error to be handled later */
dev_err(&ced->interface->dev, dev_err(&ced->interface->dev,
"%s: submit urb failed: %d\n", "%s: submit urb failed: %d\n",
__func__, iReturn); __func__, iReturn);
} else } else
ced->bReadCharsPending = true; /* Flag that we are active here */ ced->read_chars_pending = true; /* Flag that we are active here */
} }
spin_unlock_irqrestore(&ced->charInLock, flags); spin_unlock_irqrestore(&ced->char_in_lock, flags);
return iReturn; return iReturn;
...@@ -1318,7 +1337,7 @@ static long ced_ioctl(struct file *file, unsigned int cmd, unsigned long ulArg) ...@@ -1318,7 +1337,7 @@ static long ced_ioctl(struct file *file, unsigned int cmd, unsigned long ulArg)
return ced_dbg_stop_loop(ced); return ced_dbg_stop_loop(ced);
case _IOC_NR(IOCTL_CED_FULLRESET): case _IOC_NR(IOCTL_CED_FULLRESET):
ced->bForceReset = true; /* Set a flag for a full reset */ ced->force_reset = true; /* Set a flag for a full reset */
break; break;
case _IOC_NR(IOCTL_CED_SETCIRCULAR): case _IOC_NR(IOCTL_CED_SETCIRCULAR):
...@@ -1378,14 +1397,14 @@ static int ced_probe(struct usb_interface *interface, ...@@ -1378,14 +1397,14 @@ 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].event); init_waitqueue_head(&ced->trans_def[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 */
/* no need to explicitly zero it. */ /* no need to explicitly zero it. */
spin_lock_init(&ced->charOutLock); spin_lock_init(&ced->char_out_lock);
spin_lock_init(&ced->charInLock); spin_lock_init(&ced->char_in_lock);
spin_lock_init(&ced->stagedLock); spin_lock_init(&ced->staged_lock);
/* Initialises from the skeleton stuff */ /* Initialises from the skeleton stuff */
kref_init(&ced->kref); kref_init(&ced->kref);
...@@ -1400,9 +1419,9 @@ static int ced_probe(struct usb_interface *interface, ...@@ -1400,9 +1419,9 @@ static int ced_probe(struct usb_interface *interface,
bcdDevice = ced->udev->descriptor.bcdDevice; bcdDevice = ced->udev->descriptor.bcdDevice;
i = (bcdDevice >> 8); i = (bcdDevice >> 8);
if (i == 0) if (i == 0)
ced->s1401Type = TYPEU1401; ced->type = TYPEU1401;
else if ((i >= 1) && (i <= 23)) else if ((i >= 1) && (i <= 23))
ced->s1401Type = i + 2; ced->type = i + 2;
else { else {
dev_err(&interface->dev, "%s: Unknown device. bcdDevice = %d\n", dev_err(&interface->dev, "%s: Unknown device. bcdDevice = %d\n",
__func__, bcdDevice); __func__, bcdDevice);
...@@ -1411,53 +1430,55 @@ static int ced_probe(struct usb_interface *interface, ...@@ -1411,53 +1430,55 @@ static int ced_probe(struct usb_interface *interface,
/* set up the endpoint information. We only care about the number of EP as */ /* set up the endpoint information. We only care about the number of EP as */
/* we know that we are dealing with a 1401 device. */ /* we know that we are dealing with a 1401 device. */
iface_desc = interface->cur_altsetting; iface_desc = interface->cur_altsetting;
ced->nPipes = iface_desc->desc.bNumEndpoints; ced->n_pipes = iface_desc->desc.bNumEndpoints;
dev_info(&interface->dev, "1401Type=%d with %d End Points\n", dev_info(&interface->dev, "1401Type=%d with %d End Points\n",
ced->s1401Type, ced->nPipes); ced->type, ced->n_pipes);
if ((ced->nPipes < 3) || (ced->nPipes > 4)) if ((ced->n_pipes < 3) || (ced->n_pipes > 4))
goto error; goto error;
/* Allocate the URBs we hold for performing transfers */ /* Allocate the URBs we hold for performing transfers */
ced->pUrbCharOut = usb_alloc_urb(0, GFP_KERNEL); /* character output URB */ ced->urb_char_out = usb_alloc_urb(0, GFP_KERNEL); /* character output URB */
ced->pUrbCharIn = usb_alloc_urb(0, GFP_KERNEL); /* character input URB */ ced->urb_char_in = usb_alloc_urb(0, GFP_KERNEL); /* character input URB */
ced->pStagedUrb = usb_alloc_urb(0, GFP_KERNEL); /* block transfer URB */ ced->staged_urb = usb_alloc_urb(0, GFP_KERNEL); /* block transfer URB */
if (!ced->pUrbCharOut || !ced->pUrbCharIn || !ced->pStagedUrb) { if (!ced->urb_char_out || !ced->urb_char_in || !ced->staged_urb) {
dev_err(&interface->dev, "%s: URB alloc failed\n", __func__); dev_err(&interface->dev, "%s: URB alloc failed\n", __func__);
goto error; goto error;
} }
ced->pCoherStagedIO = ced->coher_staged_io =
usb_alloc_coherent(ced->udev, STAGED_SZ, GFP_KERNEL, usb_alloc_coherent(ced->udev, STAGED_SZ, GFP_KERNEL,
&ced->pStagedUrb->transfer_dma); &ced->staged_urb->transfer_dma);
ced->pCoherCharOut = ced->coher_char_out =
usb_alloc_coherent(ced->udev, OUTBUF_SZ, GFP_KERNEL, usb_alloc_coherent(ced->udev, OUTBUF_SZ, GFP_KERNEL,
&ced->pUrbCharOut->transfer_dma); &ced->urb_char_out->transfer_dma);
ced->pCoherCharIn = ced->coher_char_in =
usb_alloc_coherent(ced->udev, INBUF_SZ, GFP_KERNEL, usb_alloc_coherent(ced->udev, INBUF_SZ, GFP_KERNEL,
&ced->pUrbCharIn->transfer_dma); &ced->urb_char_in->transfer_dma);
if (!ced->pCoherCharOut || !ced->pCoherCharIn || !ced->pCoherStagedIO) { if (!ced->coher_char_out || !ced->coher_char_in ||
!ced->coher_staged_io) {
dev_err(&interface->dev, "%s: Coherent buffer alloc failed\n", dev_err(&interface->dev, "%s: Coherent buffer alloc failed\n",
__func__); __func__);
goto error; goto error;
} }
for (i = 0; i < ced->nPipes; ++i) { for (i = 0; i < ced->n_pipes; ++i) {
endpoint = &iface_desc->endpoint[i].desc; endpoint = &iface_desc->endpoint[i].desc;
ced->epAddr[i] = endpoint->bEndpointAddress; ced->ep_addr[i] = endpoint->bEndpointAddress;
dev_info(&interface->dev, "Pipe %d, ep address %02x\n", dev_info(&interface->dev, "Pipe %d, ep address %02x\n",
i, ced->epAddr[i]); i, ced->ep_addr[i]);
if (((ced->nPipes == 3) && (i == 0)) || /* if char input end point */ if (((ced->n_pipes == 3) && (i == 0)) || /* if char input end point */
((ced->nPipes == 4) && (i == 1))) { ((ced->n_pipes == 4) && (i == 1))) {
ced->bInterval = endpoint->bInterval; /* save the endpoint interrupt interval */ /* save the endpoint interrupt interval */
dev_info(&interface->dev, "Pipe %d, bInterval = %d\n", ced->interval = endpoint->bInterval;
i, ced->bInterval); dev_info(&interface->dev, "Pipe %d, interval = %d\n",
i, ced->interval);
} }
/* Detect USB2 by checking last ep size (64 if USB1) */ /* Detect USB2 by checking last ep size (64 if USB1) */
if (i == ced->nPipes - 1) { /* if this is the last ep (bulk) */ if (i == ced->n_pipes - 1) { /* if this is the last ep (bulk) */
ced->bIsUSB2 = ced->is_usb2 =
le16_to_cpu(endpoint->wMaxPacketSize) > 64; le16_to_cpu(endpoint->wMaxPacketSize) > 64;
dev_info(&ced->interface->dev, "USB%d\n", dev_info(&ced->interface->dev, "USB%d\n",
ced->bIsUSB2 + 1); ced->is_usb2 + 1);
} }
} }
...@@ -1522,13 +1543,13 @@ void ced_draw_down(struct ced_data *ced) ...@@ -1522,13 +1543,13 @@ void ced_draw_down(struct ced_data *ced)
int time; int time;
dev_dbg(&ced->interface->dev, "%s: called\n", __func__); dev_dbg(&ced->interface->dev, "%s: called\n", __func__);
ced->bInDrawDown = true; ced->in_draw_down = true;
time = usb_wait_anchor_empty_timeout(&ced->submitted, 3000); time = usb_wait_anchor_empty_timeout(&ced->submitted, 3000);
if (!time) { /* if we timed out we kill the urbs */ if (!time) { /* if we timed out we kill the urbs */
usb_kill_anchored_urbs(&ced->submitted); usb_kill_anchored_urbs(&ced->submitted);
dev_err(&ced->interface->dev, "%s: timed out\n", __func__); dev_err(&ced->interface->dev, "%s: timed out\n", __func__);
} }
ced->bInDrawDown = false; ced->in_draw_down = false;
} }
static int ced_suspend(struct usb_interface *intf, pm_message_t message) static int ced_suspend(struct usb_interface *intf, pm_message_t message)
......
...@@ -140,61 +140,63 @@ struct dmadesc { ...@@ -140,61 +140,63 @@ struct dmadesc {
#define OUTBUF_SZ 256 /* output buffer size */ #define OUTBUF_SZ 256 /* output buffer size */
#define STAGED_SZ 0x10000 /* size of coherent buffer for staged transfers */ #define STAGED_SZ 0x10000 /* size of coherent buffer for staged transfers */
/* Structure to hold all of our device specific stuff. We are making this as similar as we */ /* Structure to hold all of our device specific stuff. We are making this as */
/* can to the Windows driver to help in our understanding of what is going on. */ /* similar as we can to the Windows driver to help in our understanding of */
/* what is going on. */
struct ced_data { struct ced_data {
char inputBuffer[INBUF_SZ]; /* The two buffers */ char input_buffer[INBUF_SZ]; /* The two buffers */
char outputBuffer[OUTBUF_SZ]; /* accessed by the host functions */ char output_buffer[OUTBUF_SZ]; /* accessed by the host functions */
volatile unsigned int dwNumInput; /* num of chars in input buffer */ volatile unsigned int num_input; /* num of chars in input buffer */
volatile unsigned int dwInBuffGet; /* where to get from input buffer */ volatile unsigned int in_buff_get; /* where to get from input buffer */
volatile unsigned int dwInBuffPut; /* where to put into input buffer */ volatile unsigned int in_buff_put; /* where to put into input buffer */
volatile unsigned int dwNumOutput; /* num of chars in output buffer */ volatile unsigned int num_output; /* num of chars in output buffer */
volatile unsigned int dwOutBuffGet; /* where to get from output buffer*/ volatile unsigned int out_buff_get; /* where to get from output buffer*/
volatile unsigned int dwOutBuffPut; /* where to put into output buffer*/ volatile unsigned int out_buff_put; /* where to put into output buffer*/
volatile bool bSendCharsPending; /* Flag to indicate sendchar active */ volatile bool send_chars_pending; /* Flag to indicate sendchar active */
volatile bool bReadCharsPending; /* Flag to indicate a read is primed */ volatile bool read_chars_pending; /* Flag to indicate a read is primed*/
char *pCoherCharOut; /* special aligned buffer for chars to 1401 */ char *coher_char_out; /* special aligned buffer for chars to 1401 */
struct urb *pUrbCharOut; /* urb used for chars to 1401 */ struct urb *urb_char_out; /* urb used for chars to 1401 */
char *pCoherCharIn; /* special aligned buffer for chars to host */ char *coher_char_in; /* special aligned buffer for chars to host */
struct urb *pUrbCharIn; /* urb used for chars to host */ struct urb *urb_char_in; /* urb used for chars to host */
spinlock_t charOutLock; /* to protect the outputBuffer and outputting */ spinlock_t char_out_lock; /* protect the output_buffer and outputting */
spinlock_t charInLock; /* to protect the inputBuffer and char reads */ spinlock_t char_in_lock; /* protect the input_buffer and char reads */
__u8 bInterval; /* Interrupt end point interval */ __u8 interval; /* Interrupt end point interval */
volatile unsigned int dwDMAFlag; /* state of DMA */ volatile unsigned int dma_flag; /* state of DMA */
struct transarea rTransDef[MAX_TRANSAREAS]; /* transfer area info */ struct transarea trans_def[MAX_TRANSAREAS]; /* transfer area info */
volatile struct dmadesc rDMAInfo; /* info on current DMA transfer */ volatile struct dmadesc dma_info; /* info on current DMA transfer */
volatile bool bXFerWaiting; /* Flag set if DMA transfer stalled */ volatile bool xfer_waiting; /* Flag set if DMA transfer stalled */
volatile bool bInDrawDown; /* Flag that we want to halt transfers */ volatile bool in_draw_down; /* Flag that we want to halt transfers */
/* Parameters relating to a block read\write that is in progress. Some of these values */ /* Parameters relating to a block read\write that is in progress. Some of these values */
/* are equivalent to values in rDMAInfo. The values here are those in use, while those */ /* are equivalent to values in dma_info. The values here are those in use, while those */
/* in rDMAInfo are those received from the 1401 via an escape sequence. If another */ /* in dma_info are those received from the 1401 via an escape sequence. If another */
/* escape sequence arrives before the previous xfer ends, rDMAInfo values are updated while these */ /* escape sequence arrives before the previous xfer ends, dma_info values are updated while these */
/* are used to finish off the current transfer. */ /* are used to finish off the current transfer. */
volatile short StagedId; /* The transfer area id for this transfer */ volatile short staged_id; /* The transfer area id for this transfer */
volatile bool StagedRead; /* Flag TRUE for read from 1401, FALSE for write */ volatile bool staged_read; /* Flag TRUE for read from 1401, FALSE for write */
volatile unsigned int StagedLength; /* Total length of this transfer */ volatile unsigned int staged_length; /* Total length of this transfer */
volatile unsigned int StagedOffset; /* Offset within memory area for transfer start */ volatile unsigned int staged_offset; /* Offset within memory area for transfer start */
volatile unsigned int StagedDone; /* Bytes transferred so far */ volatile unsigned int staged_done; /* Bytes transferred so far */
volatile bool bStagedUrbPending; /* Flag to indicate active */ volatile bool staged_urb_pending; /* Flag to indicate active */
char *pCoherStagedIO; /* buffer used for block transfers */ char *coher_staged_io; /* buffer used for block transfers */
struct urb *pStagedUrb; /* The URB to use */ struct urb *staged_urb; /* The URB to use */
spinlock_t stagedLock; /* protects ReadWriteMem() and circular buffer stuff */ spinlock_t staged_lock; /* protects ReadWriteMem() and */
/* circular buffer stuff */
short s1401Type; /* type of 1401 attached */
short sCurrentState; /* current error state */ short type; /* type of 1401 attached */
bool bIsUSB2; /* type of the interface we connect to */ short current_state; /* current error state */
bool bForceReset; /* Flag to make sure we get a real reset */ bool is_usb2; /* type of the interface we connect to */
__u32 statBuf[2]; /* buffer for 1401 state info */ bool force_reset; /* Flag to make sure we get a real reset */
__u32 stat_buf[2]; /* buffer for 1401 state info */
unsigned long ulSelfTestTime; /* used to timeout self test */
unsigned long self_test_time; /* used to timeout self test */
int nPipes; /* Should be 3 or 4 depending on 1401 usb chip */
int bPipeError[4]; /* set non-zero if an error on one of the pipe */ int n_pipes; /* Should be 3 or 4 depending on 1401 usb chip */
__u8 epAddr[4]; /* addresses of the 3/4 end points */ int pipe_error[4]; /* set non-zero if an error on one of the pipe */
__u8 ep_addr[4]; /* addresses of the 3/4 end points */
struct usb_device *udev; /* the usb device for this device */ struct usb_device *udev; /* the usb device for this device */
struct usb_interface *interface; /* the interface for this device, NULL if removed */ struct usb_interface *interface; /* the interface for this device, NULL if removed */
......
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