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 @@
****************************************************************************/
static void ced_flush_out_buff(struct ced_data *ced)
{
dev_dbg(&ced->interface->dev, "%s: currentState=%d\n",
__func__, ced->sCurrentState);
if (ced->sCurrentState == U14ERR_TIME) /* Do nothing if hardware in trouble */
dev_dbg(&ced->interface->dev, "%s: current_state=%d\n",
__func__, ced->current_state);
/* Do nothing if hardware in trouble */
if (ced->current_state == U14ERR_TIME)
return;
/* Kill off any pending I/O */
/* CharSend_Cancel(ced); */
spin_lock_irq(&ced->charOutLock);
ced->dwNumOutput = 0;
ced->dwOutBuffGet = 0;
ced->dwOutBuffPut = 0;
spin_unlock_irq(&ced->charOutLock);
spin_lock_irq(&ced->char_out_lock);
ced->num_output = 0;
ced->out_buff_get = 0;
ced->out_buff_put = 0;
spin_unlock_irq(&ced->char_out_lock);
}
/****************************************************************************
......@@ -59,17 +61,17 @@ static void ced_flush_out_buff(struct ced_data *ced)
****************************************************************************/
static void ced_flush_in_buff(struct ced_data *ced)
{
dev_dbg(&ced->interface->dev, "%s: currentState=%d\n",
__func__, ced->sCurrentState);
if (ced->sCurrentState == U14ERR_TIME) /* Do nothing if hardware in trouble */
dev_dbg(&ced->interface->dev, "%s: current_state=%d\n",
__func__, ced->current_state);
if (ced->current_state == U14ERR_TIME) /* Do nothing if hardware in trouble */
return;
/* Kill off any pending I/O */
/* CharRead_Cancel(pDevObject); */
spin_lock_irq(&ced->charInLock);
ced->dwNumInput = 0;
ced->dwInBuffGet = 0;
ced->dwInBuffPut = 0;
spin_unlock_irq(&ced->charInLock);
spin_lock_irq(&ced->char_in_lock);
ced->num_input = 0;
ced->in_buff_get = 0;
ced->in_buff_put = 0;
spin_unlock_irq(&ced->char_in_lock);
}
/****************************************************************************
......@@ -82,20 +84,20 @@ static int ced_put_chars(struct ced_data *ced, const char *pCh,
unsigned int uCount)
{
int iReturn;
spin_lock_irq(&ced->charOutLock); /* get the output spin lock */
if ((OUTBUF_SZ - ced->dwNumOutput) >= uCount) {
spin_lock_irq(&ced->char_out_lock); /* get the output spin lock */
if ((OUTBUF_SZ - ced->num_output) >= uCount) {
unsigned int u;
for (u = 0; u < uCount; u++) {
ced->outputBuffer[ced->dwOutBuffPut++] = pCh[u];
if (ced->dwOutBuffPut >= OUTBUF_SZ)
ced->dwOutBuffPut = 0;
ced->output_buffer[ced->out_buff_put++] = pCh[u];
if (ced->out_buff_put >= OUTBUF_SZ)
ced->out_buff_put = 0;
}
ced->dwNumOutput += uCount;
spin_unlock_irq(&ced->charOutLock);
ced->num_output += uCount;
spin_unlock_irq(&ced->char_out_lock);
iReturn = ced_send_chars(ced); /* ...give a chance to transmit data */
} else {
iReturn = U14ERR_NOOUT; /* no room at the out (ha-ha) */
spin_unlock_irq(&ced->charOutLock);
spin_unlock_irq(&ced->char_out_lock);
}
return iReturn;
}
......@@ -179,38 +181,38 @@ int ced_get_state(struct ced_data *ced, __u32 *state, __u32 *error)
*state = 0xFFFFFFFF; /* Start off with invalid state */
nGot = usb_control_msg(ced->udev, usb_rcvctrlpipe(ced->udev, 0),
GET_STATUS, (D_TO_H | VENDOR | DEVREQ), 0, 0,
ced->statBuf, sizeof(ced->statBuf), HZ);
if (nGot != sizeof(ced->statBuf)) {
ced->stat_buf, sizeof(ced->stat_buf), HZ);
if (nGot != sizeof(ced->stat_buf)) {
dev_err(&ced->interface->dev,
"%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 */
*error = 0;
} else {
int nDevice;
dev_dbg(&ced->interface->dev,
"%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 */
*error = ced->statBuf[1];
*state = ced->stat_buf[0]; /* Return the state values to the calling code */
*error = ced->stat_buf[1];
nDevice = ced->udev->descriptor.bcdDevice >> 8; /* 1401 type code value */
switch (nDevice) { /* so we can clean up current state */
case 0:
ced->sCurrentState = U14ERR_U1401;
ced->current_state = U14ERR_U1401;
break;
default: /* allow lots of device codes for future 1401s */
if ((nDevice >= 1) && (nDevice <= 23))
ced->sCurrentState = (short)(nDevice + 6);
ced->current_state = (short)(nDevice + 6);
else
ced->sCurrentState = U14ERR_ILL;
ced->current_state = U14ERR_ILL;
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)
int ced_read_write_cancel(struct ced_data *ced)
{
dev_dbg(&ced->interface->dev, "%s: entry %d\n",
__func__, ced->bStagedUrbPending);
__func__, ced->staged_urb_pending);
#ifdef NOT_WRITTEN_YET
int ntStatus = STATUS_SUCCESS;
bool bResult = false;
unsigned int i;
/* 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,
"ced_read_write_cancel about to cancel Urb\n");
/* Clear the staging done flag */
......@@ -238,7 +240,7 @@ int ced_read_write_cancel(struct ced_data *ced)
/* Release the spinlock first otherwise the completion routine may hang */
/* 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 */
if (bResult) {
LARGE_INTEGER timeout;
......@@ -258,7 +260,7 @@ int ced_read_write_cancel(struct ced_data *ced)
("ced_read_write_cancel ntStatus = 0x%x decimal %d\n",
ntStatus, ntStatus));
} else
spin_unlock_irq(&ced->stagedLock);
spin_unlock_irq(&ced->staged_lock);
dev_info(&ced->interface - dev, "%s: done\n", __func__);
return ntStatus;
......@@ -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
**
** 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_OFF 1401 apparently not switched on
......@@ -323,7 +325,7 @@ static bool ced_is_1401(struct ced_data *ced)
}
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 */
unsigned int state;
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)
iReturn = state == 0; /* then success is that the state is 0 */
} else
iReturn = 0; /* we failed */
ced->bForceReset = false; /* Clear forced reset flag now */
ced->force_reset = false; /* Clear forced reset flag now */
return iReturn > 0;
}
......@@ -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 bShortTest;
bShortTest = ((ced->dwDMAFlag == MODE_CHAR) && /* no DMA running */
(!ced->bForceReset) && /* Not had a real reset forced */
(ced->sCurrentState >= U14ERR_STD)); /* No 1401 errors stored */
bShortTest = ((ced->dma_flag == MODE_CHAR) && /* no DMA running */
(!ced->force_reset) && /* Not had a real reset forced */
(ced->current_state >= U14ERR_STD)); /* No 1401 errors stored */
dev_dbg(&ced->interface->dev,
"%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);
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 */
dev_dbg(&ced->interface->dev,
"%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
if (!bRet && bCanReset) { /* If all not OK, then */
dev_info(&ced->interface->dev, "%s: ced_is_1401 %d %d %d %d\n",
__func__, bShortTest, ced->sCurrentState, bTestBuff,
ced->bForceReset);
__func__, bShortTest, ced->current_state, bTestBuff,
ced->force_reset);
bRet = ced_is_1401(ced); /* do full test */
}
......@@ -429,15 +431,15 @@ int ced_get_char(struct ced_data *ced)
ced_allowi(ced); /* Make sure char reads are running */
ced_send_chars(ced); /* and send any buffered chars */
spin_lock_irq(&ced->charInLock);
if (ced->dwNumInput > 0) { /* worth looking */
iReturn = ced->inputBuffer[ced->dwInBuffGet++];
if (ced->dwInBuffGet >= INBUF_SZ)
ced->dwInBuffGet = 0;
ced->dwNumInput--;
spin_lock_irq(&ced->char_in_lock);
if (ced->num_input > 0) { /* worth looking */
iReturn = ced->input_buffer[ced->in_buff_get++];
if (ced->in_buff_get >= INBUF_SZ)
ced->in_buff_get = 0;
ced->num_input--;
} else
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 */
......@@ -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_send_chars(ced); /* and send any buffered chars */
spin_lock_irq(&ced->charInLock);
nAvailable = ced->dwNumInput; /* characters available now */
spin_lock_irq(&ced->char_in_lock);
nAvailable = ced->num_input; /* characters available now */
if (nAvailable > n) /* read max of space in pUser... */
nAvailable = n; /* ...or input characters */
......@@ -478,12 +480,12 @@ int ced_get_string(struct ced_data *ced, char __user *pUser, int n)
int nCopyToUser; /* number to copy to user */
char cData;
do {
cData = ced->inputBuffer[ced->dwInBuffGet++];
cData = ced->input_buffer[ced->in_buff_get++];
if (cData == CR_CHAR) /* replace CR with zero */
cData = (char)0;
if (ced->dwInBuffGet >= INBUF_SZ)
ced->dwInBuffGet = 0; /* wrap buffer pointer */
if (ced->in_buff_get >= INBUF_SZ)
ced->in_buff_get = 0; /* wrap buffer pointer */
buffer[nGot++] = cData; /* save the output */
} while ((nGot < nAvailable) && cData);
......@@ -495,8 +497,8 @@ int ced_get_string(struct ced_data *ced, char __user *pUser, int n)
++nCopyToUser; /* ...copy the 0 as well. */
}
ced->dwNumInput -= nGot;
spin_unlock_irq(&ced->charInLock);
ced->num_input -= nGot;
spin_unlock_irq(&ced->char_in_lock);
dev_dbg(&ced->interface->dev, "%s: read %d characters >%s<\n",
__func__, nGot, buffer);
......@@ -505,7 +507,7 @@ int ced_get_string(struct ced_data *ced, char __user *pUser, int n)
else
iReturn = nGot; /* report characters read */
} else
spin_unlock_irq(&ced->charInLock);
spin_unlock_irq(&ced->char_in_lock);
ced_allowi(ced); /* Make sure char reads are running */
mutex_unlock(&ced->io_mutex); /* Protect disconnect from new i/o */
......@@ -522,7 +524,7 @@ int ced_stat_1401(struct ced_data *ced)
mutex_lock(&ced->io_mutex); /* Protect disconnect from new i/o */
ced_allowi(ced); /* make sure we allow pending chars */
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 */
return iReturn;
}
......@@ -541,13 +543,13 @@ int ced_line_count(struct ced_data *ced)
mutex_lock(&ced->io_mutex); /* Protect disconnect from new i/o */
ced_allowi(ced); /* Make sure char reads are running */
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? */
unsigned int dwIndex = ced->dwInBuffGet; /* start at first available */
unsigned int dwEnd = ced->dwInBuffPut; /* Position for search end */
if (ced->num_input > 0) { /* worth looking? */
unsigned int dwIndex = ced->in_buff_get; /* start at first available */
unsigned int dwEnd = ced->in_buff_put; /* Position for search end */
do {
if (ced->inputBuffer[dwIndex++] == CR_CHAR)
if (ced->input_buffer[dwIndex++] == CR_CHAR)
++iReturn; /* inc count if CR */
if (dwIndex >= INBUF_SZ) /* see if we fall off buff */
......@@ -555,7 +557,7 @@ int ced_line_count(struct ced_data *ced)
} 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);
mutex_unlock(&ced->io_mutex); /* Protect disconnect from new i/o */
return iReturn;
......@@ -571,7 +573,7 @@ int ced_get_out_buf_space(struct ced_data *ced)
int iReturn;
mutex_lock(&ced->io_mutex); /* Protect disconnect from new i/o */
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);
mutex_unlock(&ced->io_mutex); /* Protect disconnect from new i/o */
return iReturn;
......@@ -594,7 +596,7 @@ int ced_clear_area(struct ced_data *ced, int nArea)
__func__, nArea);
} else {
/* to save typing */
struct transarea *pTA = &ced->rTransDef[nArea];
struct transarea *pTA = &ced->trans_def[nArea];
if (!pTA->used) /* if not used... */
iReturn = U14ERR_NOTSET; /* ...nothing to be done */
else {
......@@ -606,9 +608,9 @@ int ced_clear_area(struct ced_data *ced, int nArea)
dev_dbg(&ced->interface->dev, "%s: area %d\n",
__func__, nArea);
spin_lock_irq(&ced->stagedLock);
if ((ced->StagedId == nArea)
&& (ced->dwDMAFlag > MODE_CHAR)) {
spin_lock_irq(&ced->staged_lock);
if ((ced->staged_id == nArea)
&& (ced->dma_flag > MODE_CHAR)) {
iReturn = U14ERR_UNLOCKFAIL; /* cannot delete as in use */
dev_err(&ced->interface->dev,
"%s: call on area %d while active\n",
......@@ -619,9 +621,9 @@ int ced_clear_area(struct ced_data *ced, int nArea)
if (pTA->event_sz) /* if events flagging in use */
wake_up_interruptible(&pTA->event); /* release anything that was waiting */
if (ced->bXFerWaiting
&& (ced->rDMAInfo.ident == nArea))
ced->bXFerWaiting = false; /* Cannot have pending xfer if area cleared */
if (ced->xfer_waiting
&& (ced->dma_info.ident == nArea))
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 */
/* 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)
sizeof(struct transarea) -
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 */
/* 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,
unsigned int ulOffset = ((unsigned long)puBuf) & (PAGE_SIZE - 1);
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 */
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,
/* 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 */
/* (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->base_offset = ulOffset; /* save offset in first page to start of xfer */
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,
pTA->blocks[1].size = 0;
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 */
} else {
iReturn = U14ERR_LOCKFAIL;
......@@ -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 */
return U14ERR_BADAREA;
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 */
spin_lock_irq(&ced->stagedLock);
spin_lock_irq(&ced->staged_lock);
if (pTA->used) { /* area must be in use */
pTA->event_st = te.dwStart; /* set area regions */
pTA->event_sz = te.dwLength; /* set size (0 cancels it) */
......@@ -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 */
} else
iReturn = U14ERR_NOTSET;
spin_unlock_irq(&ced->stagedLock);
spin_unlock_irq(&ced->staged_lock);
mutex_unlock(&ced->io_mutex);
}
return iReturn ==
......@@ -822,7 +824,7 @@ int ced_wait_event(struct ced_data *ced, int nArea, int msTimeOut)
return U14ERR_BADAREA;
else {
int iWait;
struct transarea *pTA = &ced->rTransDef[nArea];
struct transarea *pTA = &ced->trans_def[nArea];
msTimeOut = (msTimeOut * HZ + 999) / 1000; /* convert timeout to jiffies */
/* 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)
else
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 */
spin_unlock_irq(&ced->stagedLock);
spin_unlock_irq(&ced->staged_lock);
}
return iReturn;
}
......@@ -868,12 +870,12 @@ int ced_test_event(struct ced_data *ced, int nArea)
if ((unsigned)nArea >= MAX_TRANSAREAS)
iReturn = U14ERR_BADAREA;
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 */
spin_lock_irq(&ced->stagedLock);
spin_lock_irq(&ced->staged_lock);
iReturn = pTA->wake_up; /* get wakeup count since last call */
pTA->wake_up = 0; /* clear the count */
spin_unlock_irq(&ced->stagedLock);
spin_unlock_irq(&ced->staged_lock);
mutex_unlock(&ced->io_mutex);
}
return iReturn;
......@@ -889,7 +891,7 @@ int ced_get_transfer(struct ced_data *ced, TGET_TX_BLOCK __user *pTX)
unsigned int dwIdent;
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)
iReturn = U14ERR_BADAREA;
else {
......@@ -901,12 +903,12 @@ int ced_get_transfer(struct ced_data *ced, TGET_TX_BLOCK __user *pTX)
mutex_unlock(&ced->io_mutex);
return -ENOMEM;
}
tx->size = ced->rTransDef[dwIdent].length;
tx->linear = (long long)((long)ced->rTransDef[dwIdent].buff);
tx->size = ced->trans_def[dwIdent].length;
tx->linear = (long long)((long)ced->trans_def[dwIdent].buff);
tx->avail = GET_TX_MAXENTRIES; /* how many blocks we could return */
tx->used = 1; /* number we actually return */
tx->entries[0].physical =
(long long)(tx->linear + ced->StagedOffset);
(long long)(tx->linear + ced->staged_offset);
tx->entries[0].size = tx->size;
if (copy_to_user(pTX, tx, sizeof(*tx)))
......@@ -943,7 +945,7 @@ int ced_state_of_1401(struct ced_data *ced)
mutex_lock(&ced->io_mutex);
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);
dev_dbg(&ced->interface->dev, "%s: %d\n", __func__, iReturn);
......@@ -968,12 +970,12 @@ int ced_start_self_test(struct ced_data *ced)
ced_flush_out_buff(ced); /* Clear output buffer & pipe */
/* so things stay tidy */
/* 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),
DB_SELFTEST, (H_TO_D | VENDOR | DEVREQ),
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);
if (nGot < 0)
......@@ -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);
} else { /* No error, check for timeout */
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 */
dev_dbg(&ced->interface->dev,
"Self-test timed-out\n");
......@@ -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 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 */
else
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)
mutex_lock(&ced->io_mutex);
dev_dbg(&ced->interface->dev, "%s\n", __func__);
switch (ced->s1401Type) {
switch (ced->type) {
case TYPE1401:
iReturn = U14ERR_STD;
break; /* Handle these types directly */
......@@ -1077,8 +1079,8 @@ int ced_type_of_1401(struct ced_data *ced)
iReturn = U14ERR_U1401;
break;
default:
if ((ced->s1401Type >= TYPEPOWER) && (ced->s1401Type <= 25))
iReturn = ced->s1401Type + 4; /* We can calculate types */
if ((ced->type >= TYPEPOWER) && (ced->type <= 25))
iReturn = ced->type + 4; /* We can calculate types */
else /* for up-coming 1401 designs */
iReturn = TYPEUNKNOWN; /* Don't know or not there */
}
......@@ -1099,7 +1101,7 @@ int ced_transfer_flags(struct ced_data *ced)
U14TF_NOTIFY | U14TF_CIRCTH; /* diagnostics, notify and circular */
dev_dbg(&ced->interface->dev, "%s\n", __func__);
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;
mutex_unlock(&ced->io_mutex);
......@@ -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 */
/* Pointer to relevant info */
struct transarea *pArea = &ced->rTransDef[nArea];
spin_lock_irq(&ced->stagedLock); /* Lock others out */
struct transarea *pArea = &ced->trans_def[nArea];
spin_lock_irq(&ced->staged_lock); /* Lock others out */
if ((pArea->used) && (pArea->circular) && /* Must be circular area */
(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)
} else
iReturn = U14ERR_NOTSET;
spin_unlock_irq(&ced->stagedLock);
spin_unlock_irq(&ced->staged_lock);
} else
iReturn = U14ERR_BADAREA;
......@@ -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 */
/* Pointer to relevant info */
struct transarea *pArea = &ced->rTransDef[nArea];
spin_lock_irq(&ced->stagedLock); /* Lock others out */
struct transarea *pArea = &ced->trans_def[nArea];
spin_lock_irq(&ced->staged_lock); /* Lock others out */
if ((pArea->used) && (pArea->circular) && /* Must be circular area */
(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)
__func__, uSize, uStart,
pArea->blocks[0].size,
pArea->blocks[0].offset,
ced->bXFerWaiting);
ced->xfer_waiting);
/* Return the next available block of memory as well */
if (pArea->blocks[0].size > 0) { /* Got anything? */
......@@ -1442,8 +1444,8 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
cb.dwSize = pArea->blocks[0].size;
}
bWaiting = ced->bXFerWaiting;
if (bWaiting && ced->bStagedUrbPending) {
bWaiting = ced->xfer_waiting;
if (bWaiting && ced->staged_urb_pending) {
dev_err(&ced->interface->dev,
"%s: ERROR: waiting xfer and staged Urb pending!\n",
__func__);
......@@ -1462,10 +1464,10 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
if (bWaiting) { /* Got a block xfer waiting? */
int RWMStat =
ced_read_write_mem(ced,
!ced->rDMAInfo.outward,
ced->rDMAInfo.ident,
ced->rDMAInfo.offset,
ced->rDMAInfo.size);
!ced->dma_info.outward,
ced->dma_info.ident,
ced->dma_info.offset,
ced->dma_info.size);
if (RWMStat != U14ERR_NOERROR)
dev_err(&ced->interface->dev,
"%s: rw setup failed %d\n",
......@@ -1474,7 +1476,7 @@ int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB)
} else
iReturn = U14ERR_NOTSET;
spin_unlock_irq(&ced->stagedLock);
spin_unlock_irq(&ced->staged_lock);
} else
iReturn = U14ERR_BADAREA;
......
......@@ -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 */
/* of ced will probably be NULL, so cannot be used to get to dev. */
usb_free_coherent(ced->udev, OUTBUF_SZ, ced->pCoherCharOut,
ced->pUrbCharOut->transfer_dma);
usb_free_urb(ced->pUrbCharOut);
usb_free_coherent(ced->udev, OUTBUF_SZ, ced->coher_char_out,
ced->urb_char_out->transfer_dma);
usb_free_urb(ced->urb_char_out);
/* Do the same for chan input */
usb_free_coherent(ced->udev, INBUF_SZ, ced->pCoherCharIn,
ced->pUrbCharIn->transfer_dma);
usb_free_urb(ced->pUrbCharIn);
usb_free_coherent(ced->udev, INBUF_SZ, ced->coher_char_in,
ced->urb_char_in->transfer_dma);
usb_free_urb(ced->urb_char_in);
/* Do the same for the block transfers */
usb_free_coherent(ced->udev, STAGED_SZ, ced->pCoherStagedIO,
ced->pStagedUrb->transfer_dma);
usb_free_urb(ced->pStagedUrb);
usb_free_coherent(ced->udev, STAGED_SZ, ced->coher_staged_io,
ced->staged_urb->transfer_dma);
usb_free_urb(ced->staged_urb);
usb_put_dev(ced->udev);
kfree(ced);
......@@ -225,7 +225,7 @@ static int ced_flush(struct file *file, fl_owner_t id)
return -ENODEV;
dev_dbg(&ced->interface->dev, "%s: char in pend=%d\n",
__func__, ced->bReadCharsPending);
__func__, ced->read_chars_pending);
/* wait for io to stop */
mutex_lock(&ced->io_mutex);
......@@ -279,56 +279,61 @@ static void ced_writechar_callback(struct urb *pUrb)
spin_unlock(&ced->err_lock);
nGot = 0; /* and tidy up again if so */
spin_lock(&ced->charOutLock); /* already at irq level */
ced->dwOutBuffGet = 0; /* Reset the output buffer */
ced->dwOutBuffPut = 0;
ced->dwNumOutput = 0; /* Clear the char count */
ced->bPipeError[0] = 1; /* Flag an error for later */
ced->bSendCharsPending = false; /* Allow other threads again */
spin_unlock(&ced->charOutLock); /* already at irq level */
spin_lock(&ced->char_out_lock); /* already at irq level */
ced->out_buff_get = 0; /* Reset the output buffer */
ced->out_buff_put = 0;
ced->num_output = 0; /* Clear the char count */
ced->pipe_error[0] = 1; /* Flag an error for later */
ced->send_chars_pending = false; /* Allow other threads again */
spin_unlock(&ced->char_out_lock); /* already at irq level */
dev_dbg(&ced->interface->dev,
"%s: char out done, 0 chars sent\n", __func__);
} else {
dev_dbg(&ced->interface->dev,
"%s: char out done, %d chars sent\n", __func__, nGot);
spin_lock(&ced->charOutLock); /* already at irq level */
ced->dwNumOutput -= nGot; /* Now adjust the char send buffer */
ced->dwOutBuffGet += nGot; /* to match what we did */
if (ced->dwOutBuffGet >= OUTBUF_SZ) /* Can't do this any earlier as data could be overwritten */
ced->dwOutBuffGet = 0;
spin_lock(&ced->char_out_lock); /* already at irq level */
ced->num_output -= nGot; /* Now adjust the char send buffer */
ced->out_buff_get += nGot; /* to match what we did */
if (ced->out_buff_get >= OUTBUF_SZ) /* Can't do this any earlier as data could be overwritten */
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 iReturn;
char *pDat = &ced->outputBuffer[ced->dwOutBuffGet];
unsigned int dwCount = ced->dwNumOutput; /* maximum to send */
if ((ced->dwOutBuffGet + dwCount) > OUTBUF_SZ) /* does it cross buffer end? */
dwCount = OUTBUF_SZ - ced->dwOutBuffGet;
spin_unlock(&ced->charOutLock); /* we are done with stuff that changes */
memcpy(ced->pCoherCharOut, pDat, dwCount); /* copy output data to the buffer */
usb_fill_bulk_urb(ced->pUrbCharOut, ced->udev,
char *pDat = &ced->output_buffer[ced->out_buff_get];
unsigned int dwCount = ced->num_output; /* maximum to send */
if ((ced->out_buff_get + dwCount) > OUTBUF_SZ) /* does it cross buffer end? */
dwCount = OUTBUF_SZ - ced->out_buff_get;
/* we are done with stuff that changes */
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,
ced->epAddr[0]),
ced->pCoherCharOut, dwCount,
ced->ep_addr[0]),
ced->coher_char_out, dwCount,
ced_writechar_callback, ced);
ced->pUrbCharOut->transfer_flags |=
ced->urb_char_out->transfer_flags |=
URB_NO_TRANSFER_DMA_MAP;
usb_anchor_urb(ced->pUrbCharOut, &ced->submitted); /* in case we need to kill it */
iReturn = usb_submit_urb(ced->pUrbCharOut, GFP_ATOMIC);
usb_anchor_urb(ced->urb_char_out, &ced->submitted); /* in case we need to kill it */
iReturn = usb_submit_urb(ced->urb_char_out, GFP_ATOMIC);
dev_dbg(&ced->interface->dev, "%s: n=%d>%s<\n",
__func__, dwCount, pDat);
spin_lock(&ced->charOutLock); /* grab lock for errors */
spin_lock(&ced->char_out_lock); /* grab lock for errors */
if (iReturn) {
ced->bPipeError[nPipe] = 1; /* Flag an error to be handled later */
ced->bSendCharsPending = false; /* Allow other threads again */
usb_unanchor_urb(ced->pUrbCharOut);
ced->pipe_error[nPipe] = 1; /* Flag an error to be handled later */
ced->send_chars_pending = false; /* Allow other threads again */
usb_unanchor_urb(ced->urb_char_out);
dev_err(&ced->interface->dev,
"%s: usb_submit_urb() returned %d\n",
__func__, iReturn);
}
} else
ced->bSendCharsPending = false; /* Allow other threads again */
spin_unlock(&ced->charOutLock); /* already at irq level */
/* Allow other threads again */
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)
{
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 */
(ced->dwNumOutput > 0) && /* has characters to output */
if ((!ced->send_chars_pending) && /* Not currently sending */
(ced->num_output > 0) && /* has characters to output */
(can_accept_io_requests(ced))) { /* and current activity is OK */
unsigned int dwCount = ced->dwNumOutput; /* Get a copy of the character count */
ced->bSendCharsPending = true; /* Set flag to lock out other threads */
unsigned int dwCount = ced->num_output; /* Get a copy of the */
/* character count */
ced->send_chars_pending = true; /* Set flag to lock out other threads */
dev_dbg(&ced->interface->dev,
"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 (ced->nPipes == 3) {
if (ced->n_pipes == 3) {
/* 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. */
unsigned int count = dwCount; /* Local char counter */
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)) {
/* 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)
DB_CHARS, /* bRequest */
(H_TO_D | VENDOR | DEVREQ), /* to the device, vendor request to the device */
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 */
1000); /* timeout in jiffies */
if (nSent <= 0) {
......@@ -385,50 +391,53 @@ int ced_send_chars(struct ced_data *ced)
}
}
spin_lock_irq(&ced->charOutLock); /* Protect ced changes, released by general code */
ced->dwOutBuffGet = 0; /* so reset the output buffer */
ced->dwOutBuffPut = 0;
ced->dwNumOutput = 0; /* and clear the buffer count */
ced->bSendCharsPending = false; /* Allow other threads again */
spin_lock_irq(&ced->char_out_lock); /* Protect ced changes, released by general code */
ced->out_buff_get = 0; /* so reset the output buffer */
ced->out_buff_put = 0;
ced->num_output = 0; /* and clear the buffer count */
ced->send_chars_pending = false; /* Allow other threads again */
} else { /* Here for sending chars normally - we hold the spin lock */
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? */
dwCount = OUTBUF_SZ - ced->dwOutBuffGet;
spin_unlock_irq(&ced->charOutLock); /* we are done with stuff that changes */
memcpy(ced->pCoherCharOut, pDat, dwCount); /* copy output data to the buffer */
usb_fill_bulk_urb(ced->pUrbCharOut, ced->udev,
if ((ced->out_buff_get + dwCount) > OUTBUF_SZ) /* does it cross buffer end? */
dwCount = OUTBUF_SZ - ced->out_buff_get;
spin_unlock_irq(&ced->char_out_lock); /* we are done with stuff that changes */
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,
ced->epAddr[0]),
ced->pCoherCharOut, dwCount,
ced->ep_addr[0]),
ced->coher_char_out, dwCount,
ced_writechar_callback, ced);
ced->pUrbCharOut->transfer_flags |=
ced->urb_char_out->transfer_flags |=
URB_NO_TRANSFER_DMA_MAP;
usb_anchor_urb(ced->pUrbCharOut, &ced->submitted);
iReturn = usb_submit_urb(ced->pUrbCharOut, GFP_KERNEL);
spin_lock_irq(&ced->charOutLock); /* grab lock for errors */
usb_anchor_urb(ced->urb_char_out, &ced->submitted);
iReturn = usb_submit_urb(ced->urb_char_out, GFP_KERNEL);
/* grab lock for errors */
spin_lock_irq(&ced->char_out_lock);
if (iReturn) {
ced->bPipeError[nPipe] = 1; /* Flag an error to be handled later */
ced->bSendCharsPending = false; /* Allow other threads again */
usb_unanchor_urb(ced->pUrbCharOut); /* remove from list of active urbs */
ced->pipe_error[nPipe] = 1; /* Flag an error to be handled later */
ced->send_chars_pending = false; /* Allow other threads again */
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,
"%s: bSendCharsPending:true\n", __func__);
"%s: send_chars_pending:true\n", __func__);
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;
}
/***************************************************************************
** 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
** is defined by ced->StagedRead. The user space is determined by the area
** in ced->StagedId and the offset in ced->StagedDone. The user
** is defined by ced->staged_read. The user space is determined by the area
** 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.
**
** 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)
***************************************************************************/
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) {
/* area to be used */
struct transarea *pArea = &ced->rTransDef[nArea];
struct transarea *pArea = &ced->trans_def[nArea];
unsigned int dwOffset =
ced->StagedDone + ced->StagedOffset + pArea->base_offset;
char *pCoherBuf = ced->pCoherStagedIO; /* coherent buffer */
ced->staged_done + ced->staged_offset + pArea->base_offset;
char *pCoherBuf = ced->coher_staged_io; /* coherent buffer */
if (!pArea->used) {
dev_err(&ced->interface->dev, "%s: area %d unused\n",
__func__, nArea);
......@@ -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 */
if (uiXfer > n) /* limit byte count if too much */
uiXfer = n; /* for the page */
if (ced->StagedRead)
if (ced->staged_read)
memcpy(pvAddress + uiPageOff,
pCoherBuf, uiXfer);
else
......@@ -506,8 +515,9 @@ static void staged_callback(struct urb *pUrb)
bool bCancel = false;
bool bRestartCharInput; /* used at the end */
spin_lock(&ced->stagedLock); /* stop ced_read_write_mem() action while this routine is running */
ced->bStagedUrbPending = false; /* clear the flag for staged IRP pending */
spin_lock(&ced->staged_lock); /* stop ced_read_write_mem() action */
/* 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 (!
......@@ -528,38 +538,38 @@ static void staged_callback(struct urb *pUrb)
} else {
dev_dbg(&ced->interface->dev, "%s: %d chars xferred\n",
__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 */
if (nGot == 0)
dev_dbg(&ced->interface->dev, "%s: ZLP\n", __func__);
}
/* 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",
__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 */
/* Transfer area info */
struct transarea *pArea = &ced->rTransDef[ced->StagedId];
struct transarea *pArea = &ced->trans_def[ced->staged_id];
dev_dbg(&ced->interface->dev,
"%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 */
/* a completed transfer that can be assumed to fit into the transfer area. We should be able to */
/* add this to the end of a growing block or to use it to start a new block unless the code */
/* that calculates the offset to use (in ced_read_write_mem) is totally duff. */
if ((pArea->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 (ced->StagedOffset ==
if (ced->staged_offset ==
(pArea->blocks[1].offset +
pArea->blocks[1].size)) {
pArea->blocks[1].size +=
ced->StagedLength;
ced->staged_length;
dev_dbg(&ced->interface->dev,
"RWM_Complete, circ block 1 now %d bytes at %d\n",
pArea->blocks[1].size,
......@@ -567,9 +577,9 @@ static void staged_callback(struct urb *pUrb)
} else {
/* Here things have gone very, very, wrong, but I cannot see how this can actually be achieved */
pArea->blocks[1].offset =
ced->StagedOffset;
ced->staged_offset;
pArea->blocks[1].size =
ced->StagedLength;
ced->staged_length;
dev_err(&ced->interface->dev,
"%s: ERROR, circ block 1 re-started %d bytes at %d\n",
__func__,
......@@ -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 */
if (pArea->blocks[0].size > 0) { /* Got stored block 0 information? */
/* Must append onto the existing block 0 */
if (ced->StagedOffset ==
if (ced->staged_offset ==
(pArea->blocks[0].offset +
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,
"RWM_Complete, circ block 0 now %d bytes at %d\n",
pArea->blocks[0].
......@@ -591,9 +601,9 @@ static void staged_callback(struct urb *pUrb)
offset);
} else { /* If it doesn't append, put into new block 1 */
pArea->blocks[1].offset =
ced->StagedOffset;
ced->staged_offset;
pArea->blocks[1].size =
ced->StagedLength;
ced->staged_length;
dev_dbg(&ced->interface->dev,
"RWM_Complete, circ block 1 started %d bytes at %d\n",
pArea->blocks[1].
......@@ -603,9 +613,9 @@ static void staged_callback(struct urb *pUrb)
}
} else { /* No info stored yet, just save in block 0 */
pArea->blocks[0].offset =
ced->StagedOffset;
ced->staged_offset;
pArea->blocks[0].size =
ced->StagedLength;
ced->staged_length;
dev_dbg(&ced->interface->dev,
"RWM_Complete, circ block 0 started %d bytes at %d\n",
pArea->blocks[0].size,
......@@ -620,7 +630,7 @@ static void staged_callback(struct urb *pUrb)
pArea->circular, pArea->event_to_host,
pArea->event_st, pArea->event_sz);
if ((pArea->event_sz) && /* Set a user-mode event... */
(ced->StagedRead == pArea->event_to_host)) { /* ...on transfers in this direction? */
(ced->staged_read == pArea->event_to_host)) { /* ...on transfers in this direction? */
int iWakeUp = 0; /* assume */
/* If we have completed the right sort of DMA */
......@@ -636,11 +646,11 @@ static void staged_callback(struct urb *pUrb)
iWakeUp = (dwTotal >= pArea->event_sz);
} else {
unsigned int transEnd =
ced->StagedOffset +
ced->StagedLength;
ced->staged_offset +
ced->staged_length;
unsigned int eventEnd =
pArea->event_st + pArea->event_sz;
iWakeUp = (ced->StagedOffset < eventEnd)
iWakeUp = (ced->staged_offset < eventEnd)
&& (transEnd > pArea->event_st);
}
......@@ -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 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;
dev_info(&ced->interface->dev,
"*** RWM_Complete *** pending transfer will now be set up!!!\n");
iReturn =
ced_read_write_mem(ced, !ced->rDMAInfo.outward,
ced->rDMAInfo.ident,
ced->rDMAInfo.offset,
ced->rDMAInfo.size);
ced_read_write_mem(ced, !ced->dma_info.outward,
ced->dma_info.ident,
ced->dma_info.offset,
ced->dma_info.size);
if (iReturn)
dev_err(&ced->interface->dev,
......@@ -677,15 +687,15 @@ static void staged_callback(struct urb *pUrb)
} else /* Here for more to do */
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. */
/* This feels wrong as we should ask which spin lock protects dwDMAFlag. */
bRestartCharInput = !bCancel && (ced->dwDMAFlag == MODE_CHAR)
&& !ced->bXFerWaiting;
/* This feels wrong as we should ask which spin lock protects dma_flag. */
bRestartCharInput = !bCancel && (ced->dma_flag == MODE_CHAR) &&
!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 */
/* not be upset by char input during DMA... sigh. Needs sorting out. */
if (bRestartCharInput) /* may be out of date, but... */
......@@ -705,8 +715,8 @@ static int ced_stage_chunk(struct ced_data *ced)
{
int iReturn = U14ERR_NOERROR;
unsigned int ChunkSize;
int nPipe = ced->StagedRead ? 3 : 2; /* The pipe number to use for reads or writes */
if (ced->nPipes == 3)
int nPipe = ced->staged_read ? 3 : 2; /* The pipe number to use for reads or writes */
if (ced->n_pipes == 3)
nPipe--; /* Adjust for the 3-pipe case */
if (nPipe < 0) /* and trap case that should never happen */
return U14ERR_FAIL;
......@@ -717,31 +727,32 @@ static int ced_stage_chunk(struct ced_data *ced)
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 */
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 */
usb_fill_bulk_urb(ced->pStagedUrb, ced->udev,
ced->StagedRead ? usb_rcvbulkpipe(ced->udev,
usb_fill_bulk_urb(ced->staged_urb, ced->udev,
ced->staged_read ? usb_rcvbulkpipe(ced->udev,
ced->
epAddr[nPipe]) :
usb_sndbulkpipe(ced->udev, ced->epAddr[nPipe]),
ced->pCoherStagedIO, ChunkSize, staged_callback, ced);
ced->pStagedUrb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
usb_anchor_urb(ced->pStagedUrb, &ced->submitted); /* in case we need to kill it */
iReturn = usb_submit_urb(ced->pStagedUrb, GFP_ATOMIC);
ep_addr[nPipe]) :
usb_sndbulkpipe(ced->udev, ced->ep_addr[nPipe]),
ced->coher_staged_io, ChunkSize,
staged_callback, ced);
ced->staged_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
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) {
usb_unanchor_urb(ced->pStagedUrb); /* kill it */
ced->bPipeError[nPipe] = 1; /* Flag an error to be handled later */
usb_unanchor_urb(ced->staged_urb); /* kill it */
ced->pipe_error[nPipe] = 1; /* Flag an error to be handled later */
dev_err(&ced->interface->dev, "%s: submit urb failed, code %d\n",
__func__, iReturn);
} 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",
__func__, ced->StagedDone, ChunkSize);
__func__, ced->staged_done, ChunkSize);
return iReturn;
}
......@@ -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
** 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:
** 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,
unsigned int dwOffs, unsigned int dwLen)
{
/* 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? */
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,
/* 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. */
if (ced->bStagedUrbPending) {
ced->bXFerWaiting = true; /* Flag we are waiting */
if (ced->staged_urb_pending) {
ced->xfer_waiting = true; /* Flag we are waiting */
dev_info(&ced->interface->dev,
"%s: xfer is waiting, as previous staged pending\n",
__func__);
......@@ -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? */
ced->bXFerWaiting = true; /* Flag we are waiting */
ced->xfer_waiting = true; /* Flag we are waiting */
dev_dbg(&ced->interface->dev,
"%s: xfer waiting for circular buffer space\n",
__func__);
......@@ -835,13 +846,13 @@ int ced_read_write_mem(struct ced_data *ced, bool Read, unsigned short wIdent,
__func__, dwLen, dwOffs);
}
/* Save the parameters for the read\write transfer */
ced->StagedRead = Read; /* Save the parameters for this read */
ced->StagedId = wIdent; /* ID allows us to get transfer area info */
ced->StagedOffset = dwOffs; /* The area within the transfer area */
ced->StagedLength = dwLen;
ced->StagedDone = 0; /* Initialise the byte count */
ced->dwDMAFlag = MODE_LINEAR; /* Set DMA mode flag at this point */
ced->bXFerWaiting = false; /* Clearly not a transfer waiting now */
ced->staged_read = Read; /* Save the parameters for this read */
ced->staged_id = wIdent; /* ID allows us to get transfer area info */
ced->staged_offset = dwOffs; /* The area within the transfer area */
ced->staged_length = dwLen;
ced->staged_done = 0; /* Initialise the byte count */
ced->dma_flag = MODE_LINEAR; /* Set DMA mode flag at this point */
ced->xfer_waiting = false; /* Clearly not a transfer waiting now */
/* KeClearEvent(&ced->StagingDoneEvent); // Clear the transfer done event */
ced_stage_chunk(ced); /* fire off the first chunk */
......@@ -988,21 +999,21 @@ static bool ced_read_dma_info(volatile struct dmadesc *pDmaDesc,
pDmaDesc->size);
if ((wIdent >= MAX_TRANSAREAS) || /* Illegal area number, or... */
(!ced->rTransDef[wIdent].used) || /* area not set up, or... */
(pDmaDesc->offset > ced->rTransDef[wIdent].length) || /* range/size */
(!ced->trans_def[wIdent].used) || /* area not set up, or... */
(pDmaDesc->offset > ced->trans_def[wIdent].length) || /* range/size */
((pDmaDesc->offset +
pDmaDesc->size) >
(ced->rTransDef[wIdent].
(ced->trans_def[wIdent].
length))) {
bResult = false; /* bad parameter(s) */
dev_dbg(&ced->interface->dev,
"%s: bad param - id %d, bUsed %d, offset %d, size %d, area length %d\n",
__func__, wIdent,
ced->rTransDef[wIdent].
ced->trans_def[wIdent].
used,
pDmaDesc->offset,
pDmaDesc->size,
ced->rTransDef[wIdent].
ced->trans_def[wIdent].
length);
}
}
......@@ -1046,18 +1057,19 @@ static int ced_handle_esc(struct ced_data *ced, char *pCh,
if (pCh[0] == '?') { /* Is this an information response */
/* Parse and save the information */
} 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 */
unsigned short wTransType = ced->rDMAInfo.trans_type; /* check transfer type */
if (ced_read_dma_info(&ced->dma_info, ced, pCh, dwCount)) { /* Get DMA parameters */
unsigned short wTransType = ced->dma_info.trans_type; /* check transfer type */
dev_dbg(&ced->interface->dev,
"%s: xfer to %s, offset %d, length %d\n",
__func__,
ced->rDMAInfo.outward ? "1401" : "host",
ced->rDMAInfo.offset, ced->rDMAInfo.size);
ced->dma_info.outward ? "1401" : "host",
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 */
dev_err(&ced->interface->dev,
"ERROR: DMA setup while transfer still waiting\n");
......@@ -1066,10 +1078,10 @@ static int ced_handle_esc(struct ced_data *ced, char *pCh,
|| (wTransType == TM_EXTTO1401)) {
iReturn =
ced_read_write_mem(ced,
!ced->rDMAInfo.outward,
ced->rDMAInfo.ident,
ced->rDMAInfo.offset,
ced->rDMAInfo.size);
!ced->dma_info.outward,
ced->dma_info.ident,
ced->dma_info.offset,
ced->dma_info.size);
if (iReturn != U14ERR_NOERROR)
dev_err(&ced->interface->dev,
"%s: ced_read_write_mem() failed %d\n",
......@@ -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",
__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);
......@@ -1100,7 +1112,7 @@ static void ced_readchar_callback(struct urb *pUrb)
int nGot = pUrb->actual_length; /* what we transferred */
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 */
if (!
(pUrb->status == -ENOENT || pUrb->status == -ECONNRESET
......@@ -1118,41 +1130,41 @@ static void ced_readchar_callback(struct urb *pUrb)
spin_unlock(&ced->err_lock);
nGot = 0; /* and tidy up again if so */
spin_lock(&ced->charInLock); /* already at irq level */
ced->bPipeError[nPipe] = 1; /* Flag an error for later */
spin_lock(&ced->char_in_lock); /* already at irq level */
ced->pipe_error[nPipe] = 1; /* Flag an error for later */
} else {
if ((nGot > 1) && ((ced->pCoherCharIn[0] & 0x7f) == 0x1b)) { /* Esc sequence? */
ced_handle_esc(ced, &ced->pCoherCharIn[1], nGot - 1); /* handle it */
spin_lock(&ced->charInLock); /* already at irq level */
if ((nGot > 1) && ((ced->coher_char_in[0] & 0x7f) == 0x1b)) { /* Esc sequence? */
ced_handle_esc(ced, &ced->coher_char_in[1], nGot - 1); /* handle it */
spin_lock(&ced->char_in_lock); /* already at irq level */
} else {
spin_lock(&ced->charInLock); /* already at irq level */
spin_lock(&ced->char_in_lock); /* already at irq level */
if (nGot > 0) {
unsigned int i;
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,
"%s: got %d chars >%s<\n",
__func__, nGot,
ced->pCoherCharIn);
ced->coher_char_in);
}
/* We know that whatever we read must fit in the input buffer */
for (i = 0; i < nGot; i++) {
ced->inputBuffer[ced->dwInBuffPut++] =
ced->pCoherCharIn[i] & 0x7F;
if (ced->dwInBuffPut >= INBUF_SZ)
ced->dwInBuffPut = 0;
ced->input_buffer[ced->in_buff_put++] =
ced->coher_char_in[i] & 0x7F;
if (ced->in_buff_put >= INBUF_SZ)
ced->in_buff_put = 0;
}
if ((ced->dwNumInput + nGot) <= INBUF_SZ)
ced->dwNumInput += nGot; /* Adjust the buffer count accordingly */
if ((ced->num_input + nGot) <= INBUF_SZ)
ced->num_input += nGot; /* Adjust the buffer count accordingly */
} else
dev_dbg(&ced->interface->dev, "%s: read ZLP\n",
__func__);
}
}
ced->bReadCharsPending = false; /* No longer have a pending read */
spin_unlock(&ced->charInLock); /* already at irq level */
ced->read_chars_pending = false; /* No longer have a pending read */
spin_unlock(&ced->char_in_lock); /* already at irq level */
ced_allowi(ced); /* see if we can do the next one */
}
......@@ -1168,43 +1180,50 @@ int ced_allowi(struct ced_data *ced)
{
int iReturn = U14ERR_NOERROR;
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 */
/* 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 */
/* is no actual driver failure, so we don't allow this at all. */
if (!ced->bInDrawDown && /* stop input if */
!ced->bReadCharsPending && /* If no read request outstanding */
(ced->dwNumInput < (INBUF_SZ / 2)) && /* and there is some space */
(ced->dwDMAFlag == MODE_CHAR) && /* not doing any DMA */
(!ced->bXFerWaiting) && /* no xfer waiting to start */
if (!ced->in_draw_down && /* stop input if */
!ced->read_chars_pending && /* If no read request outstanding */
(ced->num_input < (INBUF_SZ / 2)) && /* and there is some space */
(ced->dma_flag == MODE_CHAR) && /* not doing any DMA */
(!ced->xfer_waiting) && /* no xfer waiting to start */
(can_accept_io_requests(ced))) { /* and activity is generally OK */
/* then off we go */
unsigned int nMax = INBUF_SZ - ced->dwNumInput; /* max we could read */
int nPipe = ced->nPipes == 4 ? 1 : 0; /* The pipe number to use */
unsigned int nMax = INBUF_SZ - ced->num_input; /* max we could read */
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",
__func__, ced->dwNumInput);
usb_fill_int_urb(ced->pUrbCharIn, ced->udev,
usb_rcvintpipe(ced->udev, ced->epAddr[nPipe]),
ced->pCoherCharIn, nMax, ced_readchar_callback,
ced, ced->bInterval);
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 */
iReturn = usb_submit_urb(ced->pUrbCharIn, GFP_ATOMIC);
__func__, ced->num_input);
usb_fill_int_urb(ced->urb_char_in, ced->udev,
usb_rcvintpipe(ced->udev, ced->ep_addr[nPipe]),
ced->coher_char_in, nMax, ced_readchar_callback,
ced, ced->interval);
/* short xfers are OK by default */
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) {
usb_unanchor_urb(ced->pUrbCharIn); /* remove from list of active Urbs */
ced->bPipeError[nPipe] = 1; /* Flag an error to be handled later */
usb_unanchor_urb(ced->urb_char_in); /* remove from list of active Urbs */
ced->pipe_error[nPipe] = 1; /* Flag an error to be handled later */
dev_err(&ced->interface->dev,
"%s: submit urb failed: %d\n",
__func__, iReturn);
} 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;
......@@ -1318,7 +1337,7 @@ static long ced_ioctl(struct file *file, unsigned int cmd, unsigned long ulArg)
return ced_dbg_stop_loop(ced);
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;
case _IOC_NR(IOCTL_CED_SETCIRCULAR):
......@@ -1378,14 +1397,14 @@ static int ced_probe(struct usb_interface *interface,
goto error;
for (i = 0; i < MAX_TRANSAREAS; ++i) { /* Initialise the wait queues */
init_waitqueue_head(&ced->rTransDef[i].event);
init_waitqueue_head(&ced->trans_def[i].event);
}
/* Put initialises for our stuff here. Note that all of *ced is zero, so */
/* no need to explicitly zero it. */
spin_lock_init(&ced->charOutLock);
spin_lock_init(&ced->charInLock);
spin_lock_init(&ced->stagedLock);
spin_lock_init(&ced->char_out_lock);
spin_lock_init(&ced->char_in_lock);
spin_lock_init(&ced->staged_lock);
/* Initialises from the skeleton stuff */
kref_init(&ced->kref);
......@@ -1400,9 +1419,9 @@ static int ced_probe(struct usb_interface *interface,
bcdDevice = ced->udev->descriptor.bcdDevice;
i = (bcdDevice >> 8);
if (i == 0)
ced->s1401Type = TYPEU1401;
ced->type = TYPEU1401;
else if ((i >= 1) && (i <= 23))
ced->s1401Type = i + 2;
ced->type = i + 2;
else {
dev_err(&interface->dev, "%s: Unknown device. bcdDevice = %d\n",
__func__, bcdDevice);
......@@ -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 */
/* we know that we are dealing with a 1401 device. */
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",
ced->s1401Type, ced->nPipes);
if ((ced->nPipes < 3) || (ced->nPipes > 4))
ced->type, ced->n_pipes);
if ((ced->n_pipes < 3) || (ced->n_pipes > 4))
goto error;
/* Allocate the URBs we hold for performing transfers */
ced->pUrbCharOut = usb_alloc_urb(0, GFP_KERNEL); /* character output URB */
ced->pUrbCharIn = usb_alloc_urb(0, GFP_KERNEL); /* character input URB */
ced->pStagedUrb = usb_alloc_urb(0, GFP_KERNEL); /* block transfer URB */
if (!ced->pUrbCharOut || !ced->pUrbCharIn || !ced->pStagedUrb) {
ced->urb_char_out = usb_alloc_urb(0, GFP_KERNEL); /* character output URB */
ced->urb_char_in = usb_alloc_urb(0, GFP_KERNEL); /* character input URB */
ced->staged_urb = usb_alloc_urb(0, GFP_KERNEL); /* block transfer URB */
if (!ced->urb_char_out || !ced->urb_char_in || !ced->staged_urb) {
dev_err(&interface->dev, "%s: URB alloc failed\n", __func__);
goto error;
}
ced->pCoherStagedIO =
ced->coher_staged_io =
usb_alloc_coherent(ced->udev, STAGED_SZ, GFP_KERNEL,
&ced->pStagedUrb->transfer_dma);
ced->pCoherCharOut =
&ced->staged_urb->transfer_dma);
ced->coher_char_out =
usb_alloc_coherent(ced->udev, OUTBUF_SZ, GFP_KERNEL,
&ced->pUrbCharOut->transfer_dma);
ced->pCoherCharIn =
&ced->urb_char_out->transfer_dma);
ced->coher_char_in =
usb_alloc_coherent(ced->udev, INBUF_SZ, GFP_KERNEL,
&ced->pUrbCharIn->transfer_dma);
if (!ced->pCoherCharOut || !ced->pCoherCharIn || !ced->pCoherStagedIO) {
&ced->urb_char_in->transfer_dma);
if (!ced->coher_char_out || !ced->coher_char_in ||
!ced->coher_staged_io) {
dev_err(&interface->dev, "%s: Coherent buffer alloc failed\n",
__func__);
goto error;
}
for (i = 0; i < ced->nPipes; ++i) {
for (i = 0; i < ced->n_pipes; ++i) {
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",
i, ced->epAddr[i]);
if (((ced->nPipes == 3) && (i == 0)) || /* if char input end point */
((ced->nPipes == 4) && (i == 1))) {
ced->bInterval = endpoint->bInterval; /* save the endpoint interrupt interval */
dev_info(&interface->dev, "Pipe %d, bInterval = %d\n",
i, ced->bInterval);
i, ced->ep_addr[i]);
if (((ced->n_pipes == 3) && (i == 0)) || /* if char input end point */
((ced->n_pipes == 4) && (i == 1))) {
/* save the endpoint interrupt interval */
ced->interval = endpoint->bInterval;
dev_info(&interface->dev, "Pipe %d, interval = %d\n",
i, ced->interval);
}
/* Detect USB2 by checking last ep size (64 if USB1) */
if (i == ced->nPipes - 1) { /* if this is the last ep (bulk) */
ced->bIsUSB2 =
if (i == ced->n_pipes - 1) { /* if this is the last ep (bulk) */
ced->is_usb2 =
le16_to_cpu(endpoint->wMaxPacketSize) > 64;
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)
int time;
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);
if (!time) { /* if we timed out we kill the urbs */
usb_kill_anchored_urbs(&ced->submitted);
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)
......
......@@ -140,61 +140,63 @@ struct dmadesc {
#define OUTBUF_SZ 256 /* output buffer size */
#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 */
/* can to the Windows driver to help in our understanding of what is going on. */
/* Structure to hold all of our device specific stuff. We are making this as */
/* similar as we can to the Windows driver to help in our understanding of */
/* what is going on. */
struct ced_data {
char inputBuffer[INBUF_SZ]; /* The two buffers */
char outputBuffer[OUTBUF_SZ]; /* accessed by the host functions */
volatile unsigned int dwNumInput; /* num of chars in input buffer */
volatile unsigned int dwInBuffGet; /* where to get from input buffer */
volatile unsigned int dwInBuffPut; /* where to put into input buffer */
volatile unsigned int dwNumOutput; /* num of chars in output buffer */
volatile unsigned int dwOutBuffGet; /* where to get from output buffer*/
volatile unsigned int dwOutBuffPut; /* where to put into output buffer*/
volatile bool bSendCharsPending; /* Flag to indicate sendchar active */
volatile bool bReadCharsPending; /* Flag to indicate a read is primed */
char *pCoherCharOut; /* special aligned buffer for chars to 1401 */
struct urb *pUrbCharOut; /* urb used for chars to 1401 */
char *pCoherCharIn; /* special aligned buffer for chars to host */
struct urb *pUrbCharIn; /* urb used for chars to host */
spinlock_t charOutLock; /* to protect the outputBuffer and outputting */
spinlock_t charInLock; /* to protect the inputBuffer and char reads */
__u8 bInterval; /* Interrupt end point interval */
volatile unsigned int dwDMAFlag; /* state of DMA */
struct transarea rTransDef[MAX_TRANSAREAS]; /* transfer area info */
volatile struct dmadesc rDMAInfo; /* info on current DMA transfer */
volatile bool bXFerWaiting; /* Flag set if DMA transfer stalled */
volatile bool bInDrawDown; /* Flag that we want to halt transfers */
char input_buffer[INBUF_SZ]; /* The two buffers */
char output_buffer[OUTBUF_SZ]; /* accessed by the host functions */
volatile unsigned int num_input; /* num of chars in input buffer */
volatile unsigned int in_buff_get; /* where to get from input buffer */
volatile unsigned int in_buff_put; /* where to put into input buffer */
volatile unsigned int num_output; /* num of chars in output buffer */
volatile unsigned int out_buff_get; /* where to get from output buffer*/
volatile unsigned int out_buff_put; /* where to put into output buffer*/
volatile bool send_chars_pending; /* Flag to indicate sendchar active */
volatile bool read_chars_pending; /* Flag to indicate a read is primed*/
char *coher_char_out; /* special aligned buffer for chars to 1401 */
struct urb *urb_char_out; /* urb used for chars to 1401 */
char *coher_char_in; /* special aligned buffer for chars to host */
struct urb *urb_char_in; /* urb used for chars to host */
spinlock_t char_out_lock; /* protect the output_buffer and outputting */
spinlock_t char_in_lock; /* protect the input_buffer and char reads */
__u8 interval; /* Interrupt end point interval */
volatile unsigned int dma_flag; /* state of DMA */
struct transarea trans_def[MAX_TRANSAREAS]; /* transfer area info */
volatile struct dmadesc dma_info; /* info on current DMA transfer */
volatile bool xfer_waiting; /* Flag set if DMA transfer stalled */
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 */
/* are equivalent to values in rDMAInfo. The values here are those in use, while those */
/* in rDMAInfo 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 */
/* are equivalent to values in dma_info. The values here are those in use, while those */
/* in dma_info are those received from the 1401 via an escape sequence. If another */
/* escape sequence arrives before the previous xfer ends, dma_info values are updated while these */
/* are used to finish off the current transfer. */
volatile short StagedId; /* The transfer area id for this transfer */
volatile bool StagedRead; /* Flag TRUE for read from 1401, FALSE for write */
volatile unsigned int StagedLength; /* Total length of this transfer */
volatile unsigned int StagedOffset; /* Offset within memory area for transfer start */
volatile unsigned int StagedDone; /* Bytes transferred so far */
volatile bool bStagedUrbPending; /* Flag to indicate active */
char *pCoherStagedIO; /* buffer used for block transfers */
struct urb *pStagedUrb; /* The URB to use */
spinlock_t stagedLock; /* protects ReadWriteMem() and circular buffer stuff */
short s1401Type; /* type of 1401 attached */
short sCurrentState; /* current error state */
bool bIsUSB2; /* type of the interface we connect to */
bool bForceReset; /* Flag to make sure we get a real reset */
__u32 statBuf[2]; /* buffer for 1401 state info */
unsigned long ulSelfTestTime; /* 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 */
__u8 epAddr[4]; /* addresses of the 3/4 end points */
volatile short staged_id; /* The transfer area id for this transfer */
volatile bool staged_read; /* Flag TRUE for read from 1401, FALSE for write */
volatile unsigned int staged_length; /* Total length of this transfer */
volatile unsigned int staged_offset; /* Offset within memory area for transfer start */
volatile unsigned int staged_done; /* Bytes transferred so far */
volatile bool staged_urb_pending; /* Flag to indicate active */
char *coher_staged_io; /* buffer used for block transfers */
struct urb *staged_urb; /* The URB to use */
spinlock_t staged_lock; /* protects ReadWriteMem() and */
/* circular buffer stuff */
short type; /* type of 1401 attached */
short current_state; /* current error state */
bool is_usb2; /* type of the interface we connect to */
bool force_reset; /* Flag to make sure we get a real reset */
__u32 stat_buf[2]; /* buffer for 1401 state info */
unsigned long self_test_time; /* used to timeout self test */
int n_pipes; /* Should be 3 or 4 depending on 1401 usb chip */
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_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