root/drivers/scsi/scsi.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. end_scsi_request

   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 #define TEST_UNIT_READY       0x00
  29 #define REZERO_UNIT           0x01
  30 #define REQUEST_SENSE         0x03
  31 #define FORMAT_UNIT           0x04
  32 #define READ_BLOCK_LIMITS     0x05
  33 #define REASSIGN_BLOCKS       0x07
  34 #define READ_6                0x08
  35 #define WRITE_6               0x0a
  36 #define SEEK_6                0x0b
  37 #define READ_REVERSE          0x0f
  38 #define WRITE_FILEMARKS       0x10
  39 #define SPACE                 0x11
  40 #define INQUIRY               0x12
  41 #define RECOVER_BUFFERED_DATA 0x14
  42 #define MODE_SELECT           0x15
  43 #define RESERVE               0x16
  44 #define RELEASE               0x17
  45 #define COPY                  0x18
  46 #define ERASE                 0x19
  47 #define MODE_SENSE            0x1a
  48 #define START_STOP            0x1b
  49 #define RECEIVE_DIAGNOSTIC    0x1c
  50 #define SEND_DIAGNOSTIC       0x1d
  51 #define ALLOW_MEDIUM_REMOVAL  0x1e
  52 
  53 #define SET_WINDOW            0x24
  54 #define READ_CAPACITY         0x25
  55 #define READ_10               0x28
  56 #define WRITE_10              0x2a
  57 #define SEEK_10               0x2b
  58 #define WRITE_VERIFY          0x2e
  59 #define VERIFY                0x2f
  60 #define SEARCH_HIGH           0x30
  61 #define SEARCH_EQUAL          0x31
  62 #define SEARCH_LOW            0x32
  63 #define SET_LIMITS            0x33
  64 #define PRE_FETCH             0x34
  65 #define READ_POSITION         0x34
  66 #define SYNCHRONIZE_CACHE     0x35
  67 #define LOCK_UNLOCK_CACHE     0x36
  68 #define READ_DEFECT_DATA      0x37
  69 #define MEDIUM_SCAN           0x38
  70 #define COMPARE               0x39
  71 #define COPY_VERIFY           0x3a
  72 #define WRITE_BUFFER          0x3b
  73 #define READ_BUFFER           0x3c
  74 #define UPDATE_BLOCK          0x3d
  75 #define READ_LONG             0x3e
  76 #define WRITE_LONG            0x3f
  77 #define CHANGE_DEFINITION     0x40
  78 #define WRITE_SAME            0x41
  79 #define LOG_SELECT            0x4c
  80 #define LOG_SENSE             0x4d
  81 #define MODE_SELECT_10        0x55
  82 #define MODE_SENSE_10         0x5a
  83 #define WRITE_12              0xaa
  84 #define WRITE_VERIFY_12       0xae
  85 #define SEARCH_HIGH_12        0xb0
  86 #define SEARCH_EQUAL_12       0xb1
  87 #define SEARCH_LOW_12         0xb2
  88 #define SEND_VOLUME_TAG       0xb6
  89 #define WRITE_LONG_2          0xea
  90 
  91 extern void scsi_make_blocked_list(void);
  92 extern volatile int in_scan_scsis;
  93 extern const unsigned char scsi_command_size[8];
  94 #define COMMAND_SIZE(opcode) scsi_command_size[((opcode) >> 5) & 7]
  95 
  96 /*
  97  *  MESSAGE CODES
  98  */
  99 
 100 #define COMMAND_COMPLETE    0x00
 101 #define EXTENDED_MESSAGE    0x01
 102 #define     EXTENDED_MODIFY_DATA_POINTER    0x00
 103 #define     EXTENDED_SDTR                   0x01
 104 #define     EXTENDED_EXTENDED_IDENTIFY      0x02    /* SCSI-I only */
 105 #define     EXTENDED_WDTR                   0x03
 106 #define SAVE_POINTERS       0x02
 107 #define RESTORE_POINTERS    0x03
 108 #define DISCONNECT          0x04
 109 #define INITIATOR_ERROR     0x05
 110 #define ABORT               0x06
 111 #define MESSAGE_REJECT      0x07
 112 #define NOP                 0x08
 113 #define MSG_PARITY_ERROR    0x09
 114 #define LINKED_CMD_COMPLETE 0x0a
 115 #define LINKED_FLG_CMD_COMPLETE 0x0b
 116 #define BUS_DEVICE_RESET    0x0c
 117 
 118 #define INITIATE_RECOVERY   0x0f            /* SCSI-II only */
 119 #define RELEASE_RECOVERY    0x10            /* SCSI-II only */
 120 
 121 #define SIMPLE_QUEUE_TAG    0x20
 122 #define HEAD_OF_QUEUE_TAG   0x21
 123 #define ORDERED_QUEUE_TAG   0x22
 124 
 125 #define IDENTIFY_BASE       0x80
 126 #define IDENTIFY(can_disconnect, lun)   (IDENTIFY_BASE |\
 127                      ((can_disconnect) ?  0x40 : 0) |\
 128                      ((lun) & 0x07)) 
 129 
 130                  
 131 /*
 132  *  Status codes
 133  */
 134 
 135 #define GOOD                 0x00
 136 #define CHECK_CONDITION      0x01
 137 #define CONDITION_GOOD       0x02
 138 #define BUSY                 0x04
 139 #define INTERMEDIATE_GOOD    0x08
 140 #define INTERMEDIATE_C_GOOD  0x0a
 141 #define RESERVATION_CONFLICT 0x0c
 142 #define QUEUE_FULL           0x1a
 143 
 144 #define STATUS_MASK          0x1e
 145     
 146 /*
 147  *  the return of the status word will be in the following format :
 148  *  The low byte is the status returned by the SCSI command, 
 149  *  with vendor specific bits masked.
 150  *  
 151  *  The next byte is the message which followed the SCSI status.
 152  *  This allows a stos to be used, since the Intel is a little
 153  *  endian machine.
 154  *  
 155  *  The final byte is a host return code, which is one of the following.
 156  *  
 157  *  IE 
 158  *  lsb     msb
 159  *  status  msg host code   
 160  *  
 161  *  Our errors returned by OUR driver, NOT SCSI message.  Or'd with
 162  *  SCSI message passed back to driver <IF any>.
 163  */
 164 
 165 
 166 #define DID_OK          0x00 /* NO error                                */
 167 #define DID_NO_CONNECT  0x01 /* Couldn't connect before timeout period  */
 168 #define DID_BUS_BUSY    0x02 /* BUS stayed busy through time out period */
 169 #define DID_TIME_OUT    0x03 /* TIMED OUT for other reason              */
 170 #define DID_BAD_TARGET  0x04 /* BAD target.                             */
 171 #define DID_ABORT       0x05 /* Told to abort for some other reason     */
 172 #define DID_PARITY      0x06 /* Parity error                            */
 173 #define DID_ERROR       0x07 /* Internal error                          */
 174 #define DID_RESET       0x08 /* Reset by somebody.                      */
 175 #define DID_BAD_INTR    0x09 /* Got an interrupt we weren't expecting.  */ 
 176 #define DRIVER_OK       0x00 /* Driver status                           */ 
 177 
 178 /*
 179  *  These indicate the error that occurred, and what is available.
 180  */
 181 
 182 #define DRIVER_BUSY         0x01
 183 #define DRIVER_SOFT         0x02
 184 #define DRIVER_MEDIA        0x03
 185 #define DRIVER_ERROR        0x04    
 186 
 187 #define DRIVER_INVALID      0x05
 188 #define DRIVER_TIMEOUT      0x06
 189 #define DRIVER_HARD         0x07
 190 
 191 #define SUGGEST_RETRY       0x10
 192 #define SUGGEST_ABORT       0x20 
 193 #define SUGGEST_REMAP       0x30
 194 #define SUGGEST_DIE         0x40
 195 #define SUGGEST_SENSE       0x80
 196 #define SUGGEST_IS_OK       0xff
 197 
 198 #define DRIVER_SENSE        0x08
 199 
 200 #define DRIVER_MASK         0x0f
 201 #define SUGGEST_MASK        0xf0
 202 
 203 /*
 204  *  SENSE KEYS
 205  */
 206 
 207 #define NO_SENSE            0x00
 208 #define RECOVERED_ERROR     0x01
 209 #define NOT_READY           0x02
 210 #define MEDIUM_ERROR        0x03
 211 #define HARDWARE_ERROR      0x04
 212 #define ILLEGAL_REQUEST     0x05
 213 #define UNIT_ATTENTION      0x06
 214 #define DATA_PROTECT        0x07
 215 #define BLANK_CHECK         0x08
 216 #define COPY_ABORTED        0x0a
 217 #define ABORTED_COMMAND     0x0b
 218 #define VOLUME_OVERFLOW     0x0d
 219 #define MISCOMPARE          0x0e
 220 
 221 
 222 /*
 223  *  DEVICE TYPES
 224  */
 225 
 226 #define TYPE_DISK           0x00
 227 #define TYPE_TAPE           0x01
 228 #define TYPE_PROCESSOR      0x03    /* HP scanners use this */
 229 #define TYPE_WORM           0x04    /* Treated as ROM by our system */
 230 #define TYPE_ROM            0x05
 231 #define TYPE_SCANNER        0x06
 232 #define TYPE_MOD            0x07    /* Magneto-optical disk - 
 233                                      * - treated as TYPE_DISK */
 234 #define TYPE_NO_LUN         0x7f
 235 
 236 
 237 #define MAX_COMMAND_SIZE    12
 238 
 239 /*
 240  *  SCSI command sets
 241  */
 242 
 243 #define SCSI_UNKNOWN    0
 244 #define SCSI_1          1
 245 #define SCSI_1_CCS      2
 246 #define SCSI_2          3
 247 
 248 /*
 249  *  Every SCSI command starts with a one byte OP-code.
 250  *  The next byte's high three bits are the LUN of the
 251  *  device.  Any multi-byte quantities are stored high byte
 252  *  first, and may have a 5 bit MSB in the same byte
 253  *  as the LUN.
 254  */
 255 
 256 /*
 257  *      Manufacturers list
 258  */
 259 
 260 #define SCSI_MAN_UNKNOWN     0
 261 #define SCSI_MAN_NEC         1
 262 #define SCSI_MAN_TOSHIBA     2
 263 #define SCSI_MAN_NEC_OLDCDR  3
 264 
 265 /*
 266  *  As the scsi do command functions are intelligent, and may need to
 267  *  redo a command, we need to keep track of the last command
 268  *  executed on each one.
 269  */
 270 
 271 #define WAS_RESET       0x01
 272 #define WAS_TIMEDOUT    0x02
 273 #define WAS_SENSE       0x04
 274 #define IS_RESETTING    0x08
 275 #define IS_ABORTING     0x10
 276 #define ASKED_FOR_SENSE 0x20
 277 
 278 /*
 279  *  The scsi_device struct contains what we know about each given scsi
 280  *  device.
 281  */
 282 
 283 typedef struct scsi_device {
 284     struct scsi_device * next;      /* Used for linked list */
 285 
 286     unsigned char id, lun, channel;
 287 
 288     unsigned int manufacturer;      /* Manufacturer of device, for using 
 289                                      * vendor-specific cmd's */
 290     int attached;                   /* # of high level drivers attached to 
 291                                      * this */
 292     int access_count;               /* Count of open channels/mounts */
 293     struct wait_queue * device_wait;/* Used to wait if device is busy */
 294     struct Scsi_Host * host;
 295     void (*scsi_request_fn)(void);  /* Used to jumpstart things after an 
 296                                      * ioctl */
 297     void *hostdata;                 /* available to low-level driver */
 298     char type;
 299     char scsi_level;
 300     char vendor[8], model[16], rev[4];
 301     unsigned writeable:1;
 302     unsigned removable:1; 
 303     unsigned random:1;
 304     unsigned changed:1;             /* Data invalid due to media change */
 305     unsigned busy:1;                /* Used to prevent races */
 306     unsigned lockable:1;            /* Able to prevent media removal */
 307     unsigned borken:1;              /* Tell the Seagate driver to be 
 308                                      * painfully slow on this device */ 
 309     unsigned tagged_supported:1;    /* Supports SCSI-II tagged queuing */
 310     unsigned tagged_queue:1;        /* SCSI-II tagged queuing enabled */
 311     unsigned disconnect:1;          /* can disconnect */
 312     unsigned soft_reset:1;          /* Uses soft reset option */
 313     unsigned sync:1;                /* Negotiate for sync transfers */
 314     unsigned char current_tag;      /* current tag */
 315     unsigned char sync_min_period;  /* Not less than this period */
 316     unsigned char sync_max_offset;  /* Not greater than this offset */
 317 } Scsi_Device;
 318 
 319 /*
 320  *  Use these to separate status msg and our bytes
 321  */
 322 
 323 #define status_byte(result) (((result) >> 1) & 0xf)
 324 #define msg_byte(result)    (((result) >> 8) & 0xff)
 325 #define host_byte(result)   (((result) >> 16) & 0xff)
 326 #define driver_byte(result) (((result) >> 24) & 0xff)
 327 #define suggestion(result)  (driver_byte(result) & SUGGEST_MASK)
 328 
 329 #define sense_class(sense)  (((sense) >> 4) & 0x7)
 330 #define sense_error(sense)  ((sense) & 0xf)
 331 #define sense_valid(sense)  ((sense) & 0x80);
 332 
 333 /*
 334  *  These are the SCSI devices available on the system.
 335  */
 336 
 337 extern Scsi_Device * scsi_devices;
 338 
 339 /*
 340  *  Initializes all SCSI devices.  This scans all scsi busses.
 341  */ 
 342 
 343 extern unsigned long scsi_dev_init (unsigned long, unsigned long);
 344 
 345 struct scatterlist {
 346     char *  address;    /* Location data is to be transferred to */
 347     char * alt_address; /* Location of actual if address is a 
 348                          * dma indirect buffer.  NULL otherwise */
 349     unsigned int length;
 350 };
 351 
 352 #ifdef __alpha__
 353 # define ISA_DMA_THRESHOLD (~0UL)
 354 #else
 355 # define ISA_DMA_THRESHOLD (0x00ffffff)
 356 #endif
 357 #define CONTIGUOUS_BUFFERS(X,Y) ((X->b_data+X->b_size) == Y->b_data)
 358 
 359 
 360 /*
 361  * These are the return codes for the abort and reset functions.  The mid-level
 362  * code uses these to decide what to do next.  Each of the low level abort
 363  * and reset functions must correctly indicate what it has done.
 364  */
 365 
 366 /* We did not do anything.  
 367  * Wait some more for this command to complete, and if this does not work, 
 368  * try something more serious. */ 
 369 #define SCSI_ABORT_SNOOZE 0
 370 
 371 /* This means that we were able to abort the command.  We have already
 372  * called the mid-level done function, and do not expect an interrupt that 
 373  * will lead to another call to the mid-level done function for this command */
 374 #define SCSI_ABORT_SUCCESS 1
 375 
 376 /* We called for an abort of this command, and we should get an interrupt 
 377  * when this succeeds.  Thus we should not restore the timer for this
 378  * command in the mid-level abort function. */
 379 #define SCSI_ABORT_PENDING 2
 380 
 381 /* Unable to abort - command is currently on the bus.  Grin and bear it. */
 382 #define SCSI_ABORT_BUSY 3
 383 
 384 /* The command is not active in the low level code. Command probably
 385  * finished. */
 386 #define SCSI_ABORT_NOT_RUNNING 4
 387 
 388 /* Something went wrong.  The low level driver will indicate the correct
 389  * error condition when it calls scsi_done, so the mid-level abort function
 390  * can simply wait until this comes through */
 391 #define SCSI_ABORT_ERROR 5
 392 
 393 /* We do not know how to reset the bus, or we do not want to.  Bummer.
 394  * Anyway, just wait a little more for the command in question, and hope that
 395  * it eventually finishes.  If it never finishes, the SCSI device could
 396  * hang, so use this with caution. */
 397 #define SCSI_RESET_SNOOZE 0
 398 
 399 /* We do not know how to reset the bus, or we do not want to.  Bummer.
 400  * We have given up on this ever completing.  The mid-level code will
 401  * request sense information to decide how to proceed from here. */
 402 #define SCSI_RESET_PUNT 1
 403 
 404 /* This means that we were able to reset the bus.  We have restarted all of
 405  * the commands that should be restarted, and we should be able to continue
 406  * on normally from here.  We do not expect any interrupts that will return
 407  * DID_RESET to any of the other commands in the host_queue, and the mid-level
 408  * code does not need to do anything special to keep the commands alive. */
 409 #define SCSI_RESET_SUCCESS 2
 410 
 411 /* We called for a reset of this bus, and we should get an interrupt 
 412  * when this succeeds.  Each command should get its own status
 413  * passed up to scsi_done, but this has not happened yet. */
 414 #define SCSI_RESET_PENDING 3
 415 
 416 /* We did a reset, but do not expect an interrupt to signal DID_RESET.
 417  * This tells the upper level code to request the sense info, and this
 418  * should keep the command alive. */
 419 #define SCSI_RESET_WAKEUP 4
 420 
 421 /* Something went wrong, and we do not know how to fix it. */
 422 #define SCSI_RESET_ERROR 5
 423 
 424 void *   scsi_malloc(unsigned int);
 425 int      scsi_free(void *, unsigned int);
 426 extern unsigned int dma_free_sectors;  /* How much room do we have left */
 427 extern unsigned int need_isa_buffer;   /* True if some devices need indirection
 428                                         * buffers */
 429 
 430 /*
 431  * The Scsi_Cmnd structure is used by scsi.c internally, and for communication
 432  * with low level drivers that support multiple outstanding commands.
 433  */
 434 typedef struct scsi_pointer {
 435     char * ptr;                     /* data pointer */
 436     int this_residual;              /* left in this buffer */
 437     struct scatterlist *buffer;     /* which buffer */
 438     int buffers_residual;           /* how many buffers left */
 439     
 440     volatile int Status;
 441     volatile int Message;
 442     volatile int have_data_in;
 443     volatile int sent_command;
 444     volatile int phase;
 445 } Scsi_Pointer;
 446 
 447 typedef struct scsi_cmnd {
 448     struct Scsi_Host * host;
 449     Scsi_Device * device;
 450     unsigned char target, lun, channel;
 451     unsigned char cmd_len;
 452     unsigned char old_cmd_len;
 453     struct scsi_cmnd *next, *prev;  
 454     
 455     /* These elements define the operation we are about to perform */
 456     unsigned char cmnd[12];
 457     unsigned request_bufflen;   /* Actual request size */
 458     
 459     void * request_buffer;      /* Actual requested buffer */
 460     
 461     /* These elements define the operation we ultimately want to perform */
 462     unsigned char data_cmnd[12];
 463     unsigned short old_use_sg;  /* We save  use_sg here when requesting
 464                                  * sense info */
 465     unsigned short use_sg;      /* Number of pieces of scatter-gather */
 466     unsigned short sglist_len;  /* size of malloc'd scatter-gather list */
 467     unsigned short abort_reason;/* If the mid-level code requests an
 468                                  * abort, this is the reason. */
 469     unsigned bufflen;           /* Size of data buffer */
 470     void *buffer;               /* Data buffer */
 471     
 472     unsigned underflow;         /* Return error if less than this amount is 
 473                                  * transfered */
 474     
 475     unsigned transfersize;      /* How much we are guaranteed to transfer with
 476                                  * each SCSI transfer (ie, between disconnect /
 477                                  * reconnects.   Probably == sector size */
 478     
 479     
 480     struct request request;     /* A copy of the command we are working on */
 481 
 482     unsigned char sense_buffer[16];  /* Sense for this command, if needed */
 483 
 484 
 485     int retries;
 486     int allowed;
 487     int timeout_per_command, timeout_total, timeout;
 488 
 489     /*
 490      *  We handle the timeout differently if it happens when a reset, 
 491      *  abort, etc are in process. 
 492      */
 493     unsigned volatile char internal_timeout;
 494     
 495     unsigned flags;
 496     
 497     /* These variables are for the cdrom only. Once we have variable size 
 498      * buffers in the buffer cache, they will go away. */
 499     int this_count; 
 500     /* End of special cdrom variables */
 501     
 502     /* Low-level done function - can be used by low-level driver to point
 503      *  to completion function.  Not used by mid/upper level code. */
 504     void (*scsi_done)(struct scsi_cmnd *);  
 505     void (*done)(struct scsi_cmnd *);  /* Mid-level done function */
 506     
 507     /*
 508      * The following fields can be written to by the host specific code. 
 509      * Everything else should be left alone. 
 510      */
 511     
 512     Scsi_Pointer SCp;   /* Scratchpad used by some host adapters */
 513     
 514     unsigned char * host_scribble; /* The host adapter is allowed to
 515                                     * call scsi_malloc and get some memory
 516                                     * and hang it here.  The host adapter
 517                                     * is also expected to call scsi_free
 518                                     * to release this memory.  (The memory
 519                                     * obtained by scsi_malloc is guaranteed
 520                                     * to be at an address < 16Mb). */
 521     
 522     int result;                    /* Status code from lower level driver */
 523     
 524     unsigned char tag;             /* SCSI-II queued command tag */
 525     unsigned long pid;             /* Process ID, starts at 0 */
 526 } Scsi_Cmnd;         
 527 
 528 /*
 529  *  scsi_abort aborts the current command that is executing on host host.
 530  *  The error code, if non zero is returned in the host byte, otherwise 
 531  *  DID_ABORT is returned in the hostbyte.
 532  */
 533 
 534 extern int scsi_abort (Scsi_Cmnd *, int code, int pid);
 535 
 536 extern void scsi_do_cmd (Scsi_Cmnd *, const void *cmnd ,
 537                          void *buffer, unsigned bufflen, 
 538                          void (*done)(struct scsi_cmnd *),
 539                          int timeout, int retries);
 540 
 541 
 542 extern Scsi_Cmnd * allocate_device(struct request **, Scsi_Device *, int);
 543 
 544 extern Scsi_Cmnd * request_queueable(struct request *, Scsi_Device *);
 545 extern int scsi_reset (Scsi_Cmnd *);
 546 
 547 extern int max_scsi_hosts;
 548 
 549 extern void build_proc_dir_entries(void);
 550 
 551 extern int kernel_scsi_ioctl (Scsi_Device *dev, int cmd, void *arg);
 552 extern int        scsi_ioctl (Scsi_Device *dev, int cmd, void *arg);
 553 extern void print_command(unsigned char *);
 554 extern void print_sense(char *,  Scsi_Cmnd *);
 555 
 556 
 557 #if defined(MAJOR_NR) && (MAJOR_NR != SCSI_TAPE_MAJOR)
 558 #include "hosts.h"
 559 
 560 static Scsi_Cmnd * end_scsi_request(Scsi_Cmnd * SCpnt, int uptodate, int sectors)
     /* [previous][next][first][last][top][bottom][index][help] */
 561 {
 562     struct request * req;
 563     struct buffer_head * bh;
 564     
 565     req = &SCpnt->request;
 566     req->errors = 0;
 567     if (!uptodate) {
 568         printk(DEVICE_NAME " I/O error: dev %04x, sector %lu\n",
 569                req->dev,req->sector);
 570     }
 571     
 572     do {
 573         if ((bh = req->bh) != NULL) {
 574             req->bh = bh->b_reqnext;
 575             req->nr_sectors -= bh->b_size >> 9;
 576             req->sector += bh->b_size >> 9;
 577             bh->b_reqnext = NULL;
 578             bh->b_uptodate = uptodate;
 579             unlock_buffer(bh);
 580             sectors -= bh->b_size >> 9;
 581             if ((bh = req->bh) != NULL) {
 582                 req->current_nr_sectors = bh->b_size >> 9;
 583                 if (req->nr_sectors < req->current_nr_sectors) {
 584                     req->nr_sectors = req->current_nr_sectors;
 585                     printk("end_scsi_request: buffer-list destroyed\n");
 586                 }
 587             }
 588         }
 589     } while(sectors && bh);
 590     if (req->bh){
 591         req->buffer = bh->b_data;
 592         return SCpnt;
 593     };
 594     DEVICE_OFF(req->dev);
 595     if (req->sem != NULL) {
 596         up(req->sem);
 597     }
 598     
 599     if (SCpnt->host->block) {
 600         struct Scsi_Host * next;
 601         
 602         for (next = SCpnt->host->block; next != SCpnt->host;
 603              next = next->block)
 604             wake_up(&next->host_wait);
 605     }
 606     
 607     req->dev = -1;
 608     wake_up(&wait_for_request);
 609     wake_up(&SCpnt->device->device_wait);
 610     return NULL;
 611 }
 612 
 613 
 614 /* This is just like INIT_REQUEST, but we need to be aware of the fact
 615  * that an interrupt may start another request, so we run this with interrupts
 616  * turned off 
 617  */
 618 #define INIT_SCSI_REQUEST \
 619     if (!CURRENT) {\
 620         CLEAR_INTR; \
 621         restore_flags(flags);   \
 622         return; \
 623     } \
 624     if (MAJOR(CURRENT->dev) != MAJOR_NR) \
 625         panic(DEVICE_NAME ": request list destroyed"); \
 626     if (CURRENT->bh) { \
 627         if (!CURRENT->bh->b_lock) \
 628             panic(DEVICE_NAME ": block not locked"); \
 629     }
 630 #endif
 631 
 632 #define SCSI_SLEEP(QUEUE, CONDITION) {              \
 633     if (CONDITION) {                    \
 634         struct wait_queue wait = { current, NULL};  \
 635         add_wait_queue(QUEUE, &wait);           \
 636         for(;;) {                           \
 637         current->state = TASK_UNINTERRUPTIBLE;      \
 638         if (CONDITION) {                \
 639                    if (intr_count)                              \
 640                       panic("scsi: trying to call schedule() in interrupt" \
 641                             ", file %s, line %d.\n", __FILE__, __LINE__);  \
 642            schedule();                  \
 643            }                            \
 644             else                        \
 645                    break;                                       \
 646         }                       \
 647         remove_wait_queue(QUEUE, &wait);        \
 648         current->state = TASK_RUNNING;          \
 649     }; }
 650 
 651 #endif
 652 
 653 /*
 654  * Overrides for Emacs so that we follow Linus's tabbing style.
 655  * Emacs will notice this stuff at the end of the file and automatically
 656  * adjust the settings for this buffer only.  This must remain at the end
 657  * of the file.
 658  * ---------------------------------------------------------------------------
 659  * Local variables:
 660  * c-indent-level: 4 
 661  * c-brace-imaginary-offset: 0
 662  * c-brace-offset: -4
 663  * c-argdecl-indent: 4
 664  * c-label-offset: -4
 665  * c-continued-statement-offset: 4
 666  * c-continued-brace-offset: 0
 667  * indent-tabs-mode: nil
 668  * tab-width: 4
 669  * End:
 670  */

/* [previous][next][first][last][top][bottom][index][help] */