]>
Commit | Line | Data |
---|---|---|
126bb03b AC |
1 | #include <linux/sched.h> |
2 | #include <linux/errno.h> | |
3 | #include <linux/slab.h> | |
4 | ||
5 | #include <scsi/scsi.h> | |
6 | #include <scsi/scsi_eh.h> | |
7 | #include <scsi/scsi_device.h> | |
8 | ||
9 | #include "usb.h" | |
10 | #include "scsiglue.h" | |
11 | #include "transport.h" | |
12 | #include "init.h" | |
13 | ||
14 | BYTE IsSSFDCCompliance; | |
15 | BYTE IsXDCompliance; | |
16 | extern DWORD MediaChange; | |
17 | extern int Check_D_MediaFmt(struct us_data *); | |
18 | ||
19 | //----- ENE_InitMedia() ---------------------------------------- | |
20 | int ENE_InitMedia(struct us_data *us) | |
21 | { | |
22 | int result; | |
23 | BYTE MiscReg03 = 0; | |
24 | ||
307ae1d3 | 25 | printk("--- Init Media ---\n"); |
126bb03b AC |
26 | result = ENE_Read_BYTE(us, REG_CARD_STATUS, &MiscReg03); |
27 | if (result != USB_STOR_XFER_GOOD) | |
28 | { | |
29 | printk("Read register fail !!\n"); | |
30 | return USB_STOR_TRANSPORT_ERROR; | |
31 | } | |
32 | printk("MiscReg03 = %x\n", MiscReg03); | |
33 | ||
34 | if (MiscReg03 & 0x01) | |
35 | { | |
36 | if (!us->SD_Status.Ready) | |
37 | { | |
38 | result = ENE_SDInit(us); | |
39 | if (result != USB_STOR_XFER_GOOD) | |
40 | return USB_STOR_TRANSPORT_ERROR; | |
41 | } | |
42 | } | |
43 | ||
44 | if (MiscReg03 & 0x02) | |
45 | { | |
46 | if (!us->SM_Status.Ready && !us->MS_Status.Ready) | |
47 | { | |
48 | result = ENE_SMInit(us); | |
49 | if (result != USB_STOR_XFER_GOOD) | |
50 | { | |
51 | result = ENE_MSInit(us); | |
52 | if (result != USB_STOR_XFER_GOOD) | |
53 | return USB_STOR_TRANSPORT_ERROR; | |
54 | } | |
55 | } | |
56 | ||
57 | } | |
58 | return result; | |
59 | } | |
60 | ||
61 | //----- ENE_Read_BYTE() ---------------------------------------- | |
62 | int ENE_Read_BYTE(struct us_data *us, WORD index, void *buf) | |
63 | { | |
64 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; | |
65 | int result; | |
66 | ||
307ae1d3 | 67 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
126bb03b AC |
68 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
69 | bcb->DataTransferLength = 0x01; | |
70 | bcb->Flags = 0x80; | |
71 | bcb->CDB[0] = 0xED; | |
72 | bcb->CDB[2] = (BYTE)(index>>8); | |
73 | bcb->CDB[3] = (BYTE)index; | |
74 | ||
75 | result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0); | |
76 | return result; | |
77 | } | |
78 | ||
79 | //----- ENE_SDInit() --------------------- | |
80 | int ENE_SDInit(struct us_data *us) | |
81 | { | |
82 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; | |
83 | int result; | |
84 | BYTE buf[0x200]; | |
85 | ||
86 | printk("transport --- ENE_SDInit\n"); | |
87 | // SD Init Part-1 | |
88 | result = ENE_LoadBinCode(us, SD_INIT1_PATTERN); | |
89 | if (result != USB_STOR_XFER_GOOD) | |
90 | { | |
91 | printk("Load SD Init Code Part-1 Fail !!\n"); | |
92 | return USB_STOR_TRANSPORT_ERROR; | |
93 | } | |
94 | ||
307ae1d3 | 95 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
126bb03b AC |
96 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
97 | bcb->Flags = 0x80; | |
98 | bcb->CDB[0] = 0xF2; | |
99 | ||
100 | result = ENE_SendScsiCmd(us, FDIR_READ, NULL, 0); | |
101 | if (result != USB_STOR_XFER_GOOD) | |
102 | { | |
103 | printk("Exection SD Init Code Fail !!\n"); | |
104 | return USB_STOR_TRANSPORT_ERROR; | |
105 | } | |
106 | ||
107 | // SD Init Part-2 | |
108 | result = ENE_LoadBinCode(us, SD_INIT2_PATTERN); | |
109 | if (result != USB_STOR_XFER_GOOD) | |
110 | { | |
111 | printk("Load SD Init Code Part-2 Fail !!\n"); | |
112 | return USB_STOR_TRANSPORT_ERROR; | |
113 | } | |
114 | ||
307ae1d3 | 115 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
126bb03b AC |
116 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
117 | bcb->DataTransferLength = 0x200; | |
118 | bcb->Flags = 0x80; | |
119 | bcb->CDB[0] = 0xF1; | |
120 | ||
121 | result = ENE_SendScsiCmd(us, FDIR_READ, &buf, 0); | |
122 | if (result != USB_STOR_XFER_GOOD) | |
123 | { | |
124 | printk("Exection SD Init Code Fail !!\n"); | |
125 | return USB_STOR_TRANSPORT_ERROR; | |
126 | } | |
127 | ||
128 | us->SD_Status = *(PSD_STATUS)&buf[0]; | |
129 | if (us->SD_Status.Insert && us->SD_Status.Ready) | |
130 | { | |
131 | ENE_ReadSDReg(us, (PBYTE)&buf); | |
132 | printk("Insert = %x\n", us->SD_Status.Insert); | |
133 | printk("Ready = %x\n", us->SD_Status.Ready); | |
134 | printk("IsMMC = %x\n", us->SD_Status.IsMMC); | |
135 | printk("HiCapacity = %x\n", us->SD_Status.HiCapacity); | |
136 | printk("HiSpeed = %x\n", us->SD_Status.HiSpeed); | |
137 | printk("WtP = %x\n", us->SD_Status.WtP); | |
138 | } | |
139 | else | |
140 | { | |
141 | printk("SD Card Not Ready --- %x\n", buf[0]); | |
142 | return USB_STOR_TRANSPORT_ERROR; | |
143 | } | |
144 | return USB_STOR_TRANSPORT_GOOD; | |
145 | } | |
146 | ||
147 | //----- ENE_MSInit() ---------------------------------------- | |
148 | int ENE_MSInit(struct us_data *us) | |
149 | { | |
150 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; | |
151 | int result; | |
152 | BYTE buf[0x200]; | |
153 | WORD MSP_BlockSize, MSP_UserAreaBlocks; | |
154 | ||
155 | ||
156 | printk("transport --- ENE_MSInit\n"); | |
157 | result = ENE_LoadBinCode(us, MS_INIT_PATTERN); | |
158 | if (result != USB_STOR_XFER_GOOD) | |
159 | { | |
160 | printk("Load MS Init Code Fail !!\n"); | |
161 | return USB_STOR_TRANSPORT_ERROR; | |
162 | } | |
163 | ||
307ae1d3 | 164 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
126bb03b AC |
165 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
166 | bcb->DataTransferLength = 0x200; | |
167 | bcb->Flags = 0x80; | |
168 | bcb->CDB[0] = 0xF1; | |
169 | bcb->CDB[1] = 0x01; | |
170 | ||
171 | result = ENE_SendScsiCmd(us, FDIR_READ, &buf, 0); | |
172 | if (result != USB_STOR_XFER_GOOD) | |
173 | { | |
174 | printk("Exection MS Init Code Fail !!\n"); | |
175 | return USB_STOR_TRANSPORT_ERROR; | |
176 | } | |
177 | ||
178 | us->MS_Status = *(PMS_STATUS)&buf[0]; | |
179 | ||
180 | if (us->MS_Status.Insert && us->MS_Status.Ready) | |
181 | { | |
182 | printk("Insert = %x\n", us->MS_Status.Insert); | |
183 | printk("Ready = %x\n", us->MS_Status.Ready); | |
184 | printk("IsMSPro = %x\n", us->MS_Status.IsMSPro); | |
185 | printk("IsMSPHG = %x\n", us->MS_Status.IsMSPHG); | |
186 | printk("WtP = %x\n", us->MS_Status.WtP); | |
187 | if (us->MS_Status.IsMSPro) | |
188 | { | |
189 | MSP_BlockSize = (buf[6] <<8) | buf[7]; | |
190 | MSP_UserAreaBlocks = (buf[10]<<8) | buf[11]; | |
191 | us->MSP_TotalBlock = MSP_BlockSize * MSP_UserAreaBlocks; | |
192 | } | |
193 | else | |
194 | MS_CardInit(us); | |
195 | printk("MS Init Code OK !!\n"); | |
196 | } | |
197 | else | |
198 | { | |
199 | printk("MS Card Not Ready --- %x\n", buf[0]); | |
200 | return USB_STOR_TRANSPORT_ERROR; | |
201 | } | |
202 | ||
203 | return USB_STOR_TRANSPORT_GOOD; | |
204 | } | |
205 | ||
206 | //----- ENE_SMInit() ---------------------------------------- | |
207 | int ENE_SMInit(struct us_data *us) | |
208 | { | |
209 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; | |
210 | int result; | |
211 | BYTE buf[0x200]; | |
212 | ||
213 | printk("transport --- ENE_SMInit\n"); | |
214 | ||
215 | result = ENE_LoadBinCode(us, SM_INIT_PATTERN); | |
216 | if (result != USB_STOR_XFER_GOOD) | |
217 | { | |
218 | printk("Load SM Init Code Fail !!\n"); | |
219 | return USB_STOR_TRANSPORT_ERROR; | |
220 | } | |
221 | ||
307ae1d3 | 222 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
126bb03b AC |
223 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
224 | bcb->DataTransferLength = 0x200; | |
225 | bcb->Flags = 0x80; | |
226 | bcb->CDB[0] = 0xF1; | |
227 | bcb->CDB[1] = 0x01; | |
228 | ||
229 | result = ENE_SendScsiCmd(us, FDIR_READ, &buf, 0); | |
230 | if (result != USB_STOR_XFER_GOOD) | |
231 | { | |
232 | printk("Exection SM Init Code Fail !! result = %x\n", result); | |
233 | return USB_STOR_TRANSPORT_ERROR; | |
234 | } | |
235 | ||
236 | us->SM_Status = *(PSM_STATUS)&buf[0]; | |
237 | ||
238 | us->SM_DeviceID = buf[1]; | |
239 | us->SM_CardID = buf[2]; | |
240 | ||
241 | if (us->SM_Status.Insert && us->SM_Status.Ready) | |
242 | { | |
243 | printk("Insert = %x\n", us->SM_Status.Insert); | |
244 | printk("Ready = %x\n", us->SM_Status.Ready); | |
245 | printk("WtP = %x\n", us->SM_Status.WtP); | |
246 | printk("DeviceID = %x\n", us->SM_DeviceID); | |
247 | printk("CardID = %x\n", us->SM_CardID); | |
248 | MediaChange = 1; | |
249 | Check_D_MediaFmt(us); | |
250 | } | |
251 | else | |
252 | { | |
253 | printk("SM Card Not Ready --- %x\n", buf[0]); | |
254 | return USB_STOR_TRANSPORT_ERROR; | |
255 | } | |
256 | ||
257 | return USB_STOR_TRANSPORT_GOOD; | |
258 | } | |
259 | ||
260 | //----- ENE_ReadSDReg() ---------------------------------------------- | |
261 | int ENE_ReadSDReg(struct us_data *us, u8 *RdBuf) | |
262 | { | |
263 | WORD tmpreg; | |
264 | DWORD reg4b; | |
265 | ||
266 | //printk("transport --- ENE_ReadSDReg\n"); | |
267 | reg4b = *(PDWORD)&RdBuf[0x18]; | |
268 | us->SD_READ_BL_LEN = (BYTE)((reg4b >> 8) & 0x0f); | |
269 | ||
270 | tmpreg = (WORD) reg4b; | |
271 | reg4b = *(PDWORD)(&RdBuf[0x14]); | |
272 | if (us->SD_Status.HiCapacity && !us->SD_Status.IsMMC) | |
273 | us->HC_C_SIZE = (reg4b >> 8) & 0x3fffff; | |
274 | ||
275 | us->SD_C_SIZE = ((tmpreg & 0x03) << 10) | (WORD)(reg4b >> 22); | |
276 | us->SD_C_SIZE_MULT = (BYTE)(reg4b >> 7) & 0x07; | |
277 | if (us->SD_Status.HiCapacity && us->SD_Status.IsMMC) | |
278 | us->HC_C_SIZE = *(PDWORD)(&RdBuf[0x100]); | |
279 | ||
280 | if (us->SD_READ_BL_LEN > SD_BLOCK_LEN) | |
281 | { | |
282 | us->SD_Block_Mult = 1 << (us->SD_READ_BL_LEN - SD_BLOCK_LEN); us->SD_READ_BL_LEN = SD_BLOCK_LEN; | |
283 | } | |
284 | else | |
285 | { us->SD_Block_Mult = 1; | |
286 | } | |
287 | return USB_STOR_TRANSPORT_GOOD; | |
288 | } | |
289 | ||
290 | //----- ENE_LoadBinCode() --------------------- | |
291 | int ENE_LoadBinCode(struct us_data *us, BYTE flag) | |
292 | { | |
293 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; | |
294 | int result; | |
295 | //void *buf; | |
296 | PBYTE buf; | |
297 | ||
298 | //printk("transport --- ENE_LoadBinCode\n"); | |
299 | if (us->BIN_FLAG == flag) | |
300 | return USB_STOR_TRANSPORT_GOOD; | |
301 | ||
302 | buf = kmalloc(0x800, GFP_KERNEL); | |
b1f5f54e VK |
303 | if (buf == NULL) |
304 | return USB_STOR_TRANSPORT_ERROR; | |
126bb03b AC |
305 | switch ( flag ) |
306 | { | |
307 | // For SD | |
308 | case SD_INIT1_PATTERN: | |
309 | printk("SD_INIT1_PATTERN\n"); | |
310 | memcpy(buf, SD_Init1, 0x800); | |
311 | break; | |
312 | case SD_INIT2_PATTERN: | |
313 | printk("SD_INIT2_PATTERN\n"); | |
314 | memcpy(buf, SD_Init2, 0x800); | |
315 | break; | |
316 | case SD_RW_PATTERN: | |
317 | printk("SD_RW_PATTERN\n"); | |
318 | memcpy(buf, SD_Rdwr, 0x800); | |
319 | break; | |
320 | // For MS | |
321 | case MS_INIT_PATTERN: | |
322 | printk("MS_INIT_PATTERN\n"); | |
323 | memcpy(buf, MS_Init, 0x800); | |
324 | break; | |
325 | case MSP_RW_PATTERN: | |
326 | printk("MSP_RW_PATTERN\n"); | |
327 | memcpy(buf, MSP_Rdwr, 0x800); | |
328 | break; | |
329 | case MS_RW_PATTERN: | |
330 | printk("MS_RW_PATTERN\n"); | |
331 | memcpy(buf, MS_Rdwr, 0x800); | |
332 | break; | |
333 | // For SS | |
334 | case SM_INIT_PATTERN: | |
335 | printk("SM_INIT_PATTERN\n"); | |
336 | memcpy(buf, SM_Init, 0x800); | |
337 | break; | |
338 | case SM_RW_PATTERN: | |
339 | printk("SM_RW_PATTERN\n"); | |
340 | memcpy(buf, SM_Rdwr, 0x800); | |
341 | break; | |
342 | } | |
343 | ||
307ae1d3 | 344 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
126bb03b AC |
345 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
346 | bcb->DataTransferLength = 0x800; | |
347 | bcb->Flags =0x00; | |
348 | bcb->CDB[0] = 0xEF; | |
349 | ||
350 | result = ENE_SendScsiCmd(us, FDIR_WRITE, buf, 0); | |
351 | ||
352 | kfree(buf); | |
353 | us->BIN_FLAG = flag; | |
354 | return result; | |
355 | } | |
356 | ||
357 | //----- ENE_SendScsiCmd() --------------------- | |
358 | int ENE_SendScsiCmd(struct us_data *us, BYTE fDir, void *buf, int use_sg) | |
359 | { | |
360 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; | |
361 | struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf; | |
362 | ||
363 | int result; | |
364 | unsigned int transfer_length=bcb->DataTransferLength, cswlen=0, partial=0; | |
365 | unsigned int residue; | |
366 | ||
367 | //printk("transport --- ENE_SendScsiCmd\n"); | |
368 | // send cmd to out endpoint | |
369 | result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb, US_BULK_CB_WRAP_LEN, NULL); | |
370 | if (result != USB_STOR_XFER_GOOD) | |
371 | { | |
372 | printk("send cmd to out endpoint fail ---\n"); | |
373 | return USB_STOR_TRANSPORT_ERROR; | |
374 | } | |
375 | ||
376 | if (buf) | |
377 | { | |
378 | unsigned int pipe = fDir == FDIR_READ ? us->recv_bulk_pipe : us->send_bulk_pipe; | |
379 | // Bulk | |
380 | if (use_sg) | |
381 | result = usb_stor_bulk_srb(us, pipe, us->srb); | |
382 | else | |
383 | result = usb_stor_bulk_transfer_sg(us, pipe, buf, transfer_length, 0, &partial); | |
384 | if (result != USB_STOR_XFER_GOOD) | |
385 | { | |
386 | printk("data transfer fail ---\n"); | |
387 | return USB_STOR_TRANSPORT_ERROR; | |
388 | } | |
389 | } | |
390 | ||
391 | // Get CSW for device status | |
392 | result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, &cswlen); | |
393 | ||
394 | if (result == USB_STOR_XFER_SHORT && cswlen == 0) | |
395 | { | |
396 | printk("Received 0-length CSW; retrying...\n"); | |
397 | result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, &cswlen); | |
398 | } | |
399 | ||
400 | if (result == USB_STOR_XFER_STALLED) | |
401 | { | |
402 | /* get the status again */ | |
403 | printk("Attempting to get CSW (2nd try)...\n"); | |
404 | result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, NULL); | |
405 | } | |
406 | ||
407 | if (result != USB_STOR_XFER_GOOD) | |
408 | return USB_STOR_TRANSPORT_ERROR; | |
409 | ||
410 | /* check bulk status */ | |
411 | residue = le32_to_cpu(bcs->Residue); | |
412 | ||
413 | /* try to compute the actual residue, based on how much data | |
414 | * was really transferred and what the device tells us */ | |
415 | if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) | |
416 | { | |
417 | residue = min(residue, transfer_length); | |
418 | scsi_set_resid(us->srb, max(scsi_get_resid(us->srb), (int) residue)); | |
419 | } | |
420 | ||
421 | if (bcs->Status != US_BULK_STAT_OK) | |
422 | return USB_STOR_TRANSPORT_ERROR; | |
423 | ||
424 | return USB_STOR_TRANSPORT_GOOD; | |
425 | } | |
426 | ||
427 | //----- ENE_Read_Data() --------------------- | |
428 | int ENE_Read_Data(struct us_data *us, void *buf, unsigned int length) | |
429 | { | |
430 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; | |
431 | struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf; | |
432 | int result; | |
433 | ||
434 | //printk("transport --- ENE_Read_Data\n"); | |
435 | // set up the command wrapper | |
307ae1d3 | 436 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
126bb03b AC |
437 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
438 | bcb->DataTransferLength = length; | |
439 | bcb->Flags =0x80; | |
440 | bcb->CDB[0] = 0xED; | |
441 | bcb->CDB[2] = 0xFF; | |
442 | bcb->CDB[3] = 0x81; | |
443 | ||
444 | // send cmd to out endpoint | |
445 | result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb, US_BULK_CB_WRAP_LEN, NULL); | |
446 | if (result != USB_STOR_XFER_GOOD) | |
447 | return USB_STOR_TRANSPORT_ERROR; | |
448 | ||
449 | // R/W data | |
450 | result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, buf, length, NULL); | |
451 | if (result != USB_STOR_XFER_GOOD) | |
452 | return USB_STOR_TRANSPORT_ERROR; | |
453 | ||
454 | // Get CSW for device status | |
455 | result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, NULL); | |
456 | if (result != USB_STOR_XFER_GOOD) | |
457 | return USB_STOR_TRANSPORT_ERROR; | |
458 | if (bcs->Status != US_BULK_STAT_OK) | |
459 | return USB_STOR_TRANSPORT_ERROR; | |
460 | ||
461 | return USB_STOR_TRANSPORT_GOOD; | |
462 | } | |
463 | ||
464 | //----- ENE_Write_Data() --------------------- | |
465 | int ENE_Write_Data(struct us_data *us, void *buf, unsigned int length) | |
466 | { | |
467 | struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; | |
468 | struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf; | |
469 | int result; | |
470 | ||
471 | //printk("transport --- ENE_Write_Data\n"); | |
472 | // set up the command wrapper | |
307ae1d3 | 473 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
126bb03b AC |
474 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
475 | bcb->DataTransferLength = length; | |
476 | bcb->Flags =0x00; | |
477 | bcb->CDB[0] = 0xEE; | |
478 | bcb->CDB[2] = 0xFF; | |
479 | bcb->CDB[3] = 0x81; | |
480 | ||
481 | // send cmd to out endpoint | |
482 | result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb, US_BULK_CB_WRAP_LEN, NULL); | |
483 | if (result != USB_STOR_XFER_GOOD) | |
484 | return USB_STOR_TRANSPORT_ERROR; | |
485 | ||
486 | // R/W data | |
487 | result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, buf, length, NULL); | |
488 | if (result != USB_STOR_XFER_GOOD) | |
489 | return USB_STOR_TRANSPORT_ERROR; | |
490 | ||
491 | // Get CSW for device status | |
492 | result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, NULL); | |
493 | if (result != USB_STOR_XFER_GOOD) | |
494 | return USB_STOR_TRANSPORT_ERROR; | |
495 | if (bcs->Status != US_BULK_STAT_OK) | |
496 | return USB_STOR_TRANSPORT_ERROR; | |
497 | ||
498 | return USB_STOR_TRANSPORT_GOOD; | |
499 | } | |
500 | ||
501 | //----- usb_stor_print_cmd() --------------------- | |
502 | void usb_stor_print_cmd(struct scsi_cmnd *srb) | |
503 | { | |
504 | PBYTE Cdb = srb->cmnd; | |
505 | DWORD cmd = Cdb[0]; | |
506 | DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) | | |
507 | ((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff); | |
508 | WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff); | |
509 | ||
510 | switch (cmd) { | |
511 | case TEST_UNIT_READY: | |
512 | //printk("scsi cmd %X --- SCSIOP_TEST_UNIT_READY\n", cmd); | |
513 | break; | |
514 | case INQUIRY: | |
515 | printk("scsi cmd %X --- SCSIOP_INQUIRY\n", cmd); | |
516 | break; | |
517 | case MODE_SENSE: | |
518 | printk("scsi cmd %X --- SCSIOP_MODE_SENSE\n", cmd); | |
519 | break; | |
520 | case START_STOP: | |
521 | printk("scsi cmd %X --- SCSIOP_START_STOP\n", cmd); | |
522 | break; | |
523 | case READ_CAPACITY: | |
524 | printk("scsi cmd %X --- SCSIOP_READ_CAPACITY\n", cmd); | |
525 | break; | |
526 | case READ_10: | |
527 | //printk("scsi cmd %X --- SCSIOP_READ, bn = %X, blen = %X\n", cmd, bn, blen); | |
528 | break; | |
529 | case WRITE_10: | |
530 | //printk("scsi cmd %X --- SCSIOP_WRITE, bn = %X, blen = %X\n", cmd, bn, blen); | |
531 | break; | |
532 | case ALLOW_MEDIUM_REMOVAL: | |
533 | printk("scsi cmd %X --- SCSIOP_ALLOW_MEDIUM_REMOVAL\n", cmd); | |
534 | break; | |
535 | default: | |
536 | printk("scsi cmd %X --- Other cmd\n", cmd); | |
537 | break; | |
538 | } | |
539 | bn = 0; | |
540 | blen = 0; | |
541 | } | |
542 | ||
543 |