20 #include <linux/kernel.h>
21 #include <linux/errno.h>
23 #include <linux/slab.h>
24 #include <linux/module.h>
87 for (u = 0; u < uCount; u++) {
123 iReturn = PutChars(pdx, buffer, n);
141 iReturn = PutChars(pdx, &c, 1);
183 if (nGot !=
sizeof(pdx->
statBuf)) {
185 "Get1401State() FAILED, return code %d", nGot);
192 "Get1401State() Success, state: 0x%x, 0x%x",
198 nDevice = pdx->
udev->descriptor.bcdDevice >> 8;
206 if ((nDevice >= 1) && (nDevice <= 23))
226 #ifdef NOT_WRITTEN_YET
228 bool bResult =
false;
236 "ReadWrite_Cancel about to cancel Urb");
239 USB_ASSERT(pdx->pStagedIrp !=
NULL);
244 bResult = IoCancelIrp(pdx->pStagedIrp);
247 timeout.QuadPart = -10000000;
249 "ReadWrite_Cancel about to wait till done");
251 KeWaitForSingleObject(&pdx->StagingDoneEvent,
252 Executive, KernelMode,
FALSE,
256 "ReadWrite_Cancel, cancellation failed");
259 USB_KdPrint(DBGLVL_DEFAULT,
260 (
"ReadWrite_Cancel ntStatus = 0x%x decimal %d\n",
261 ntStatus, ntStatus));
282 iReturn = (state == (
unsigned int)-1) ||
283 ((state & 0xff) == 0x80);
325 usb_unlock_device(pdx->
udev);
333 iReturn = InSelfTest(pdx, &state);
336 unsigned long ulTimeOut =
jiffies + 30 *
HZ;
339 iReturn = InSelfTest(pdx, &state);
344 iReturn = state == 0;
376 "%s DMAFlag:%d, state:%d, force:%d, testBuff:%d, short:%d",
378 bTestBuff, bShortTest);
385 "%s will reset as buffers not empty", __func__);
388 if (bShortTest || !bCanReset)
394 if ((state & 0xFF) == 0)
399 if (!bRet && bCanReset)
497 buffer[nGot++] = cData;
499 while ((nGot < nAvailable) && cData);
504 buffer[nGot] = (
char)0;
513 "GetString read %d characters >%s<", nGot, buffer);
568 while (dwIndex != dwEnd);
615 struct page **pPages = 0;
626 "%s call on area %d while active",
654 for (np = 0; np < nPages; ++np) {
656 SetPageDirty(pPages[np]);
663 "%s kfree(pPages) done", __func__);
678 unsigned int dwLength,
bool bCircular,
bool bCircToHost)
684 unsigned int ulOffset = ((
unsigned long)puBuf) & (
PAGE_SIZE - 1);
688 struct page **pPages = 0;
707 __func__, puBuf, dwLength, bCircular);
845 msTimeOut = (msTimeOut *
HZ + 999) / 1000;
908 unsigned int dwIdent;
917 memset(&tx, 0,
sizeof(tx));
922 tx.entries[0].physical =
924 tx.entries[0].size = tx.size;
1016 memset(&gst, 0,
sizeof(gst));
1028 "%s Get1401State=%d, assuming still testing", __func__,
1035 if ((state == -1) && (error == -1))
1038 "%s Get1401State failed, assuming still testing",
1044 if ((state & 0xFF) == 0x80)
1046 if (state & 0x00FF0000)
1048 gst.
code = (state & 0x00FF0000) >> 16;
1049 gst.
x = error & 0x0000FFFF;
1050 gst.
y = (error & 0xFFFF0000) >> 16;
1055 unsigned long ulNow =
jiffies;
1059 "Self-test timed-out");
1062 "Self-test on-going");
1175 iReturn = DbgCmd1401(pdx,
DB_PEEK, 0);
1237 iReturn = DbgCmd1401(pdx,
DB_RAMPD, 0);
1267 iReturn = DbgCmd1401(pdx,
DB_RAMPA, 0);
1282 memset(&db, 0,
sizeof(db));
1291 if (iReturn ==
sizeof(db.
iData)) {
1314 unsigned int uState, uErr;
1344 bToHost = td.
eSize != 0;
1392 "%s return block 0: %d bytes at %d",
1417 unsigned int nArea, uStart, uSize;
1441 bool bWaiting =
false;
1460 "%s free %d bytes at %d, return %d bytes at %d, wait=%d",
1461 __func__, uSize, uStart,
1477 "%s ERROR: waiting xfer and staged Urb pending!",
1483 "%s ERROR: freeing %d bytes at %d, block 0 is %d bytes at %d",
1484 __func__, uSize, uStart,
1500 "%s rw setup failed %d",