1 /* 2 * scsi.h Copyright (C) 1992 Drew Eckhardt 3 * generic SCSI package header file by 4 * Drew Eckhardt 5 * 6 * <drew@colorado.edu> 7 * 8 * Modified by Eric Youngdale eric@tantalus.nrl.navy.mil to 9 * add scatter-gather, multiple outstanding request, and other 10 * enhancements. 11 */ 12
13 #ifndef_SCSI_H 14 #define_SCSI_H 15
16 /* 17 $Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/scsi.h,v 1.3 1993/09/24 12:20:33 drew Exp $ 18
19 For documentation on the OPCODES, MESSAGES, and SENSE values, 20 please consult the SCSI standard. 21
22 */ 23
24 /* 25 * SCSI opcodes 26 */ 27
28 #defineTEST_UNIT_READY 0x00
29 #defineREZERO_UNIT 0x01
30 #defineREQUEST_SENSE 0x03
31 #defineFORMAT_UNIT 0x04
32 #defineREAD_BLOCK_LIMITS 0x05
33 #defineREASSIGN_BLOCKS 0x07
34 #defineREAD_6 0x08
35 #defineWRITE_6 0x0a
36 #defineSEEK_6 0x0b
37 #define READ_REVERSE 0x0f
38 #defineWRITE_FILEMARKS 0x10
39 #defineSPACE 0x11
40 #defineINQUIRY 0x12
41 #define RECOVER_BUFFERED_DATA 0x14
42 #defineMODE_SELECT 0x15
43 #defineRESERVE 0x16
44 #define RELEASE 0x17
45 #defineCOPY 0x18
46 #defineERASE 0x19
47 #defineMODE_SENSE 0x1a
48 #defineSTART_STOP 0x1b
49 #define RECEIVE_DIAGNOSTIC 0x1c
50 #defineSEND_DIAGNOSTIC 0x1d
51 #defineALLOW_MEDIUM_REMOVAL 0x1e
52
53 #defineSET_WINDOW 0x24
54 #defineREAD_CAPACITY 0x25
55 #defineREAD_10 0x28
56 #defineWRITE_10 0x2a
57 #defineSEEK_10 0x2b
58 #defineWRITE_VERIFY 0x2e
59 #define VERIFY 0x2f
60 #defineSEARCH_HIGH 0x30
61 #defineSEARCH_EQUAL 0x31
62 #defineSEARCH_LOW 0x32
63 #define SET_LIMITS 0x33
64 #define PRE_FETCH 0x34
65 #defineREAD_POSITION 0x34
66 #define SYNCHRONIZE_CACHE 0x35
67 #define LOCK_UNLOCK_CACHE 0x36
68 #define READ_DEFECT_DATA 0x37
69 #defineMEDIUM_SCAN 0x38
70 #defineCOMPARE 0x39
71 #defineCOPY_VERIFY 0x3a
72 #defineWRITE_BUFFER 0x3b
73 #define READ_BUFFER 0x3c
74 #defineUPDATE_BLOCK 0x3d
75 #define READ_LONG 0x3e
76 #defineWRITE_LONG 0x3f
77 #defineCHANGE_DEFINITION 0x40
78 #defineWRITE_SAME 0x41
79 #defineLOG_SELECT 0x4c
80 #defineLOG_SENSE 0x4d
81 #defineMODE_SELECT_10 0x55
82 #defineMODE_SENSE_10 0x5a
83 #defineREAD_12 0xa8
84 #defineWRITE_12 0xaa
85 #defineWRITE_VERIFY_12 0xae
86 #defineSEARCH_HIGH_12 0xb0
87 #defineSEARCH_EQUAL_12 0xb1
88 #defineSEARCH_LOW_12 0xb2
89 #defineSEND_VOLUME_TAG 0xb6
90 #define WRITE_LONG_2 0xea
91
92 externvoidscsi_make_blocked_list(void);
93 externvolatileintin_scan_scsis;
94 externconstunsignedcharscsi_command_size[8];
95 #defineCOMMAND_SIZE(opcode) scsi_command_size[((opcode) >> 5) & 7]
96
97 /* 98 * MESSAGE CODES 99 */ 100
101 #defineCOMMAND_COMPLETE 0x00
102 #defineEXTENDED_MESSAGE 0x01
103 #defineEXTENDED_MODIFY_DATA_POINTER 0x00
104 #defineEXTENDED_SDTR 0x01
105 #defineEXTENDED_EXTENDED_IDENTIFY 0x02 /* SCSI-I only */ 106 #defineEXTENDED_WDTR 0x03
107 #defineSAVE_POINTERS 0x02
108 #defineRESTORE_POINTERS 0x03
109 #defineDISCONNECT 0x04
110 #define INITIATOR_ERROR 0x05
111 #defineABORT 0x06
112 #defineMESSAGE_REJECT 0x07
113 #defineNOP 0x08
114 #define MSG_PARITY_ERROR 0x09
115 #defineLINKED_CMD_COMPLETE 0x0a
116 #defineLINKED_FLG_CMD_COMPLETE 0x0b
117 #defineBUS_DEVICE_RESET 0x0c
118
119 #defineINITIATE_RECOVERY 0x0f /* SCSI-II only */ 120 #define RELEASE_RECOVERY 0x10 /* SCSI-II only */ 121
122 #defineSIMPLE_QUEUE_TAG 0x20
123 #defineHEAD_OF_QUEUE_TAG 0x21
124 #defineORDERED_QUEUE_TAG 0x22
125
126 #defineIDENTIFY_BASE 0x80
127 #defineIDENTIFY(can_disconnect, lun) (IDENTIFY_BASE |\
128 ((can_disconnect) ? 0x40 : 0) |\
129 ((lun) & 0x07))
130
131
132 /* 133 * Status codes 134 */ 135
136 #defineGOOD 0x00
137 #defineCHECK_CONDITION 0x01
138 #defineCONDITION_GOOD 0x02
139 #defineBUSY 0x04
140 #defineINTERMEDIATE_GOOD 0x08
141 #defineINTERMEDIATE_C_GOOD 0x0a
142 #defineRESERVATION_CONFLICT 0x0c
143 #defineQUEUE_FULL 0x1a
144
145 #defineSTATUS_MASK 0x1e
146
147 /* 148 * the return of the status word will be in the following format : 149 * The low byte is the status returned by the SCSI command, 150 * with vendor specific bits masked. 151 * 152 * The next byte is the message which followed the SCSI status. 153 * This allows a stos to be used, since the Intel is a little 154 * endian machine. 155 * 156 * The final byte is a host return code, which is one of the following. 157 * 158 * IE 159 * lsb msb 160 * status msg host code 161 * 162 * Our errors returned by OUR driver, NOT SCSI message. Or'd with 163 * SCSI message passed back to driver <IF any>. 164 */ 165
166
167 #defineDID_OK 0x00 /* NO error */ 168 #defineDID_NO_CONNECT 0x01 /* Couldn't connect before timeout period */ 169 #defineDID_BUS_BUSY 0x02 /* BUS stayed busy through time out period */ 170 #defineDID_TIME_OUT 0x03 /* TIMED OUT for other reason */ 171 #defineDID_BAD_TARGET 0x04 /* BAD target. */ 172 #defineDID_ABORT 0x05 /* Told to abort for some other reason */ 173 #defineDID_PARITY 0x06 /* Parity error */ 174 #defineDID_ERROR 0x07 /* Internal error */ 175 #defineDID_RESET 0x08 /* Reset by somebody. */ 176 #defineDID_BAD_INTR 0x09 /* Got an interrupt we weren't expecting. */ 177 #defineDRIVER_OK 0x00 /* Driver status */ 178
179 /* 180 * These indicate the error that occurred, and what is available. 181 */ 182
183 #define DRIVER_BUSY 0x01
184 #defineDRIVER_SOFT 0x02
185 #define DRIVER_MEDIA 0x03
186 #defineDRIVER_ERROR 0x04
187
188 #defineDRIVER_INVALID 0x05
189 #defineDRIVER_TIMEOUT 0x06
190 #defineDRIVER_HARD 0x07
191
192 #defineSUGGEST_RETRY 0x10
193 #defineSUGGEST_ABORT 0x20
194 #defineSUGGEST_REMAP 0x30
195 #defineSUGGEST_DIE 0x40
196 #defineSUGGEST_SENSE 0x80
197 #defineSUGGEST_IS_OK 0xff
198
199 #defineDRIVER_SENSE 0x08
200
201 #define DRIVER_MASK 0x0f
202 #defineSUGGEST_MASK 0xf0
203
204 /* 205 * SENSE KEYS 206 */ 207
208 #defineNO_SENSE 0x00
209 #defineRECOVERED_ERROR 0x01
210 #defineNOT_READY 0x02
211 #defineMEDIUM_ERROR 0x03
212 #defineHARDWARE_ERROR 0x04
213 #defineILLEGAL_REQUEST 0x05
214 #defineUNIT_ATTENTION 0x06
215 #defineDATA_PROTECT 0x07
216 #defineBLANK_CHECK 0x08
217 #defineCOPY_ABORTED 0x0a
218 #defineABORTED_COMMAND 0x0b
219 #defineVOLUME_OVERFLOW 0x0d
220 #defineMISCOMPARE 0x0e
221
222
223 /* 224 * DEVICE TYPES 225 */ 226
227 #defineTYPE_DISK 0x00
228 #defineTYPE_TAPE 0x01
229 #defineTYPE_PROCESSOR 0x03 /* HP scanners use this */ 230 #defineTYPE_WORM 0x04 /* Treated as ROM by our system */ 231 #defineTYPE_ROM 0x05
232 #defineTYPE_SCANNER 0x06
233 #defineTYPE_MOD 0x07 /* Magneto-optical disk - 234 * - treated as TYPE_DISK */ 235 #define TYPE_NO_LUN 0x7f
236
237
238 #defineMAX_COMMAND_SIZE 12
239
240 /* 241 * SCSI command sets 242 */ 243
244 #define SCSI_UNKNOWN 0
245 #define SCSI_1 1
246 #define SCSI_1_CCS 2
247 #defineSCSI_2 3
248
249 /* 250 * Every SCSI command starts with a one byte OP-code. 251 * The next byte's high three bits are the LUN of the 252 * device. Any multi-byte quantities are stored high byte 253 * first, and may have a 5 bit MSB in the same byte 254 * as the LUN. 255 */ 256
257 /* 258 * Manufacturers list 259 */ 260
261 #defineSCSI_MAN_UNKNOWN 0
262 #defineSCSI_MAN_NEC 1
263 #defineSCSI_MAN_TOSHIBA 2
264 #defineSCSI_MAN_NEC_OLDCDR 3
265 #defineSCSI_MAN_SONY 4
266
267 /* 268 * As the scsi do command functions are intelligent, and may need to 269 * redo a command, we need to keep track of the last command 270 * executed on each one. 271 */ 272
273 #defineWAS_RESET 0x01
274 #defineWAS_TIMEDOUT 0x02
275 #defineWAS_SENSE 0x04
276 #defineIS_RESETTING 0x08
277 #define IS_ABORTING 0x10
278 #defineASKED_FOR_SENSE 0x20
279
280 /* 281 * The scsi_device struct contains what we know about each given scsi 282 * device. 283 */ 284
285 typedefstructscsi_device{ 286 structscsi_device * next; /* Used for linked list */ 287
288 unsignedcharid, lun, channel;
289
290 unsignedintmanufacturer; /* Manufacturer of device, for using 291 * vendor-specific cmd's */ 292 intattached; /* # of high level drivers attached to 293 * this */ 294 intaccess_count; /* Count of open channels/mounts */ 295 structwait_queue * device_wait;/* Used to wait if device is busy */ 296 structScsi_Host * host;
297 void (*scsi_request_fn)(void); /* Used to jumpstart things after an 298 * ioctl */ 299 void *hostdata; /* available to low-level driver */ 300 chartype;
301 charscsi_level;
302 charvendor[8], model[16], rev[4];
303 unsignedwriteable:1;
304 unsignedremovable:1;
305 unsignedrandom:1;
306 unsignedhas_cmdblocks:1;
307 unsignedchanged:1; /* Data invalid due to media change */ 308 unsignedbusy:1; /* Used to prevent races */ 309 unsignedlockable:1; /* Able to prevent media removal */ 310 unsignedborken:1; /* Tell the Seagate driver to be 311 * painfully slow on this device */ 312 unsignedtagged_supported:1; /* Supports SCSI-II tagged queuing */ 313 unsignedtagged_queue:1; /* SCSI-II tagged queuing enabled */ 314 unsigneddisconnect:1; /* can disconnect */ 315 unsignedsoft_reset:1; /* Uses soft reset option */ 316 unsignedsync:1; /* Negotiate for sync transfers */ 317 unsignedsingle_lun:1; /* Indicates we should only allow I/O to 318 one of the luns for the device at a time. */ 319 unsignedcharcurrent_tag; /* current tag */ 320 unsignedchar sync_min_period; /* Not less than this period */ 321 unsignedchar sync_max_offset; /* Not greater than this offset */ 322 }Scsi_Device;
323
324 /* 325 * Use these to separate status msg and our bytes 326 */ 327
328 #definestatus_byte(result) (((result) >> 1) & 0xf)
329 #definemsg_byte(result) (((result) >> 8) & 0xff)
330 #definehost_byte(result) (((result) >> 16) & 0xff)
331 #definedriver_byte(result) (((result) >> 24) & 0xff)
332 #definesuggestion(result) (driver_byte(result) & SUGGEST_MASK)
333
334 #definesense_class(sense) (((sense) >> 4) & 0x7)
335 #definesense_error(sense) ((sense) & 0xf)
336 #define sense_valid(sense) ((sense) & 0x80);
337
338 /* 339 * These are the SCSI devices available on the system. 340 */ 341
342 externScsi_Device * scsi_devices;
343
344 /* 345 * Initializes all SCSI devices. This scans all scsi busses. 346 */ 347
348 externunsignedlongscsi_dev_init (unsignedlong, unsignedlong);
349
350 structscatterlist{ 351 char * address; /* Location data is to be transferred to */ 352 char * alt_address; /* Location of actual if address is a 353 * dma indirect buffer. NULL otherwise */ 354 unsignedintlength;
355 };
356
357 #ifdef__alpha__ 358 # defineISA_DMA_THRESHOLD (~0UL)
359 #else 360 # defineISA_DMA_THRESHOLD (0x00ffffff)
361 #endif 362 #defineCONTIGUOUS_BUFFERS(X,Y) ((X->b_data+X->b_size) == Y->b_data)
363
364
365 /* 366 * These are the return codes for the abort and reset functions. The mid-level 367 * code uses these to decide what to do next. Each of the low level abort 368 * and reset functions must correctly indicate what it has done. 369 */ 370
371 /* We did not do anything. 372 * Wait some more for this command to complete, and if this does not work, 373 * try something more serious. */ 374 #defineSCSI_ABORT_SNOOZE 0
375
376 /* This means that we were able to abort the command. We have already 377 * called the mid-level done function, and do not expect an interrupt that 378 * will lead to another call to the mid-level done function for this command */ 379 #defineSCSI_ABORT_SUCCESS 1
380
381 /* We called for an abort of this command, and we should get an interrupt 382 * when this succeeds. Thus we should not restore the timer for this 383 * command in the mid-level abort function. */ 384 #defineSCSI_ABORT_PENDING 2
385
386 /* Unable to abort - command is currently on the bus. Grin and bear it. */ 387 #defineSCSI_ABORT_BUSY 3
388
389 /* The command is not active in the low level code. Command probably 390 * finished. */ 391 #defineSCSI_ABORT_NOT_RUNNING 4
392
393 /* Something went wrong. The low level driver will indicate the correct 394 * error condition when it calls scsi_done, so the mid-level abort function 395 * can simply wait until this comes through */ 396 #defineSCSI_ABORT_ERROR 5
397
398 /* We do not know how to reset the bus, or we do not want to. Bummer. 399 * Anyway, just wait a little more for the command in question, and hope that 400 * it eventually finishes. If it never finishes, the SCSI device could 401 * hang, so use this with caution. */ 402 #defineSCSI_RESET_SNOOZE 0
403
404 /* We do not know how to reset the bus, or we do not want to. Bummer. 405 * We have given up on this ever completing. The mid-level code will 406 * request sense information to decide how to proceed from here. */ 407 #defineSCSI_RESET_PUNT 1
408
409 /* This means that we were able to reset the bus. We have restarted all of 410 * the commands that should be restarted, and we should be able to continue 411 * on normally from here. We do not expect any interrupts that will return 412 * DID_RESET to any of the other commands in the host_queue, and the mid-level 413 * code does not need to do anything special to keep the commands alive. */ 414 #defineSCSI_RESET_SUCCESS 2
415
416 /* We called for a reset of this bus, and we should get an interrupt 417 * when this succeeds. Each command should get its own status 418 * passed up to scsi_done, but this has not happened yet. */ 419 #defineSCSI_RESET_PENDING 3
420
421 /* We did a reset, but do not expect an interrupt to signal DID_RESET. 422 * This tells the upper level code to request the sense info, and this 423 * should keep the command alive. */ 424 #defineSCSI_RESET_WAKEUP 4
425
426 /* Something went wrong, and we do not know how to fix it. */ 427 #defineSCSI_RESET_ERROR 5
428
429 void * scsi_malloc(unsignedint);
430 intscsi_free(void *, unsignedint);
431 externunsignedintdma_free_sectors; /* How much room do we have left */ 432 externunsignedintneed_isa_buffer; /* True if some devices need indirection 433 * buffers */ 434
435 /* 436 * The Scsi_Cmnd structure is used by scsi.c internally, and for communication 437 * with low level drivers that support multiple outstanding commands. 438 */ 439 typedefstruct scsi_pointer { 440 char * ptr; /* data pointer */ 441 intthis_residual; /* left in this buffer */ 442 structscatterlist *buffer; /* which buffer */ 443 intbuffers_residual; /* how many buffers left */ 444
445 volatileintStatus;
446 volatileintMessage;
447 volatileinthave_data_in;
448 volatileintsent_command;
449 volatileintphase;
450 }Scsi_Pointer;
451
452 typedefstructscsi_cmnd{ 453 structScsi_Host * host;
454 Scsi_Device * device;
455 unsignedchartarget, lun, channel;
456 unsignedcharcmd_len;
457 unsignedcharold_cmd_len;
458 structscsi_cmnd *next, *prev;
459
460 /* These elements define the operation we are about to perform */ 461 unsignedcharcmnd[12];
462 unsignedrequest_bufflen; /* Actual request size */ 463
464 void * request_buffer; /* Actual requested buffer */ 465
466 /* These elements define the operation we ultimately want to perform */ 467 unsignedchardata_cmnd[12];
468 unsignedshortold_use_sg; /* We save use_sg here when requesting 469 * sense info */ 470 unsignedshortuse_sg; /* Number of pieces of scatter-gather */ 471 unsignedshortsglist_len; /* size of malloc'd scatter-gather list */ 472 unsignedshortabort_reason;/* If the mid-level code requests an 473 * abort, this is the reason. */ 474 unsignedbufflen; /* Size of data buffer */ 475 void *buffer; /* Data buffer */ 476
477 unsignedunderflow; /* Return error if less than this amount is 478 * transfered */ 479
480 unsignedtransfersize; /* How much we are guaranteed to transfer with 481 * each SCSI transfer (ie, between disconnect / 482 * reconnects. Probably == sector size */ 483
484
485 structrequestrequest; /* A copy of the command we are working on */ 486
487 unsignedcharsense_buffer[16]; /* Sense for this command, if needed */ 488
489
490 intretries;
491 intallowed;
492 inttimeout_per_command, timeout_total, timeout;
493
494 /* 495 * We handle the timeout differently if it happens when a reset, 496 * abort, etc are in process. 497 */ 498 unsignedvolatilecharinternal_timeout;
499
500 unsignedflags;
501
502 /* These variables are for the cdrom only. Once we have variable size 503 * buffers in the buffer cache, they will go away. */ 504 intthis_count;
505 /* End of special cdrom variables */ 506
507 /* Low-level done function - can be used by low-level driver to point 508 * to completion function. Not used by mid/upper level code. */ 509 void (*scsi_done)(structscsi_cmnd *);
510 void (*done)(structscsi_cmnd *); /* Mid-level done function */ 511
512 /* 513 * The following fields can be written to by the host specific code. 514 * Everything else should be left alone. 515 */ 516
517 Scsi_PointerSCp; /* Scratchpad used by some host adapters */ 518
519 unsignedchar * host_scribble; /* The host adapter is allowed to 520 * call scsi_malloc and get some memory 521 * and hang it here. The host adapter 522 * is also expected to call scsi_free 523 * to release this memory. (The memory 524 * obtained by scsi_malloc is guaranteed 525 * to be at an address < 16Mb). */ 526
527 intresult; /* Status code from lower level driver */ 528
529 unsignedchartag; /* SCSI-II queued command tag */ 530 unsignedlongpid; /* Process ID, starts at 0 */ 531 }Scsi_Cmnd;
532
533 /* 534 * scsi_abort aborts the current command that is executing on host host. 535 * The error code, if non zero is returned in the host byte, otherwise 536 * DID_ABORT is returned in the hostbyte. 537 */ 538
539 externintscsi_abort (Scsi_Cmnd *, intcode, intpid);
540
541 externvoidscsi_do_cmd (Scsi_Cmnd *, constvoid *cmnd ,
542 void *buffer, unsignedbufflen,
543 void (*done)(structscsi_cmnd *),
544 inttimeout, intretries);
545
546
547 externScsi_Cmnd * allocate_device(structrequest **, Scsi_Device *, int);
548
549 externScsi_Cmnd * request_queueable(structrequest *, Scsi_Device *);
550 externintscsi_reset (Scsi_Cmnd *);
551
552 externintmax_scsi_hosts;
553
554 externvoidbuild_proc_dir_entries(void);
555
556 externintkernel_scsi_ioctl (Scsi_Device *dev, intcmd, void *arg);
557 externintscsi_ioctl (Scsi_Device *dev, intcmd, void *arg);
558 externvoidprint_command(unsignedchar *);
559 externvoidprint_sense(char *, Scsi_Cmnd *);
560
561
562 #ifdefined(MAJOR_NR) && (MAJOR_NR != SCSI_TAPE_MAJOR)
563 #include "hosts.h"
564
565 staticScsi_Cmnd * end_scsi_request(Scsi_Cmnd * SCpnt, intuptodate, intsectors)
/* */ 566 { 567 structrequest * req;
568 structbuffer_head * bh;
569
570 req = &SCpnt->request;
571 req->errors = 0;
572 if (!uptodate) { 573 printk(DEVICE_NAME " I/O error: dev %04x, sector %lu\n",
574 req->dev,req->sector);
575 } 576
577 do{ 578 if ((bh = req->bh) != NULL) { 579 req->bh = bh->b_reqnext;
580 req->nr_sectors -= bh->b_size >> 9;
581 req->sector += bh->b_size >> 9;
582 bh->b_reqnext = NULL;
583 bh->b_uptodate = uptodate;
584 unlock_buffer(bh);
585 sectors -= bh->b_size >> 9;
586 if ((bh = req->bh) != NULL) { 587 req->current_nr_sectors = bh->b_size >> 9;
588 if (req->nr_sectors < req->current_nr_sectors) { 589 req->nr_sectors = req->current_nr_sectors;
590 printk("end_scsi_request: buffer-list destroyed\n");
591 } 592 } 593 } 594 }while(sectors && bh);
595 if (req->bh){ 596 req->buffer = bh->b_data;
597 returnSCpnt;
598 };
599 DEVICE_OFF(req->dev);
600 if (req->sem != NULL) { 601 up(req->sem);
602 } 603
604 if (SCpnt->host->block) { 605 structScsi_Host * next;
606
607 for (next = SCpnt->host->block; next != SCpnt->host;
608 next = next->block)
609 wake_up(&next->host_wait);
610 } 611
612 req->dev = -1;
613 wake_up(&wait_for_request);
614 wake_up(&SCpnt->device->device_wait);
615 returnNULL;
616 } 617
618
619 /* This is just like INIT_REQUEST, but we need to be aware of the fact 620 * that an interrupt may start another request, so we run this with interrupts 621 * turned off 622 */ 623 #defineINIT_SCSI_REQUEST \
624 if (!CURRENT) {\
625 CLEAR_INTR; \
626 restore_flags(flags); \
627 return; \
628 } \
629 if (MAJOR(CURRENT->dev) != MAJOR_NR) \
630 panic(DEVICE_NAME ": request list destroyed"); \
631 if (CURRENT->bh) { \
632 if (!CURRENT->bh->b_lock) \
633 panic(DEVICE_NAME ": block not locked"); \
634 } 635 #endif 636
637 #defineSCSI_SLEEP(QUEUE, CONDITION) { \
638 if (CONDITION) { \
639 structwait_queuewait = {current, NULL}; \
640 add_wait_queue(QUEUE, &wait); \
641 for(;;) { \
642 current->state = TASK_UNINTERRUPTIBLE; \
643 if (CONDITION) { \
644 if (intr_count) \
645 panic("scsi: trying to call schedule() in interrupt" \
646 ", file %s, line %d.\n", __FILE__, __LINE__); \
647 schedule(); \
648 } \
649 else \
650 break; \
651 } \
652 remove_wait_queue(QUEUE, &wait); \
653 current->state = TASK_RUNNING; \
654 }; } 655
656 #endif 657
658 /* 659 * Overrides for Emacs so that we follow Linus's tabbing style. 660 * Emacs will notice this stuff at the end of the file and automatically 661 * adjust the settings for this buffer only. This must remain at the end 662 * of the file. 663 * --------------------------------------------------------------------------- 664 * Local variables: 665 * c-indent-level: 4 666 * c-brace-imaginary-offset: 0 667 * c-brace-offset: -4 668 * c-argdecl-indent: 4 669 * c-label-offset: -4 670 * c-continued-statement-offset: 4 671 * c-continued-brace-offset: 0 672 * indent-tabs-mode: nil 673 * tab-width: 8 674 * End: 675 */