root/include/linux/blk.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ide_end_request
  2. end_request

   1 #ifndef _BLK_H
   2 #define _BLK_H
   3 
   4 #include <linux/blkdev.h>
   5 #include <linux/locks.h>
   6 #include <linux/config.h>
   7 
   8 /*
   9  * NR_REQUEST is the number of entries in the request-queue.
  10  * NOTE that writes may use only the low 2/3 of these: reads
  11  * take precedence.
  12  */
  13 #define NR_REQUEST      64
  14 
  15 /*
  16  * This is used in the elevator algorithm: Note that
  17  * reads always go before writes. This is natural: reads
  18  * are much more time-critical than writes.
  19  */
  20 #define IN_ORDER(s1,s2) \
  21 ((s1)->cmd < (s2)->cmd || ((s1)->cmd == (s2)->cmd && \
  22 ((s1)->rq_dev < (s2)->rq_dev || (((s1)->rq_dev == (s2)->rq_dev && \
  23 (s1)->sector < (s2)->sector)))))
  24 
  25 /*
  26  * These will have to be changed to be aware of different buffer
  27  * sizes etc.. It actually needs a major cleanup.
  28  */
  29 #ifdef IDE_DRIVER
  30 #define SECTOR_MASK ((BLOCK_SIZE >> 9) - 1)
  31 #else
  32 #define SECTOR_MASK (blksize_size[MAJOR_NR] &&     \
  33         blksize_size[MAJOR_NR][MINOR(CURRENT->rq_dev)] ? \
  34         ((blksize_size[MAJOR_NR][MINOR(CURRENT->rq_dev)] >> 9) - 1) :  \
  35         ((BLOCK_SIZE >> 9)  -  1))
  36 #endif /* IDE_DRIVER */
  37 
  38 #define SUBSECTOR(block) (CURRENT->current_nr_sectors > 0)
  39 
  40 #ifdef CONFIG_CDU31A
  41 extern int cdu31a_init(void);
  42 #endif CONFIG_CDU31A
  43 #ifdef CONFIG_MCD
  44 extern int mcd_init(void);
  45 #endif CONFIG_MCD
  46 #ifdef CONFIG_MCDX
  47 extern int mcdx_init(void);
  48 #endif CONFIG_MCDX
  49 #ifdef CONFIG_SBPCD
  50 extern int sbpcd_init(void);
  51 #endif CONFIG_SBPCD
  52 #ifdef CONFIG_AZTCD
  53 extern int aztcd_init(void);
  54 #endif CONFIG_AZTCD
  55 #ifdef CONFIG_CDU535
  56 extern int sony535_init(void);
  57 #endif CONFIG_CDU535
  58 #ifdef CONFIG_GSCD
  59 extern int gscd_init(void);
  60 #endif CONFIG_GSCD
  61 #ifdef CONFIG_CM206
  62 extern int cm206_init(void);
  63 #endif CONFIG_CM206
  64 #ifdef CONFIG_OPTCD
  65 extern int optcd_init(void);
  66 #endif CONFIG_OPTCD
  67 #ifdef CONFIG_SJCD
  68 extern int sjcd_init(void);
  69 #endif CONFIG_SJCD
  70 #ifdef CONFIG_BLK_DEV_HD
  71 extern int hd_init(void);
  72 #endif
  73 #ifdef CONFIG_BLK_DEV_IDE
  74 extern int ide_init(void);
  75 #endif
  76 #ifdef CONFIG_BLK_DEV_XD
  77 extern int xd_init(void);
  78 #endif
  79 
  80 extern void set_device_ro(kdev_t dev,int flag);
  81 void add_blkdev_randomness(int major);
  82 
  83 extern int floppy_init(void);
  84 extern void rd_load(void);
  85 extern int rd_init(void);
  86 extern int rd_doload;           /* 1 = load ramdisk, 0 = don't load */
  87 extern int rd_prompt;           /* 1 = prompt for ramdisk, 0 = don't prompt */
  88 extern int rd_image_start;      /* starting block # of image */
  89 
  90 #define RO_IOCTLS(dev,where) \
  91   case BLKROSET: if (!suser()) return -EACCES; \
  92                  set_device_ro((dev),get_fs_long((long *) (where))); return 0; \
  93   case BLKROGET: { int __err = verify_area(VERIFY_WRITE, (void *) (where), sizeof(long)); \
  94                    if (!__err) put_fs_long(0!=is_read_only(dev),(long *) (where)); return __err; }
  95                  
  96 #if defined(MAJOR_NR) || defined(IDE_DRIVER)
  97 
  98 /*
  99  * Add entries as needed.
 100  */
 101 
 102 #ifdef IDE_DRIVER
 103 
 104 #define DEVICE_NR(device)       (MINOR(device) >> PARTN_BITS)
 105 #define DEVICE_ON(device)       /* nothing */
 106 #define DEVICE_OFF(device)      /* nothing */
 107 
 108 #elif (MAJOR_NR == RAMDISK_MAJOR)
 109 
 110 /* ram disk */
 111 #define DEVICE_NAME "ramdisk"
 112 #define DEVICE_REQUEST rd_request
 113 #define DEVICE_NR(device) (MINOR(device))
 114 #define DEVICE_ON(device) 
 115 #define DEVICE_OFF(device)
 116 #define DEVICE_NO_RANDOM
 117 
 118 #elif (MAJOR_NR == FLOPPY_MAJOR)
 119 
 120 static void floppy_off(unsigned int nr);
 121 
 122 #define DEVICE_NAME "floppy"
 123 #define DEVICE_INTR do_floppy
 124 #define DEVICE_REQUEST do_fd_request
 125 #define DEVICE_NR(device) ( (MINOR(device) & 3) | ((MINOR(device) & 0x80 ) >> 5 ))
 126 #define DEVICE_ON(device)
 127 #define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
 128 
 129 #elif (MAJOR_NR == HD_MAJOR)
 130 
 131 /* harddisk: timeout is 6 seconds.. */
 132 #define DEVICE_NAME "harddisk"
 133 #define DEVICE_INTR do_hd
 134 #define DEVICE_TIMEOUT HD_TIMER
 135 #define TIMEOUT_VALUE (6*HZ)
 136 #define DEVICE_REQUEST do_hd_request
 137 #define DEVICE_NR(device) (MINOR(device)>>6)
 138 #define DEVICE_ON(device)
 139 #define DEVICE_OFF(device)
 140 
 141 #elif (MAJOR_NR == SCSI_DISK_MAJOR)
 142 
 143 #define DEVICE_NAME "scsidisk"
 144 #define DEVICE_INTR do_sd  
 145 #define TIMEOUT_VALUE (2*HZ)
 146 #define DEVICE_REQUEST do_sd_request
 147 #define DEVICE_NR(device) (MINOR(device) >> 4)
 148 #define DEVICE_ON(device)
 149 #define DEVICE_OFF(device)
 150 
 151 #elif (MAJOR_NR == SCSI_TAPE_MAJOR)
 152 
 153 #define DEVICE_NAME "scsitape"
 154 #define DEVICE_INTR do_st  
 155 #define DEVICE_NR(device) (MINOR(device) & 0x7f)
 156 #define DEVICE_ON(device)
 157 #define DEVICE_OFF(device)
 158 
 159 #elif (MAJOR_NR == SCSI_CDROM_MAJOR)
 160 
 161 #define DEVICE_NAME "CD-ROM"
 162 #define DEVICE_INTR do_sr
 163 #define DEVICE_REQUEST do_sr_request
 164 #define DEVICE_NR(device) (MINOR(device))
 165 #define DEVICE_ON(device)
 166 #define DEVICE_OFF(device)
 167 
 168 #elif (MAJOR_NR == XT_DISK_MAJOR)
 169 
 170 #define DEVICE_NAME "xt disk"
 171 #define DEVICE_REQUEST do_xd_request
 172 #define DEVICE_NR(device) (MINOR(device) >> 6)
 173 #define DEVICE_ON(device)
 174 #define DEVICE_OFF(device)
 175 
 176 #elif (MAJOR_NR == CDU31A_CDROM_MAJOR)
 177 
 178 #define DEVICE_NAME "CDU31A"
 179 #define DEVICE_REQUEST do_cdu31a_request
 180 #define DEVICE_NR(device) (MINOR(device))
 181 #define DEVICE_ON(device)
 182 #define DEVICE_OFF(device)
 183 
 184 #elif (MAJOR_NR == MITSUMI_CDROM_MAJOR)
 185 
 186 #define DEVICE_NAME "Mitsumi CD-ROM"
 187 /* #define DEVICE_INTR do_mcd */
 188 #define DEVICE_REQUEST do_mcd_request
 189 #define DEVICE_NR(device) (MINOR(device))
 190 #define DEVICE_ON(device)
 191 #define DEVICE_OFF(device)
 192 
 193 #elif (MAJOR_NR == MITSUMI_X_CDROM_MAJOR)
 194 
 195 #define DEVICE_NAME "Mitsumi CD-ROM"
 196 /* #define DEVICE_INTR do_mcdx */
 197 #define DEVICE_REQUEST do_mcdx_request
 198 #define DEVICE_NR(device) (MINOR(device))
 199 #define DEVICE_ON(device)
 200 #define DEVICE_OFF(device)
 201 
 202 #elif (MAJOR_NR == MATSUSHITA_CDROM_MAJOR)
 203 
 204 #define DEVICE_NAME "Matsushita CD-ROM controller #1"
 205 #define DEVICE_REQUEST do_sbpcd_request
 206 #define DEVICE_NR(device) (MINOR(device))
 207 #define DEVICE_ON(device)
 208 #define DEVICE_OFF(device)
 209 
 210 #elif (MAJOR_NR == MATSUSHITA_CDROM2_MAJOR)
 211 
 212 #define DEVICE_NAME "Matsushita CD-ROM controller #2"
 213 #define DEVICE_REQUEST do_sbpcd2_request
 214 #define DEVICE_NR(device) (MINOR(device))
 215 #define DEVICE_ON(device)
 216 #define DEVICE_OFF(device)
 217 
 218 #elif (MAJOR_NR == MATSUSHITA_CDROM3_MAJOR)
 219 
 220 #define DEVICE_NAME "Matsushita CD-ROM controller #3"
 221 #define DEVICE_REQUEST do_sbpcd3_request
 222 #define DEVICE_NR(device) (MINOR(device))
 223 #define DEVICE_ON(device)
 224 #define DEVICE_OFF(device)
 225 
 226 #elif (MAJOR_NR == MATSUSHITA_CDROM4_MAJOR)
 227 
 228 #define DEVICE_NAME "Matsushita CD-ROM controller #4"
 229 #define DEVICE_REQUEST do_sbpcd4_request
 230 #define DEVICE_NR(device) (MINOR(device))
 231 #define DEVICE_ON(device)
 232 #define DEVICE_OFF(device)
 233 
 234 #elif (MAJOR_NR == AZTECH_CDROM_MAJOR)
 235 
 236 #define DEVICE_NAME "Aztech CD-ROM"
 237 #define DEVICE_REQUEST do_aztcd_request
 238 #define DEVICE_NR(device) (MINOR(device))
 239 #define DEVICE_ON(device)
 240 #define DEVICE_OFF(device)
 241 
 242 #elif (MAJOR_NR == CDU535_CDROM_MAJOR)
 243 
 244 #define DEVICE_NAME "SONY-CDU535"
 245 #define DEVICE_INTR do_cdu535
 246 #define DEVICE_REQUEST do_cdu535_request
 247 #define DEVICE_NR(device) (MINOR(device))
 248 #define DEVICE_ON(device)
 249 #define DEVICE_OFF(device)
 250 
 251 #elif (MAJOR_NR == GOLDSTAR_CDROM_MAJOR)
 252 
 253 #define DEVICE_NAME "Goldstar R420"
 254 #define DEVICE_REQUEST do_gscd_request
 255 #define DEVICE_NR(device) (MINOR(device))
 256 #define DEVICE_ON(device)
 257 #define DEVICE_OFF(device)
 258 
 259 #elif (MAJOR_NR == CM206_CDROM_MAJOR)
 260 #define DEVICE_NAME "Philips/LMS cd-rom cm206"
 261 #define DEVICE_REQUEST do_cm206_request
 262 #define DEVICE_NR(device) (MINOR(device))
 263 #define DEVICE_ON(device)
 264 #define DEVICE_OFF(device)
 265 
 266 #elif (MAJOR_NR == OPTICS_CDROM_MAJOR)
 267 
 268 #define DEVICE_NAME "DOLPHIN 8000AT CD-ROM"
 269 #define DEVICE_REQUEST do_optcd_request
 270 #define DEVICE_NR(device) (MINOR(device))
 271 #define DEVICE_ON(device)
 272 #define DEVICE_OFF(device)
 273 
 274 #elif (MAJOR_NR == SANYO_CDROM_MAJOR)
 275 
 276 #define DEVICE_NAME "Sanyo H94A CD-ROM"
 277 #define DEVICE_REQUEST do_sjcd_request
 278 #define DEVICE_NR(device) (MINOR(device))
 279 #define DEVICE_ON(device)
 280 #define DEVICE_OFF(device)
 281 
 282 #endif /* MAJOR_NR == whatever */
 283 
 284 #if (MAJOR_NR != SCSI_TAPE_MAJOR) && !defined(IDE_DRIVER)
 285 
 286 #ifndef CURRENT
 287 #define CURRENT (blk_dev[MAJOR_NR].current_request)
 288 #endif
 289 
 290 #define CURRENT_DEV DEVICE_NR(CURRENT->rq_dev)
 291 
 292 #ifdef DEVICE_INTR
 293 void (*DEVICE_INTR)(void) = NULL;
 294 #endif
 295 #ifdef DEVICE_TIMEOUT
 296 
 297 #define SET_TIMER \
 298 ((timer_table[DEVICE_TIMEOUT].expires = jiffies + TIMEOUT_VALUE), \
 299 (timer_active |= 1<<DEVICE_TIMEOUT))
 300 
 301 #define CLEAR_TIMER \
 302 timer_active &= ~(1<<DEVICE_TIMEOUT)
 303 
 304 #define SET_INTR(x) \
 305 if ((DEVICE_INTR = (x)) != NULL) \
 306         SET_TIMER; \
 307 else \
 308         CLEAR_TIMER;
 309 
 310 #else
 311 
 312 #define SET_INTR(x) (DEVICE_INTR = (x))
 313 
 314 #endif /* DEVICE_TIMEOUT */
 315 
 316 static void (DEVICE_REQUEST)(void);
 317 
 318 #ifdef DEVICE_INTR
 319 #define CLEAR_INTR SET_INTR(NULL)
 320 #else
 321 #define CLEAR_INTR
 322 #endif
 323 
 324 #define INIT_REQUEST \
 325         if (!CURRENT) {\
 326                 CLEAR_INTR; \
 327                 return; \
 328         } \
 329         if (MAJOR(CURRENT->rq_dev) != MAJOR_NR) \
 330                 panic(DEVICE_NAME ": request list destroyed"); \
 331         if (CURRENT->bh) { \
 332                 if (!buffer_locked(CURRENT->bh)) \
 333                         panic(DEVICE_NAME ": block not locked"); \
 334         }
 335 
 336 #endif /* (MAJOR_NR != SCSI_TAPE_MAJOR) && !defined(IDE_DRIVER) */
 337 
 338 /* end_request() - SCSI devices have their own version */
 339 /*               - IDE drivers have their own copy too */
 340 
 341 #if ! SCSI_MAJOR(MAJOR_NR)
 342 
 343 #if defined(_IDE_CD_C) || defined(_TRITON_C) || defined(_IDE_TAPE_C) /* shares copy with ide.c */
 344 void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup);
 345 #else
 346 
 347 #ifdef IDE_DRIVER
 348 void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup) {
     /* [previous][next][first][last][top][bottom][index][help] */
 349         struct request *req = hwgroup->rq;
 350 #else
 351 static void end_request(int uptodate) {
     /* [previous][next][first][last][top][bottom][index][help] */
 352         struct request *req = CURRENT;
 353 #endif /* IDE_DRIVER */
 354         struct buffer_head * bh;
 355 
 356         req->errors = 0;
 357         if (!uptodate) {
 358                 printk("end_request: I/O error, dev %s, sector %lu\n",
 359                         kdevname(req->rq_dev), req->sector);
 360                 req->nr_sectors--;
 361                 req->nr_sectors &= ~SECTOR_MASK;
 362                 req->sector += (BLOCK_SIZE / 512);
 363                 req->sector &= ~SECTOR_MASK;            
 364         }
 365 
 366         if ((bh = req->bh) != NULL) {
 367                 req->bh = bh->b_reqnext;
 368                 bh->b_reqnext = NULL;
 369                 mark_buffer_uptodate(bh, uptodate);
 370                 unlock_buffer(bh);
 371                 if ((bh = req->bh) != NULL) {
 372                         req->current_nr_sectors = bh->b_size >> 9;
 373                         if (req->nr_sectors < req->current_nr_sectors) {
 374                                 req->nr_sectors = req->current_nr_sectors;
 375                                 printk("end_request: buffer-list destroyed\n");
 376                         }
 377                         req->buffer = bh->b_data;
 378                         return;
 379                 }
 380         }
 381 #ifndef DEVICE_NO_RANDOM
 382         add_blkdev_randomness(MAJOR(req->rq_dev));
 383 #endif
 384 #ifdef IDE_DRIVER
 385         blk_dev[MAJOR(req->rq_dev)].current_request = req->next;
 386         hwgroup->rq = NULL;
 387 #else
 388         DEVICE_OFF(req->rq_dev);
 389         CURRENT = req->next;
 390 #endif /* IDE_DRIVER */
 391         if (req->sem != NULL)
 392                 up(req->sem);
 393         req->rq_status = RQ_INACTIVE;
 394         wake_up(&wait_for_request);
 395 }
 396 #endif /* ndef _IDE_CD_C */
 397 #endif /* ! SCSI_MAJOR(MAJOR_NR) */
 398 
 399 #endif /* defined(MAJOR_NR) || defined(IDE_DRIVER) */
 400 
 401 #endif /* _BLK_H */

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