aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorCho, Yu-Chen <acho@novell.com>2011-05-18 06:40:14 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-18 11:22:40 -0400
commit3aa4fc587df15a7a55bd6e3f3fbdcca30c7acc58 (patch)
treeb4bf4d115d6ec66ce1d3f7ffb7f84b84034aea79 /drivers/staging
parentece114aa788de418874c660c789c018a07a08bb1 (diff)
staging/keucr: fix keucr transport coding style
fix keucr transport.c transport.h coding style Signed-off-by: Cho, Yu-Chen <acho@novell.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/keucr/transport.c385
-rw-r--r--drivers/staging/keucr/transport.h81
2 files changed, 258 insertions, 208 deletions
diff --git a/drivers/staging/keucr/transport.c b/drivers/staging/keucr/transport.c
index 011427645fe..d48f592fe2a 100644
--- a/drivers/staging/keucr/transport.c
+++ b/drivers/staging/keucr/transport.c
@@ -15,7 +15,9 @@
15/*********************************************************************** 15/***********************************************************************
16 * Data transfer routines 16 * Data transfer routines
17 ***********************************************************************/ 17 ***********************************************************************/
18//----- usb_stor_blocking_completion() --------------------- 18/*
19 * usb_stor_blocking_completion()
20 */
19static void usb_stor_blocking_completion(struct urb *urb) 21static void usb_stor_blocking_completion(struct urb *urb)
20{ 22{
21 struct completion *urb_done_ptr = urb->context; 23 struct completion *urb_done_ptr = urb->context;
@@ -24,7 +26,9 @@ static void usb_stor_blocking_completion(struct urb *urb)
24 complete(urb_done_ptr); 26 complete(urb_done_ptr);
25} 27}
26 28
27//----- usb_stor_msg_common() --------------------- 29/*
30 * usb_stor_msg_common()
31 */
28static int usb_stor_msg_common(struct us_data *us, int timeout) 32static int usb_stor_msg_common(struct us_data *us, int timeout)
29{ 33{
30 struct completion urb_done; 34 struct completion urb_done;
@@ -54,20 +58,18 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
54 58
55 set_bit(US_FLIDX_URB_ACTIVE, &us->dflags); 59 set_bit(US_FLIDX_URB_ACTIVE, &us->dflags);
56 60
57 if (test_bit(US_FLIDX_ABORTING, &us->dflags)) 61 if (test_bit(US_FLIDX_ABORTING, &us->dflags)) {
58 { 62 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
59 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags))
60 {
61 /* pr_info("-- cancelling URB\n"); */ 63 /* pr_info("-- cancelling URB\n"); */
62 usb_unlink_urb(us->current_urb); 64 usb_unlink_urb(us->current_urb);
63 } 65 }
64 } 66 }
65 67
66 timeleft = wait_for_completion_interruptible_timeout(&urb_done, timeout ? : MAX_SCHEDULE_TIMEOUT); 68 timeleft = wait_for_completion_interruptible_timeout(&urb_done,
69 timeout ? : MAX_SCHEDULE_TIMEOUT);
67 clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags); 70 clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags);
68 71
69 if (timeleft <= 0) 72 if (timeleft <= 0) {
70 {
71 /* pr_info("%s -- cancelling URB\n", 73 /* pr_info("%s -- cancelling URB\n",
72 timeleft == 0 ? "Timeout" : "Signal"); */ 74 timeleft == 0 ? "Timeout" : "Signal"); */
73 usb_kill_urb(us->current_urb); 75 usb_kill_urb(us->current_urb);
@@ -76,7 +78,9 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
76 return us->current_urb->status; 78 return us->current_urb->status;
77} 79}
78 80
79//----- usb_stor_control_msg() --------------------- 81/*
82 * usb_stor_control_msg()
83 */
80int usb_stor_control_msg(struct us_data *us, unsigned int pipe, 84int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
81 u8 request, u8 requesttype, u16 value, u16 index, 85 u8 request, u8 requesttype, u16 value, u16 index,
82 void *data, u16 size, int timeout) 86 void *data, u16 size, int timeout)
@@ -94,7 +98,7 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
94 98
95 /* fill and submit the URB */ 99 /* fill and submit the URB */
96 usb_fill_control_urb(us->current_urb, us->pusb_dev, pipe, 100 usb_fill_control_urb(us->current_urb, us->pusb_dev, pipe,
97 (unsigned char*) us->cr, data, size, 101 (unsigned char *) us->cr, data, size,
98 usb_stor_blocking_completion, NULL); 102 usb_stor_blocking_completion, NULL);
99 status = usb_stor_msg_common(us, timeout); 103 status = usb_stor_msg_common(us, timeout);
100 104
@@ -104,14 +108,16 @@ int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
104 return status; 108 return status;
105} 109}
106 110
107//----- usb_stor_clear_halt() --------------------- 111/*
112 * usb_stor_clear_halt()
113 */
108int usb_stor_clear_halt(struct us_data *us, unsigned int pipe) 114int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
109{ 115{
110 int result; 116 int result;
111 int endp = usb_pipeendpoint(pipe); 117 int endp = usb_pipeendpoint(pipe);
112 118
113 /* pr_info("transport --- usb_stor_clear_halt\n"); */ 119 /* pr_info("transport --- usb_stor_clear_halt\n"); */
114 if (usb_pipein (pipe)) 120 if (usb_pipein(pipe))
115 endp |= USB_DIR_IN; 121 endp |= USB_DIR_IN;
116 122
117 result = usb_stor_control_msg(us, us->send_ctrl_pipe, 123 result = usb_stor_control_msg(us, us->send_ctrl_pipe,
@@ -121,13 +127,16 @@ int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
121 127
122 /* reset the endpoint toggle */ 128 /* reset the endpoint toggle */
123 if (result >= 0) 129 if (result >= 0)
124 //usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 0); 130 /* usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe),
125 usb_reset_endpoint(us->pusb_dev, endp); 131 usb_pipeout(pipe), 0); */
132 usb_reset_endpoint(us->pusb_dev, endp);
126 133
127 return result; 134 return result;
128} 135}
129 136
130//----- interpret_urb_result() --------------------- 137/*
138 * interpret_urb_result()
139 */
131static int interpret_urb_result(struct us_data *us, unsigned int pipe, 140static int interpret_urb_result(struct us_data *us, unsigned int pipe,
132 unsigned int length, int result, unsigned int partial) 141 unsigned int length, int result, unsigned int partial)
133{ 142{
@@ -135,16 +144,14 @@ static int interpret_urb_result(struct us_data *us, unsigned int pipe,
135 switch (result) { 144 switch (result) {
136 /* no error code; did we send all the data? */ 145 /* no error code; did we send all the data? */
137 case 0: 146 case 0:
138 if (partial != length) 147 if (partial != length) {
139 {
140 /* pr_info("-- short transfer\n"); */ 148 /* pr_info("-- short transfer\n"); */
141 return USB_STOR_XFER_SHORT; 149 return USB_STOR_XFER_SHORT;
142 } 150 }
143 /* pr_info("-- transfer complete\n"); */ 151 /* pr_info("-- transfer complete\n"); */
144 return USB_STOR_XFER_GOOD; 152 return USB_STOR_XFER_GOOD;
145 case -EPIPE: 153 case -EPIPE:
146 if (usb_pipecontrol(pipe)) 154 if (usb_pipecontrol(pipe)) {
147 {
148 /* pr_info("-- stall on control pipe\n"); */ 155 /* pr_info("-- stall on control pipe\n"); */
149 return USB_STOR_XFER_STALLED; 156 return USB_STOR_XFER_STALLED;
150 } 157 }
@@ -170,7 +177,9 @@ static int interpret_urb_result(struct us_data *us, unsigned int pipe,
170 } 177 }
171} 178}
172 179
173//----- usb_stor_bulk_transfer_buf() --------------------- 180/*
181 * usb_stor_bulk_transfer_buf()
182 */
174int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe, 183int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
175 void *buf, unsigned int length, unsigned int *act_len) 184 void *buf, unsigned int length, unsigned int *act_len)
176{ 185{
@@ -179,17 +188,21 @@ int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
179 /* pr_info("transport --- usb_stor_bulk_transfer_buf\n"); */ 188 /* pr_info("transport --- usb_stor_bulk_transfer_buf\n"); */
180 189
181 /* fill and submit the URB */ 190 /* fill and submit the URB */
182 usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length, usb_stor_blocking_completion, NULL); 191 usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf,
192 length, usb_stor_blocking_completion, NULL);
183 result = usb_stor_msg_common(us, 0); 193 result = usb_stor_msg_common(us, 0);
184 194
185 /* store the actual length of the data transferred */ 195 /* store the actual length of the data transferred */
186 if (act_len) 196 if (act_len)
187 *act_len = us->current_urb->actual_length; 197 *act_len = us->current_urb->actual_length;
188 198
189 return interpret_urb_result(us, pipe, length, result, us->current_urb->actual_length); 199 return interpret_urb_result(us, pipe, length, result,
200 us->current_urb->actual_length);
190} 201}
191 202
192//----- usb_stor_bulk_transfer_sglist() --------------------- 203/*
204 * usb_stor_bulk_transfer_sglist()
205 */
193static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe, 206static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
194 struct scatterlist *sg, int num_sg, unsigned int length, 207 struct scatterlist *sg, int num_sg, unsigned int length,
195 unsigned int *act_len) 208 unsigned int *act_len)
@@ -201,22 +214,21 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
201 return USB_STOR_XFER_ERROR; 214 return USB_STOR_XFER_ERROR;
202 215
203 /* initialize the scatter-gather request block */ 216 /* initialize the scatter-gather request block */
204 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, sg, num_sg, length, GFP_NOIO); 217 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
205 if (result) 218 sg, num_sg, length, GFP_NOIO);
206 { 219 if (result) {
207 /* pr_info("usb_sg_init returned %d\n", result); */ 220 /* pr_info("usb_sg_init returned %d\n", result); */
208 return USB_STOR_XFER_ERROR; 221 return USB_STOR_XFER_ERROR;
209 } 222 }
210 223
211 /* since the block has been initialized successfully, it's now okay to cancel it */ 224 /* since the block has been initialized successfully,
225 it's now okay to cancel it */
212 set_bit(US_FLIDX_SG_ACTIVE, &us->dflags); 226 set_bit(US_FLIDX_SG_ACTIVE, &us->dflags);
213 227
214 /* did an abort/disconnect occur during the submission? */ 228 /* did an abort/disconnect occur during the submission? */
215 if (test_bit(US_FLIDX_ABORTING, &us->dflags)) 229 if (test_bit(US_FLIDX_ABORTING, &us->dflags)) {
216 {
217 /* cancel the request, if it hasn't been cancelled already */ 230 /* cancel the request, if it hasn't been cancelled already */
218 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) 231 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
219 {
220 /* pr_info("-- cancelling sg request\n"); */ 232 /* pr_info("-- cancelling sg request\n"); */
221 usb_sg_cancel(&us->current_sg); 233 usb_sg_cancel(&us->current_sg);
222 } 234 }
@@ -230,11 +242,15 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
230 if (act_len) 242 if (act_len)
231 *act_len = us->current_sg.bytes; 243 *act_len = us->current_sg.bytes;
232 244
233 return interpret_urb_result(us, pipe, length, result, us->current_sg.bytes); 245 return interpret_urb_result(us, pipe, length,
246 result, us->current_sg.bytes);
234} 247}
235 248
236//----- usb_stor_bulk_srb() --------------------- 249/*
237int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe, struct scsi_cmnd* srb) 250 * usb_stor_bulk_srb()
251 */
252int usb_stor_bulk_srb(struct us_data *us, unsigned int pipe,
253 struct scsi_cmnd *srb)
238{ 254{
239 unsigned int partial; 255 unsigned int partial;
240 int result = usb_stor_bulk_transfer_sglist(us, pipe, scsi_sglist(srb), 256 int result = usb_stor_bulk_transfer_sglist(us, pipe, scsi_sglist(srb),
@@ -245,8 +261,10 @@ int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe, struct scsi_cmnd* s
245 return result; 261 return result;
246} 262}
247 263
248//----- usb_stor_bulk_transfer_sg() --------------------- 264/*
249int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe, 265 * usb_stor_bulk_transfer_sg()
266 */
267int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
250 void *buf, unsigned int length_left, int use_sg, int *residual) 268 void *buf, unsigned int length_left, int use_sg, int *residual)
251{ 269{
252 int result; 270 int result;
@@ -254,18 +272,16 @@ int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,
254 272
255 /* pr_info("transport --- usb_stor_bulk_transfer_sg\n"); */ 273 /* pr_info("transport --- usb_stor_bulk_transfer_sg\n"); */
256 /* are we scatter-gathering? */ 274 /* are we scatter-gathering? */
257 if (use_sg) 275 if (use_sg) {
258 {
259 /* use the usb core scatter-gather primitives */ 276 /* use the usb core scatter-gather primitives */
260 result = usb_stor_bulk_transfer_sglist(us, pipe, 277 result = usb_stor_bulk_transfer_sglist(us, pipe,
261 (struct scatterlist *) buf, use_sg, 278 (struct scatterlist *) buf, use_sg,
262 length_left, &partial); 279 length_left, &partial);
263 length_left -= partial; 280 length_left -= partial;
264 } 281 } else {
265 else
266 {
267 /* no scatter-gather, just make the request */ 282 /* no scatter-gather, just make the request */
268 result = usb_stor_bulk_transfer_buf(us, pipe, buf, length_left, &partial); 283 result = usb_stor_bulk_transfer_buf(us, pipe, buf,
284 length_left, &partial);
269 length_left -= partial; 285 length_left -= partial;
270 } 286 }
271 287
@@ -278,7 +294,9 @@ int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,
278/*********************************************************************** 294/***********************************************************************
279 * Transport routines 295 * Transport routines
280 ***********************************************************************/ 296 ***********************************************************************/
281//----- usb_stor_invoke_transport() --------------------- 297/*
298 * usb_stor_invoke_transport()
299 */
282void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) 300void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
283{ 301{
284 int need_auto_sense; 302 int need_auto_sense;
@@ -288,27 +306,25 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
288 usb_stor_print_cmd(srb); 306 usb_stor_print_cmd(srb);
289 /* send the command to the transport layer */ 307 /* send the command to the transport layer */
290 scsi_set_resid(srb, 0); 308 scsi_set_resid(srb, 0);
291 result = us->transport(srb, us); //usb_stor_Bulk_transport; 309 result = us->transport(srb, us); /* usb_stor_Bulk_transport; */
292 310
293 /* if the command gets aborted by the higher layers, we need to short-circuit all other processing */ 311 /* if the command gets aborted by the higher layers,
294 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) 312 we need to short-circuit all other processing */
295 { 313 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
296 /* pr_info("-- command was aborted\n"); */ 314 /* pr_info("-- command was aborted\n"); */
297 srb->result = DID_ABORT << 16; 315 srb->result = DID_ABORT << 16;
298 goto Handle_Errors; 316 goto Handle_Errors;
299 } 317 }
300 318
301 /* if there is a transport error, reset and don't auto-sense */ 319 /* if there is a transport error, reset and don't auto-sense */
302 if (result == USB_STOR_TRANSPORT_ERROR) 320 if (result == USB_STOR_TRANSPORT_ERROR) {
303 {
304 /* pr_info("-- transport indicates error, resetting\n"); */ 321 /* pr_info("-- transport indicates error, resetting\n"); */
305 srb->result = DID_ERROR << 16; 322 srb->result = DID_ERROR << 16;
306 goto Handle_Errors; 323 goto Handle_Errors;
307 } 324 }
308 325
309 /* if the transport provided its own sense data, don't auto-sense */ 326 /* if the transport provided its own sense data, don't auto-sense */
310 if (result == USB_STOR_TRANSPORT_NO_SENSE) 327 if (result == USB_STOR_TRANSPORT_NO_SENSE) {
311 {
312 srb->result = SAM_STAT_CHECK_CONDITION; 328 srb->result = SAM_STAT_CHECK_CONDITION;
313 return; 329 return;
314 } 330 }
@@ -318,21 +334,19 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
318 /* Determine if we need to auto-sense */ 334 /* Determine if we need to auto-sense */
319 need_auto_sense = 0; 335 need_auto_sense = 0;
320 336
321 if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) && srb->sc_data_direction != DMA_FROM_DEVICE) 337 if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) &&
322 { 338 srb->sc_data_direction != DMA_FROM_DEVICE) {
323 /* pr_info("-- CB transport device requiring auto-sense\n"); */ 339 /* pr_info("-- CB transport device requiring auto-sense\n"); */
324 need_auto_sense = 1; 340 need_auto_sense = 1;
325 } 341 }
326 342
327 if (result == USB_STOR_TRANSPORT_FAILED) 343 if (result == USB_STOR_TRANSPORT_FAILED) {
328 {
329 /* pr_info("-- transport indicates command failure\n"); */ 344 /* pr_info("-- transport indicates command failure\n"); */
330 need_auto_sense = 1; 345 need_auto_sense = 1;
331 } 346 }
332 347
333 /* Now, if we need to do the auto-sense, let's do it */ 348 /* Now, if we need to do the auto-sense, let's do it */
334 if (need_auto_sense) 349 if (need_auto_sense) {
335 {
336 int temp_result; 350 int temp_result;
337 struct scsi_eh_save ses; 351 struct scsi_eh_save ses;
338 352
@@ -341,11 +355,13 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
341 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE); 355 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE);
342 356
343 /* we must do the protocol translation here */ 357 /* we must do the protocol translation here */
344 if (us->subclass == USB_SC_RBC || us->subclass == USB_SC_SCSI || us->subclass == USB_SC_CYP_ATACB) 358 if (us->subclass == USB_SC_RBC ||
359 us->subclass == USB_SC_SCSI ||
360 us->subclass == USB_SC_CYP_ATACB) {
345 srb->cmd_len = 6; 361 srb->cmd_len = 6;
346 else 362 } else {
347 srb->cmd_len = 12; 363 srb->cmd_len = 12;
348 364 }
349 /* issue the auto-sense command */ 365 /* issue the auto-sense command */
350 scsi_set_resid(srb, 0); 366 scsi_set_resid(srb, 0);
351 temp_result = us->transport(us->srb, us); 367 temp_result = us->transport(us->srb, us);
@@ -353,14 +369,12 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
353 /* let's clean up right away */ 369 /* let's clean up right away */
354 scsi_eh_restore_cmnd(srb, &ses); 370 scsi_eh_restore_cmnd(srb, &ses);
355 371
356 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) 372 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
357 {
358 /* pr_info("-- auto-sense aborted\n"); */ 373 /* pr_info("-- auto-sense aborted\n"); */
359 srb->result = DID_ABORT << 16; 374 srb->result = DID_ABORT << 16;
360 goto Handle_Errors; 375 goto Handle_Errors;
361 } 376 }
362 if (temp_result != USB_STOR_TRANSPORT_GOOD) 377 if (temp_result != USB_STOR_TRANSPORT_GOOD) {
363 {
364 /* pr_info("-- auto-sense failure\n"); */ 378 /* pr_info("-- auto-sense failure\n"); */
365 srb->result = DID_ERROR << 16; 379 srb->result = DID_ERROR << 16;
366 if (!(us->fflags & US_FL_SCM_MULT_TARG)) 380 if (!(us->fflags & US_FL_SCM_MULT_TARG))
@@ -374,16 +388,17 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
374 if (result == USB_STOR_TRANSPORT_GOOD && 388 if (result == USB_STOR_TRANSPORT_GOOD &&
375 (srb->sense_buffer[2] & 0xaf) == 0 && 389 (srb->sense_buffer[2] & 0xaf) == 0 &&
376 srb->sense_buffer[12] == 0 && 390 srb->sense_buffer[12] == 0 &&
377 srb->sense_buffer[13] == 0) 391 srb->sense_buffer[13] == 0) {
378 {
379 srb->result = SAM_STAT_GOOD; 392 srb->result = SAM_STAT_GOOD;
380 srb->sense_buffer[0] = 0x0; 393 srb->sense_buffer[0] = 0x0;
381 } 394 }
382 } 395 }
383 396
384 /* Did we transfer less than the minimum amount required? */ 397 /* Did we transfer less than the minimum amount required? */
385 if (srb->result == SAM_STAT_GOOD && scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) 398 if (srb->result == SAM_STAT_GOOD && scsi_bufflen(srb) -
386 srb->result = (DID_ERROR << 16);//v02 | (SUGGEST_RETRY << 24); 399 scsi_get_resid(srb) < srb->underflow)
400 srb->result = (DID_ERROR << 16);
401 /* v02 | (SUGGEST_RETRY << 24); */
387 402
388 return; 403 return;
389 404
@@ -397,8 +412,7 @@ Handle_Errors:
397 result = usb_stor_port_reset(us); 412 result = usb_stor_port_reset(us);
398 mutex_lock(&us->dev_mutex); 413 mutex_lock(&us->dev_mutex);
399 414
400 if (result < 0) 415 if (result < 0) {
401 {
402 scsi_lock(us_to_host(us)); 416 scsi_lock(us_to_host(us));
403 usb_stor_report_device_reset(us); 417 usb_stor_report_device_reset(us);
404 scsi_unlock(us_to_host(us)); 418 scsi_unlock(us_to_host(us));
@@ -407,10 +421,12 @@ Handle_Errors:
407 clear_bit(US_FLIDX_RESETTING, &us->dflags); 421 clear_bit(US_FLIDX_RESETTING, &us->dflags);
408} 422}
409 423
410//----- ENE_stor_invoke_transport() --------------------- 424/*
425 * ENE_stor_invoke_transport()
426 */
411void ENE_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) 427void ENE_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
412{ 428{
413 int result=0; 429 int result = 0;
414 430
415 /* pr_info("transport --- ENE_stor_invoke_transport\n"); */ 431 /* pr_info("transport --- ENE_stor_invoke_transport\n"); */
416 usb_stor_print_cmd(srb); 432 usb_stor_print_cmd(srb);
@@ -418,50 +434,51 @@ void ENE_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
418 scsi_set_resid(srb, 0); 434 scsi_set_resid(srb, 0);
419 if (!(us->MS_Status.Ready || us->SM_Status.Ready)) 435 if (!(us->MS_Status.Ready || us->SM_Status.Ready))
420 result = ENE_InitMedia(us); 436 result = ENE_InitMedia(us);
421 437
422 if (us->Power_IsResum == true) { 438 if (us->Power_IsResum == true) {
423 result = ENE_InitMedia(us); 439 result = ENE_InitMedia(us);
424 us->Power_IsResum = false; 440 us->Power_IsResum = false;
425 } 441 }
426 442
427 if (us->MS_Status.Ready) result = MS_SCSIIrp(us, srb); 443 if (us->MS_Status.Ready)
428 if (us->SM_Status.Ready) result = SM_SCSIIrp(us, srb); 444 result = MS_SCSIIrp(us, srb);
429 445 if (us->SM_Status.Ready)
430 /* if the command gets aborted by the higher layers, we need to short-circuit all other processing */ 446 result = SM_SCSIIrp(us, srb);
431 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) 447
432 { 448 /* if the command gets aborted by the higher layers,
449 we need to short-circuit all other processing */
450 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
433 /* pr_info("-- command was aborted\n"); */ 451 /* pr_info("-- command was aborted\n"); */
434 srb->result = DID_ABORT << 16; 452 srb->result = DID_ABORT << 16;
435 goto Handle_Errors; 453 goto Handle_Errors;
436 } 454 }
437 455
438 /* if there is a transport error, reset and don't auto-sense */ 456 /* if there is a transport error, reset and don't auto-sense */
439 if (result == USB_STOR_TRANSPORT_ERROR) 457 if (result == USB_STOR_TRANSPORT_ERROR) {
440 {
441 /* pr_info("-- transport indicates error, resetting\n"); */ 458 /* pr_info("-- transport indicates error, resetting\n"); */
442 srb->result = DID_ERROR << 16; 459 srb->result = DID_ERROR << 16;
443 goto Handle_Errors; 460 goto Handle_Errors;
444 } 461 }
445 462
446 /* if the transport provided its own sense data, don't auto-sense */ 463 /* if the transport provided its own sense data, don't auto-sense */
447 if (result == USB_STOR_TRANSPORT_NO_SENSE) 464 if (result == USB_STOR_TRANSPORT_NO_SENSE) {
448 {
449 srb->result = SAM_STAT_CHECK_CONDITION; 465 srb->result = SAM_STAT_CHECK_CONDITION;
450 return; 466 return;
451 } 467 }
452 468
453 srb->result = SAM_STAT_GOOD; 469 srb->result = SAM_STAT_GOOD;
454 if (result == USB_STOR_TRANSPORT_FAILED) 470 if (result == USB_STOR_TRANSPORT_FAILED) {
455 {
456 /* pr_info("-- transport indicates command failure\n"); */ 471 /* pr_info("-- transport indicates command failure\n"); */
457 //need_auto_sense = 1; 472 /* need_auto_sense = 1; */
458 BuildSenseBuffer(srb, us->SrbStatus); 473 BuildSenseBuffer(srb, us->SrbStatus);
459 srb->result = SAM_STAT_CHECK_CONDITION; 474 srb->result = SAM_STAT_CHECK_CONDITION;
460 } 475 }
461 476
462 /* Did we transfer less than the minimum amount required? */ 477 /* Did we transfer less than the minimum amount required? */
463 if (srb->result == SAM_STAT_GOOD && scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) 478 if (srb->result == SAM_STAT_GOOD && scsi_bufflen(srb) -
464 srb->result = (DID_ERROR << 16);//v02 | (SUGGEST_RETRY << 24); 479 scsi_get_resid(srb) < srb->underflow)
480 srb->result = (DID_ERROR << 16);
481 /* v02 | (SUGGEST_RETRY << 24); */
465 482
466 return; 483 return;
467 484
@@ -475,8 +492,7 @@ Handle_Errors:
475 result = usb_stor_port_reset(us); 492 result = usb_stor_port_reset(us);
476 mutex_lock(&us->dev_mutex); 493 mutex_lock(&us->dev_mutex);
477 494
478 if (result < 0) 495 if (result < 0) {
479 {
480 scsi_lock(us_to_host(us)); 496 scsi_lock(us_to_host(us));
481 usb_stor_report_device_reset(us); 497 usb_stor_report_device_reset(us);
482 scsi_unlock(us_to_host(us)); 498 scsi_unlock(us_to_host(us));
@@ -485,47 +501,58 @@ Handle_Errors:
485 clear_bit(US_FLIDX_RESETTING, &us->dflags); 501 clear_bit(US_FLIDX_RESETTING, &us->dflags);
486} 502}
487 503
488//----- BuildSenseBuffer() ------------------------------------------- 504/*
505 * BuildSenseBuffer()
506 */
489void BuildSenseBuffer(struct scsi_cmnd *srb, int SrbStatus) 507void BuildSenseBuffer(struct scsi_cmnd *srb, int SrbStatus)
490{ 508{
491 BYTE *buf = srb->sense_buffer; 509 BYTE *buf = srb->sense_buffer;
492 BYTE asc; 510 BYTE asc;
493 511
494 pr_info("transport --- BuildSenseBuffer\n"); 512 pr_info("transport --- BuildSenseBuffer\n");
495 switch (SrbStatus) 513 switch (SrbStatus) {
496 { 514 case SS_NOT_READY:
497 case SS_NOT_READY: asc = 0x3a; break; // sense key = 0x02 515 asc = 0x3a;
498 case SS_MEDIUM_ERR: asc = 0x0c; break; // sense key = 0x03 516 break; /* sense key = 0x02 */
499 case SS_ILLEGAL_REQUEST: asc = 0x20; break; // sense key = 0x05 517 case SS_MEDIUM_ERR:
500 default: asc = 0x00; break; // ?? 518 asc = 0x0c;
501 } 519 break; /* sense key = 0x03 */
502 520 case SS_ILLEGAL_REQUEST:
503 memset(buf, 0, 18); 521 asc = 0x20;
504 buf[0x00] = 0xf0; 522 break; /* sense key = 0x05 */
505 buf[0x02] = SrbStatus; 523 default:
506 buf[0x07] = 0x0b; 524 asc = 0x00;
507 buf[0x0c] = asc; 525 break; /* ?? */
526 }
527
528 memset(buf, 0, 18);
529 buf[0x00] = 0xf0;
530 buf[0x02] = SrbStatus;
531 buf[0x07] = 0x0b;
532 buf[0x0c] = asc;
508} 533}
509 534
510//----- usb_stor_stop_transport() --------------------- 535/*
536 * usb_stor_stop_transport()
537 */
511void usb_stor_stop_transport(struct us_data *us) 538void usb_stor_stop_transport(struct us_data *us)
512{ 539{
513 /* pr_info("transport --- usb_stor_stop_transport\n"); */ 540 /* pr_info("transport --- usb_stor_stop_transport\n"); */
514 541
515 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) 542 if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
516 {
517 /* pr_info("-- cancelling URB\n"); */ 543 /* pr_info("-- cancelling URB\n"); */
518 usb_unlink_urb(us->current_urb); 544 usb_unlink_urb(us->current_urb);
519 } 545 }
520 546
521 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) 547 if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
522 {
523 /* pr_info("-- cancelling sg request\n"); */ 548 /* pr_info("-- cancelling sg request\n"); */
524 usb_sg_cancel(&us->current_sg); 549 usb_sg_cancel(&us->current_sg);
525 } 550 }
526} 551}
527 552
528//----- usb_stor_Bulk_max_lun() --------------------- 553/*
554 * usb_stor_Bulk_max_lun()
555 */
529int usb_stor_Bulk_max_lun(struct us_data *us) 556int usb_stor_Bulk_max_lun(struct us_data *us)
530{ 557{
531 int result; 558 int result;
@@ -549,7 +576,9 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
549 return 0; 576 return 0;
550} 577}
551 578
552//----- usb_stor_Bulk_transport() --------------------- 579/*
580 * usb_stor_Bulk_transport()
581 */
553int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) 582int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
554{ 583{
555 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; 584 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
@@ -563,8 +592,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
563 592
564 /* pr_info("transport --- usb_stor_Bulk_transport\n"); */ 593 /* pr_info("transport --- usb_stor_Bulk_transport\n"); */
565 /* Take care of BULK32 devices; set extra byte to 0 */ 594 /* Take care of BULK32 devices; set extra byte to 0 */
566 if (unlikely(us->fflags & US_FL_BULK32)) 595 if (unlikely(us->fflags & US_FL_BULK32)) {
567 {
568 cbwlen = 32; 596 cbwlen = 32;
569 us->iobuf[31] = 0; 597 us->iobuf[31] = 0;
570 } 598 }
@@ -583,14 +611,15 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
583 memset(bcb->CDB, 0, sizeof(bcb->CDB)); 611 memset(bcb->CDB, 0, sizeof(bcb->CDB));
584 memcpy(bcb->CDB, srb->cmnd, bcb->Length); 612 memcpy(bcb->CDB, srb->cmnd, bcb->Length);
585 613
586 // send command 614 /* send command */
587 /* send it to out endpoint */ 615 /* send it to out endpoint */
588 /* pr_info("Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n", 616 /* pr_info("Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n",
589 le32_to_cpu(bcb->Signature), bcb->Tag, 617 le32_to_cpu(bcb->Signature), bcb->Tag,
590 le32_to_cpu(bcb->DataTransferLength), bcb->Flags, 618 le32_to_cpu(bcb->DataTransferLength), bcb->Flags,
591 (bcb->Lun >> 4), (bcb->Lun & 0x0F), 619 (bcb->Lun >> 4), (bcb->Lun & 0x0F),
592 bcb->Length); */ 620 bcb->Length); */
593 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb, cbwlen, NULL); 621 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
622 bcb, cbwlen, NULL);
594 /* pr_info("Bulk command transfer result=%d\n", result); */ 623 /* pr_info("Bulk command transfer result=%d\n", result); */
595 if (result != USB_STOR_XFER_GOOD) 624 if (result != USB_STOR_XFER_GOOD)
596 return USB_STOR_TRANSPORT_ERROR; 625 return USB_STOR_TRANSPORT_ERROR;
@@ -598,10 +627,10 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
598 if (unlikely(us->fflags & US_FL_GO_SLOW)) 627 if (unlikely(us->fflags & US_FL_GO_SLOW))
599 udelay(125); 628 udelay(125);
600 629
601 // R/W data 630 /* R/W data */
602 if (transfer_length) 631 if (transfer_length) {
603 { 632 unsigned int pipe = srb->sc_data_direction ==
604 unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? us->recv_bulk_pipe : us->send_bulk_pipe; 633 DMA_FROM_DEVICE ? us->recv_bulk_pipe : us->send_bulk_pipe;
605 result = usb_stor_bulk_srb(us, pipe, srb); 634 result = usb_stor_bulk_srb(us, pipe, srb);
606 /* pr_info("Bulk data transfer result 0x%x\n", result); */ 635 /* pr_info("Bulk data transfer result 0x%x\n", result); */
607 if (result == USB_STOR_XFER_ERROR) 636 if (result == USB_STOR_XFER_ERROR)
@@ -613,20 +642,21 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
613 642
614 /* get CSW for device status */ 643 /* get CSW for device status */
615 /* pr_info("Attempting to get CSW...\n"); */ 644 /* pr_info("Attempting to get CSW...\n"); */
616 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, &cswlen); 645 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
646 US_BULK_CS_WRAP_LEN, &cswlen);
617 647
618 if (result == USB_STOR_XFER_SHORT && cswlen == 0) 648 if (result == USB_STOR_XFER_SHORT && cswlen == 0) {
619 {
620 /* pr_info("Received 0-length CSW; retrying...\n"); */ 649 /* pr_info("Received 0-length CSW; retrying...\n"); */
621 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, &cswlen); 650 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
651 US_BULK_CS_WRAP_LEN, &cswlen);
622 } 652 }
623 653
624 /* did the attempt to read the CSW fail? */ 654 /* did the attempt to read the CSW fail? */
625 if (result == USB_STOR_XFER_STALLED) 655 if (result == USB_STOR_XFER_STALLED) {
626 {
627 /* get the status again */ 656 /* get the status again */
628 /* pr_info("Attempting to get CSW (2nd try)...\n"); */ 657 /* pr_info("Attempting to get CSW (2nd try)...\n"); */
629 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs, US_BULK_CS_WRAP_LEN, NULL); 658 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
659 US_BULK_CS_WRAP_LEN, NULL);
630 } 660 }
631 661
632 /* if we still have a failure at this point, we're in trouble */ 662 /* if we still have a failure at this point, we're in trouble */
@@ -639,21 +669,19 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
639 /* pr_info("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", 669 /* pr_info("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
640 le32_to_cpu(bcs->Signature), 670 le32_to_cpu(bcs->Signature),
641 bcs->Tag, residue, bcs->Status); */ 671 bcs->Tag, residue, bcs->Status); */
642 if (!(bcs->Tag == us->tag || (us->fflags & US_FL_BULK_IGNORE_TAG)) || bcs->Status > US_BULK_STAT_PHASE) 672 if (!(bcs->Tag == us->tag ||
643 { 673 (us->fflags & US_FL_BULK_IGNORE_TAG)) ||
674 bcs->Status > US_BULK_STAT_PHASE) {
644 /* pr_info("Bulk logical error\n"); */ 675 /* pr_info("Bulk logical error\n"); */
645 return USB_STOR_TRANSPORT_ERROR; 676 return USB_STOR_TRANSPORT_ERROR;
646 } 677 }
647 678
648 if (!us->bcs_signature) 679 if (!us->bcs_signature) {
649 {
650 us->bcs_signature = bcs->Signature; 680 us->bcs_signature = bcs->Signature;
651 //if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN)) 681 /* if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN)) */
652 /* pr_info("Learnt BCS signature 0x%08X\n", 682 /* pr_info("Learnt BCS signature 0x%08X\n",
653 le32_to_cpu(us->bcs_signature)); */ 683 le32_to_cpu(us->bcs_signature)); */
654 } 684 } else if (bcs->Signature != us->bcs_signature) {
655 else if (bcs->Signature != us->bcs_signature)
656 {
657 /* pr_info("Signature mismatch: got %08X, expecting %08X\n", 685 /* pr_info("Signature mismatch: got %08X, expecting %08X\n",
658 le32_to_cpu(bcs->Signature), 686 le32_to_cpu(bcs->Signature),
659 le32_to_cpu(us->bcs_signature)); */ 687 le32_to_cpu(us->bcs_signature)); */
@@ -662,8 +690,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
662 690
663 /* try to compute the actual residue, based on how much data 691 /* try to compute the actual residue, based on how much data
664 * was really transferred and what the device tells us */ 692 * was really transferred and what the device tells us */
665 if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) 693 if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) {
666 {
667 694
668 /* Heuristically detect devices that generate bogus residues 695 /* Heuristically detect devices that generate bogus residues
669 * by seeing what happens with INQUIRY and READ CAPACITY 696 * by seeing what happens with INQUIRY and READ CAPACITY
@@ -674,34 +701,31 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
674 ((srb->cmnd[0] == INQUIRY && 701 ((srb->cmnd[0] == INQUIRY &&
675 transfer_length == 36) || 702 transfer_length == 36) ||
676 (srb->cmnd[0] == READ_CAPACITY && 703 (srb->cmnd[0] == READ_CAPACITY &&
677 transfer_length == 8))) 704 transfer_length == 8))) {
678 {
679 us->fflags |= US_FL_IGNORE_RESIDUE; 705 us->fflags |= US_FL_IGNORE_RESIDUE;
680 706
681 } 707 } else {
682 else
683 {
684 residue = min(residue, transfer_length); 708 residue = min(residue, transfer_length);
685 scsi_set_resid(srb, max(scsi_get_resid(srb), (int) residue)); 709 scsi_set_resid(srb, max(scsi_get_resid(srb),
710 (int) residue));
686 } 711 }
687 } 712 }
688 713
689 /* based on the status code, we report good or bad */ 714 /* based on the status code, we report good or bad */
690 switch (bcs->Status) 715 switch (bcs->Status) {
691 { 716 case US_BULK_STAT_OK:
692 case US_BULK_STAT_OK: 717 if (fake_sense) {
693 if (fake_sense) 718 memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB,
694 { 719 sizeof(usb_stor_sense_invalidCDB));
695 memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB, sizeof(usb_stor_sense_invalidCDB)); 720 return USB_STOR_TRANSPORT_NO_SENSE;
696 return USB_STOR_TRANSPORT_NO_SENSE; 721 }
697 } 722 return USB_STOR_TRANSPORT_GOOD;
698 return USB_STOR_TRANSPORT_GOOD; 723
699 724 case US_BULK_STAT_FAIL:
700 case US_BULK_STAT_FAIL: 725 return USB_STOR_TRANSPORT_FAILED;
701 return USB_STOR_TRANSPORT_FAILED; 726
702 727 case US_BULK_STAT_PHASE:
703 case US_BULK_STAT_PHASE: 728 return USB_STOR_TRANSPORT_ERROR;
704 return USB_STOR_TRANSPORT_ERROR;
705 } 729 }
706 return USB_STOR_TRANSPORT_ERROR; 730 return USB_STOR_TRANSPORT_ERROR;
707} 731}
@@ -709,7 +733,9 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
709/*********************************************************************** 733/***********************************************************************
710 * Reset routines 734 * Reset routines
711 ***********************************************************************/ 735 ***********************************************************************/
712//----- usb_stor_reset_common() --------------------- 736/*
737 * usb_stor_reset_common()
738 */
713static int usb_stor_reset_common(struct us_data *us, 739static int usb_stor_reset_common(struct us_data *us,
714 u8 request, u8 requesttype, 740 u8 request, u8 requesttype,
715 u16 value, u16 index, void *data, u16 size) 741 u16 value, u16 index, void *data, u16 size)
@@ -718,22 +744,23 @@ static int usb_stor_reset_common(struct us_data *us,
718 int result2; 744 int result2;
719 745
720 /* pr_info("transport --- usb_stor_reset_common\n"); */ 746 /* pr_info("transport --- usb_stor_reset_common\n"); */
721 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) 747 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
722 {
723 /* pr_info("No reset during disconnect\n"); */ 748 /* pr_info("No reset during disconnect\n"); */
724 return -EIO; 749 return -EIO;
725 } 750 }
726 751
727 result = usb_stor_control_msg(us, us->send_ctrl_pipe, request, requesttype, value, index, data, size, 5*HZ); 752 result = usb_stor_control_msg(us, us->send_ctrl_pipe,
728 if (result < 0) 753 request, requesttype, value, index, data, size, 5*HZ);
729 { 754
755 if (result < 0) {
730 /* pr_info("Soft reset failed: %d\n", result); */ 756 /* pr_info("Soft reset failed: %d\n", result); */
731 return result; 757 return result;
732 } 758 }
733 759
734 wait_event_interruptible_timeout(us->delay_wait, test_bit(US_FLIDX_DISCONNECTING, &us->dflags), HZ*6); 760 wait_event_interruptible_timeout(us->delay_wait,
735 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) 761 test_bit(US_FLIDX_DISCONNECTING, &us->dflags), HZ*6);
736 { 762
763 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
737 /* pr_info("Reset interrupted by disconnect\n"); */ 764 /* pr_info("Reset interrupted by disconnect\n"); */
738 return -EIO; 765 return -EIO;
739 } 766 }
@@ -747,14 +774,16 @@ static int usb_stor_reset_common(struct us_data *us,
747 /* return a result code based on the result of the clear-halts */ 774 /* return a result code based on the result of the clear-halts */
748 if (result >= 0) 775 if (result >= 0)
749 result = result2; 776 result = result2;
750 //if (result < 0) 777 /* if (result < 0) */
751 /* pr_info("Soft reset failed\n"); */ 778 /* pr_info("Soft reset failed\n"); */
752 //else 779 /* else */
753 /* pr_info("Soft reset done\n"); */ 780 /* pr_info("Soft reset done\n"); */
754 return result; 781 return result;
755} 782}
756 783
757//----- usb_stor_Bulk_reset() --------------------- 784/*
785 * usb_stor_Bulk_reset()
786 */
758int usb_stor_Bulk_reset(struct us_data *us) 787int usb_stor_Bulk_reset(struct us_data *us)
759{ 788{
760 /* pr_info("transport --- usb_stor_Bulk_reset\n"); */ 789 /* pr_info("transport --- usb_stor_Bulk_reset\n"); */
@@ -763,7 +792,9 @@ int usb_stor_Bulk_reset(struct us_data *us)
763 0, us->ifnum, NULL, 0); 792 0, us->ifnum, NULL, 0);
764} 793}
765 794
766//----- usb_stor_port_reset() --------------------- 795/*
796 * usb_stor_port_reset()
797 */
767int usb_stor_port_reset(struct us_data *us) 798int usb_stor_port_reset(struct us_data *us)
768{ 799{
769 int result; 800 int result;
diff --git a/drivers/staging/keucr/transport.h b/drivers/staging/keucr/transport.h
index ddfec53bf85..75296152af7 100644
--- a/drivers/staging/keucr/transport.h
+++ b/drivers/staging/keucr/transport.h
@@ -8,7 +8,7 @@
8/* command block wrapper */ 8/* command block wrapper */
9struct bulk_cb_wrap { 9struct bulk_cb_wrap {
10 __le32 Signature; /* contains 'USBC' */ 10 __le32 Signature; /* contains 'USBC' */
11 __u32 Tag; /* unique per command id */ 11 __u32 Tag; /* unique per command id */
12 __le32 DataTransferLength; /* size of data */ 12 __le32 DataTransferLength; /* size of data */
13 __u8 Flags; /* direction in bit 0 */ 13 __u8 Flags; /* direction in bit 0 */
14 __u8 Lun; /* LUN normally 0 */ 14 __u8 Lun; /* LUN normally 0 */
@@ -49,9 +49,9 @@ struct bulk_cs_wrap {
49 49
50/* Transport return codes */ 50/* Transport return codes */
51#define USB_STOR_TRANSPORT_GOOD 0 /* Transport good, command good */ 51#define USB_STOR_TRANSPORT_GOOD 0 /* Transport good, command good */
52#define USB_STOR_TRANSPORT_FAILED 1 /* Transport good, command failed */ 52#define USB_STOR_TRANSPORT_FAILED 1 /* Transport good, command failed */
53#define USB_STOR_TRANSPORT_NO_SENSE 2 /* Command failed, no auto-sense */ 53#define USB_STOR_TRANSPORT_NO_SENSE 2 /* Command failed, no auto-sense */
54#define USB_STOR_TRANSPORT_ERROR 3 /* Transport bad (i.e. device dead) */ 54#define USB_STOR_TRANSPORT_ERROR 3 /* Transport bad (i.e. device dead) */
55 55
56/* 56/*
57 * We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED 57 * We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED
@@ -64,11 +64,11 @@ struct bulk_cs_wrap {
64/* CBI accept device specific command */ 64/* CBI accept device specific command */
65#define US_CBI_ADSC 0 65#define US_CBI_ADSC 0
66extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*); 66extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*);
67extern int usb_stor_Bulk_max_lun(struct us_data*); 67extern int usb_stor_Bulk_max_lun(struct us_data *);
68extern int usb_stor_Bulk_reset(struct us_data*); 68extern int usb_stor_Bulk_reset(struct us_data *);
69extern void usb_stor_print_cmd(struct scsi_cmnd *); 69extern void usb_stor_print_cmd(struct scsi_cmnd *);
70extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*); 70extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
71extern void usb_stor_stop_transport(struct us_data*); 71extern void usb_stor_stop_transport(struct us_data *);
72extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe, 72extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
73 u8 request, u8 requesttype, u16 value, u16 index, 73 u8 request, u8 requesttype, u16 value, u16 index,
74 void *data, u16 size, int timeout); 74 void *data, u16 size, int timeout);
@@ -77,23 +77,26 @@ extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
77 void *buf, unsigned int length, unsigned int *act_len); 77 void *buf, unsigned int length, unsigned int *act_len);
78extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe, 78extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
79 void *buf, unsigned int length, int use_sg, int *residual); 79 void *buf, unsigned int length, int use_sg, int *residual);
80extern int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe, 80extern int usb_stor_bulk_srb(struct us_data *us, unsigned int pipe,
81 struct scsi_cmnd* srb); 81 struct scsi_cmnd *srb);
82extern int usb_stor_port_reset(struct us_data *us); 82extern int usb_stor_port_reset(struct us_data *us);
83 83
84/* Protocol handling routines */ 84/* Protocol handling routines */
85enum xfer_buf_dir {TO_XFER_BUF, FROM_XFER_BUF}; 85enum xfer_buf_dir {TO_XFER_BUF, FROM_XFER_BUF};
86extern unsigned int usb_stor_access_xfer_buf(struct us_data*, unsigned char *buffer, 86extern unsigned int usb_stor_access_xfer_buf(struct us_data*,
87 unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **, 87 unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb,
88 unsigned int *offset, enum xfer_buf_dir dir); 88 struct scatterlist **, unsigned int *offset, enum xfer_buf_dir dir);
89extern void usb_stor_set_xfer_buf(struct us_data*, unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb, 89extern void usb_stor_set_xfer_buf(struct us_data*, unsigned char *buffer,
90 unsigned int buflen, struct scsi_cmnd *srb,
90 unsigned int dir); 91 unsigned int dir);
91 92
92// ENE scsi function 93/*
93extern void ENE_stor_invoke_transport(struct scsi_cmnd *, struct us_data*); 94 * ENE scsi function
94extern int ENE_InitMedia(struct us_data*); 95 */
95extern int ENE_MSInit(struct us_data*); 96extern void ENE_stor_invoke_transport(struct scsi_cmnd *, struct us_data *);
96extern int ENE_SMInit(struct us_data*); 97extern int ENE_InitMedia(struct us_data *);
98extern int ENE_MSInit(struct us_data *);
99extern int ENE_SMInit(struct us_data *);
97extern int ENE_SendScsiCmd(struct us_data*, BYTE, void*, int); 100extern int ENE_SendScsiCmd(struct us_data*, BYTE, void*, int);
98extern int ENE_LoadBinCode(struct us_data*, BYTE); 101extern int ENE_LoadBinCode(struct us_data*, BYTE);
99extern int ENE_Read_BYTE(struct us_data*, WORD index, void *buf); 102extern int ENE_Read_BYTE(struct us_data*, WORD index, void *buf);
@@ -101,35 +104,51 @@ extern int ENE_Read_Data(struct us_data*, void *buf, unsigned int length);
101extern int ENE_Write_Data(struct us_data*, void *buf, unsigned int length); 104extern int ENE_Write_Data(struct us_data*, void *buf, unsigned int length);
102extern void BuildSenseBuffer(struct scsi_cmnd *, int); 105extern void BuildSenseBuffer(struct scsi_cmnd *, int);
103 106
104// ENE scsi function 107/*
108 * ENE scsi function
109 */
105extern int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb); 110extern int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
106extern int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb); 111extern int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
107 112
108// ENE MS function 113/*
109extern int MS_CardInit(struct us_data *us); 114 * ENE MS function
115 */
116extern int MS_CardInit(struct us_data *us);
110extern void MS_LibFreeAllocatedArea(struct us_data *us); 117extern void MS_LibFreeAllocatedArea(struct us_data *us);
111extern void MS_LibFreeWriteBuf(struct us_data *us); 118extern void MS_LibFreeWriteBuf(struct us_data *us);
112extern int MS_LibFreeLogicalMap(struct us_data *us); 119extern int MS_LibFreeLogicalMap(struct us_data *us);
113extern int MS_LibForceSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk); 120extern int MS_LibForceSetLogicalPair(struct us_data *us, WORD logblk,
114extern int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, DWORD *PageBuf, MS_LibTypeExtdat *ExtraDat); 121 WORD phyblk);
115extern int MS_ReaderCopyBlock(struct us_data *us, WORD oldphy, WORD newphy, WORD PhyBlockAddr, BYTE PageNum, PBYTE buf, WORD len); 122extern int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr,
123 BYTE PageNum, DWORD *PageBuf,
124 MS_LibTypeExtdat *ExtraDat);
125extern int MS_ReaderCopyBlock(struct us_data *us, WORD oldphy,
126 WORD newphy, WORD PhyBlockAddr,
127 BYTE PageNum, PBYTE buf, WORD len);
116extern int MS_ReaderEraseBlock(struct us_data *us, DWORD PhyBlockAddr); 128extern int MS_ReaderEraseBlock(struct us_data *us, DWORD PhyBlockAddr);
117extern int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData); 129extern int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock,
130 BYTE *PageData);
118extern int MS_LibAllocLogicalMap(struct us_data *us); 131extern int MS_LibAllocLogicalMap(struct us_data *us);
119extern int MS_LibSetBootBlockMark(struct us_data *us, WORD phyblk); 132extern int MS_LibSetBootBlockMark(struct us_data *us, WORD phyblk);
120extern int MS_LibSetLogicalBlockMark(struct us_data *us, WORD phyblk, WORD mark); 133extern int MS_LibSetLogicalBlockMark(struct us_data *us, WORD phyblk,
134 WORD mark);
121extern int MS_LibSetInitialErrorBlock(struct us_data *us, WORD phyblk); 135extern int MS_LibSetInitialErrorBlock(struct us_data *us, WORD phyblk);
122extern int MS_LibScanLogicalBlockNumber(struct us_data *us, WORD phyblk); 136extern int MS_LibScanLogicalBlockNumber(struct us_data *us, WORD phyblk);
123extern int MS_LibAllocWriteBuf(struct us_data *us); 137extern int MS_LibAllocWriteBuf(struct us_data *us);
124void MS_LibClearWriteBuf(struct us_data *us); 138void MS_LibClearWriteBuf(struct us_data *us);
125void MS_LibPhy2LogRange(WORD PhyBlock, WORD *LogStart, WORD *LogEnde); 139void MS_LibPhy2LogRange(WORD PhyBlock, WORD *LogStart,
126extern int MS_LibReadExtra(struct us_data *us, DWORD PhyBlock, BYTE PageNum, MS_LibTypeExtdat *ExtraDat); 140 WORD *LogEnde);
127extern int MS_LibReadExtraBlock(struct us_data *us, DWORD PhyBlock, BYTE PageNum, BYTE blen, void *buf); 141extern int MS_LibReadExtra(struct us_data *us, DWORD PhyBlock,
142 BYTE PageNum, MS_LibTypeExtdat *ExtraDat);
143extern int MS_LibReadExtraBlock(struct us_data *us, DWORD PhyBlock,
144 BYTE PageNum, BYTE blen, void *buf);
128extern int MS_LibSetAcquiredErrorBlock(struct us_data *us, WORD phyblk); 145extern int MS_LibSetAcquiredErrorBlock(struct us_data *us, WORD phyblk);
129extern int MS_LibErasePhyBlock(struct us_data *us, WORD phyblk); 146extern int MS_LibErasePhyBlock(struct us_data *us, WORD phyblk);
130extern int MS_LibErrorPhyBlock(struct us_data *us, WORD phyblk); 147extern int MS_LibErrorPhyBlock(struct us_data *us, WORD phyblk);
131extern int MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, BYTE OverwriteFlag); 148extern int MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr,
132extern int MS_LibSetLogicalPair(struct us_data *us, WORD logblk, WORD phyblk); 149 BYTE PageNum, BYTE OverwriteFlag);
150extern int MS_LibSetLogicalPair(struct us_data *us,
151 WORD logblk, WORD phyblk);
133extern int MS_LibCheckDisableBlock(struct us_data *us, WORD PhyBlock); 152extern int MS_LibCheckDisableBlock(struct us_data *us, WORD PhyBlock);
134extern int MS_CountFreeBlock(struct us_data *us, WORD PhyBlock); 153extern int MS_CountFreeBlock(struct us_data *us, WORD PhyBlock);
135extern int MS_LibSearchBlockFromLogical(struct us_data *us, WORD logblk); 154extern int MS_LibSearchBlockFromLogical(struct us_data *us, WORD logblk);