This source file includes following definitions.
- ide_end_request
- end_request
- end_request
- end_redirect
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
10
11
12
13 #define NR_REQUEST 64
14
15
16
17
18
19
20
21 #define IN_ORDER(s1,s2) \
22 ((s1)->rq_dev < (s2)->rq_dev || (((s1)->rq_dev == (s2)->rq_dev && \
23 (s1)->sector < (s2)->sector)))
24
25
26
27
28
29 #if defined(IDE_DRIVER) || defined(MD_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
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_CDI_INIT
71 extern int cdi_init(void);
72 #endif CONFIG_CDI_INIT
73 #ifdef CONFIG_BLK_DEV_HD
74 extern int hd_init(void);
75 #endif
76 #ifdef CONFIG_BLK_DEV_IDE
77 extern int ide_init(void);
78 #endif
79 #ifdef CONFIG_BLK_DEV_XD
80 extern int xd_init(void);
81 #endif
82 #ifdef CONFIG_BLK_DEV_LOOP
83 extern int loop_init(void);
84 #endif
85 #ifdef CONFIG_BLK_DEV_MD
86 extern int md_init(void);
87 #endif CONFIG_BLK_DEV_MD
88
89 extern void set_device_ro(kdev_t dev,int flag);
90 void add_blkdev_randomness(int major);
91
92 extern int floppy_init(void);
93 extern void rd_load(void);
94 extern int rd_init(void);
95 extern int rd_doload;
96 extern int rd_prompt;
97 extern int rd_image_start;
98
99 #define RO_IOCTLS(dev,where) \
100 case BLKROSET: if (!suser()) return -EACCES; \
101 set_device_ro((dev),get_fs_long((long *) (where))); return 0; \
102 case BLKROGET: { int __err = verify_area(VERIFY_WRITE, (void *) (where), sizeof(long)); \
103 if (!__err) put_fs_long(0!=is_read_only(dev),(long *) (where)); return __err; }
104
105 #if defined(MAJOR_NR) || defined(IDE_DRIVER)
106
107
108
109
110
111 #ifdef IDE_DRIVER
112
113 #define DEVICE_NR(device) (MINOR(device) >> PARTN_BITS)
114 #define DEVICE_ON(device)
115 #define DEVICE_OFF(device)
116
117 #elif (MAJOR_NR == RAMDISK_MAJOR)
118
119
120 #define DEVICE_NAME "ramdisk"
121 #define DEVICE_REQUEST rd_request
122 #define DEVICE_NR(device) (MINOR(device))
123 #define DEVICE_ON(device)
124 #define DEVICE_OFF(device)
125 #define DEVICE_NO_RANDOM
126
127 #elif (MAJOR_NR == FLOPPY_MAJOR)
128
129 static void floppy_off(unsigned int nr);
130
131 #define DEVICE_NAME "floppy"
132 #define DEVICE_INTR do_floppy
133 #define DEVICE_REQUEST do_fd_request
134 #define DEVICE_NR(device) ( (MINOR(device) & 3) | ((MINOR(device) & 0x80 ) >> 5 ))
135 #define DEVICE_ON(device)
136 #define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
137
138 #elif (MAJOR_NR == HD_MAJOR)
139
140
141 #define DEVICE_NAME "harddisk"
142 #define DEVICE_INTR do_hd
143 #define DEVICE_TIMEOUT HD_TIMER
144 #define TIMEOUT_VALUE (6*HZ)
145 #define DEVICE_REQUEST do_hd_request
146 #define DEVICE_NR(device) (MINOR(device)>>6)
147 #define DEVICE_ON(device)
148 #define DEVICE_OFF(device)
149
150 #elif (MAJOR_NR == SCSI_DISK_MAJOR)
151
152 #define DEVICE_NAME "scsidisk"
153 #define DEVICE_INTR do_sd
154 #define TIMEOUT_VALUE (2*HZ)
155 #define DEVICE_REQUEST do_sd_request
156 #define DEVICE_NR(device) (MINOR(device) >> 4)
157 #define DEVICE_ON(device)
158 #define DEVICE_OFF(device)
159
160
161 #elif (MAJOR_NR == MD_MAJOR) && defined(MD_DRIVER)
162
163 #ifndef MD_PERSONALITY
164
165 #define DEVICE_NAME "Multiple devices driver"
166 #define DEVICE_REQUEST do_md_request
167 #define DEVICE_NR(device) (MINOR(device))
168 #define DEVICE_ON(device)
169 #define DEVICE_OFF(device)
170
171 #endif
172
173 #elif (MAJOR_NR == SCSI_TAPE_MAJOR)
174
175 #define DEVICE_NAME "scsitape"
176 #define DEVICE_INTR do_st
177 #define DEVICE_NR(device) (MINOR(device) & 0x7f)
178 #define DEVICE_ON(device)
179 #define DEVICE_OFF(device)
180
181 #elif (MAJOR_NR == SCSI_CDROM_MAJOR)
182
183 #define DEVICE_NAME "CD-ROM"
184 #define DEVICE_INTR do_sr
185 #define DEVICE_REQUEST do_sr_request
186 #define DEVICE_NR(device) (MINOR(device))
187 #define DEVICE_ON(device)
188 #define DEVICE_OFF(device)
189
190 #elif (MAJOR_NR == XT_DISK_MAJOR)
191
192 #define DEVICE_NAME "xt disk"
193 #define DEVICE_REQUEST do_xd_request
194 #define DEVICE_NR(device) (MINOR(device) >> 6)
195 #define DEVICE_ON(device)
196 #define DEVICE_OFF(device)
197
198 #elif (MAJOR_NR == CDU31A_CDROM_MAJOR)
199
200 #define DEVICE_NAME "CDU31A"
201 #define DEVICE_REQUEST do_cdu31a_request
202 #define DEVICE_NR(device) (MINOR(device))
203 #define DEVICE_ON(device)
204 #define DEVICE_OFF(device)
205
206 #elif (MAJOR_NR == MITSUMI_CDROM_MAJOR)
207
208 #define DEVICE_NAME "Mitsumi CD-ROM"
209
210 #define DEVICE_REQUEST do_mcd_request
211 #define DEVICE_NR(device) (MINOR(device))
212 #define DEVICE_ON(device)
213 #define DEVICE_OFF(device)
214
215 #elif (MAJOR_NR == MITSUMI_X_CDROM_MAJOR)
216
217 #define DEVICE_NAME "Mitsumi CD-ROM"
218
219 #define DEVICE_REQUEST do_mcdx_request
220 #define DEVICE_NR(device) (MINOR(device))
221 #define DEVICE_ON(device)
222 #define DEVICE_OFF(device)
223
224 #elif (MAJOR_NR == MATSUSHITA_CDROM_MAJOR)
225
226 #define DEVICE_NAME "Matsushita CD-ROM controller #1"
227 #define DEVICE_REQUEST do_sbpcd_request
228 #define DEVICE_NR(device) (MINOR(device))
229 #define DEVICE_ON(device)
230 #define DEVICE_OFF(device)
231
232 #elif (MAJOR_NR == MATSUSHITA_CDROM2_MAJOR)
233
234 #define DEVICE_NAME "Matsushita CD-ROM controller #2"
235 #define DEVICE_REQUEST do_sbpcd2_request
236 #define DEVICE_NR(device) (MINOR(device))
237 #define DEVICE_ON(device)
238 #define DEVICE_OFF(device)
239
240 #elif (MAJOR_NR == MATSUSHITA_CDROM3_MAJOR)
241
242 #define DEVICE_NAME "Matsushita CD-ROM controller #3"
243 #define DEVICE_REQUEST do_sbpcd3_request
244 #define DEVICE_NR(device) (MINOR(device))
245 #define DEVICE_ON(device)
246 #define DEVICE_OFF(device)
247
248 #elif (MAJOR_NR == MATSUSHITA_CDROM4_MAJOR)
249
250 #define DEVICE_NAME "Matsushita CD-ROM controller #4"
251 #define DEVICE_REQUEST do_sbpcd4_request
252 #define DEVICE_NR(device) (MINOR(device))
253 #define DEVICE_ON(device)
254 #define DEVICE_OFF(device)
255
256 #elif (MAJOR_NR == AZTECH_CDROM_MAJOR)
257
258 #define DEVICE_NAME "Aztech CD-ROM"
259 #define DEVICE_REQUEST do_aztcd_request
260 #define DEVICE_NR(device) (MINOR(device))
261 #define DEVICE_ON(device)
262 #define DEVICE_OFF(device)
263
264 #elif (MAJOR_NR == CDU535_CDROM_MAJOR)
265
266 #define DEVICE_NAME "SONY-CDU535"
267 #define DEVICE_INTR do_cdu535
268 #define DEVICE_REQUEST do_cdu535_request
269 #define DEVICE_NR(device) (MINOR(device))
270 #define DEVICE_ON(device)
271 #define DEVICE_OFF(device)
272
273 #elif (MAJOR_NR == GOLDSTAR_CDROM_MAJOR)
274
275 #define DEVICE_NAME "Goldstar R420"
276 #define DEVICE_REQUEST do_gscd_request
277 #define DEVICE_NR(device) (MINOR(device))
278 #define DEVICE_ON(device)
279 #define DEVICE_OFF(device)
280
281 #elif (MAJOR_NR == CM206_CDROM_MAJOR)
282 #define DEVICE_NAME "Philips/LMS cd-rom cm206"
283 #define DEVICE_REQUEST do_cm206_request
284 #define DEVICE_NR(device) (MINOR(device))
285 #define DEVICE_ON(device)
286 #define DEVICE_OFF(device)
287
288 #elif (MAJOR_NR == OPTICS_CDROM_MAJOR)
289
290 #define DEVICE_NAME "DOLPHIN 8000AT CD-ROM"
291 #define DEVICE_REQUEST do_optcd_request
292 #define DEVICE_NR(device) (MINOR(device))
293 #define DEVICE_ON(device)
294 #define DEVICE_OFF(device)
295
296 #elif (MAJOR_NR == SANYO_CDROM_MAJOR)
297
298 #define DEVICE_NAME "Sanyo H94A CD-ROM"
299 #define DEVICE_REQUEST do_sjcd_request
300 #define DEVICE_NR(device) (MINOR(device))
301 #define DEVICE_ON(device)
302 #define DEVICE_OFF(device)
303
304 #endif
305
306 #if ((MAJOR_NR != SCSI_TAPE_MAJOR) && !defined(IDE_DRIVER) && !defined(MD_DRIVER))
307
308 #ifndef CURRENT
309 #define CURRENT (blk_dev[MAJOR_NR].current_request)
310 #endif
311
312 #define CURRENT_DEV DEVICE_NR(CURRENT->rq_dev)
313
314 #ifdef DEVICE_INTR
315 void (*DEVICE_INTR)(void) = NULL;
316 #endif
317 #ifdef DEVICE_TIMEOUT
318
319 #define SET_TIMER \
320 ((timer_table[DEVICE_TIMEOUT].expires = jiffies + TIMEOUT_VALUE), \
321 (timer_active |= 1<<DEVICE_TIMEOUT))
322
323 #define CLEAR_TIMER \
324 timer_active &= ~(1<<DEVICE_TIMEOUT)
325
326 #define SET_INTR(x) \
327 if ((DEVICE_INTR = (x)) != NULL) \
328 SET_TIMER; \
329 else \
330 CLEAR_TIMER;
331
332 #else
333
334 #define SET_INTR(x) (DEVICE_INTR = (x))
335
336 #endif
337
338 #ifndef MD_PERSONALITY
339 static void (DEVICE_REQUEST)(void);
340 #endif
341
342 #ifdef DEVICE_INTR
343 #define CLEAR_INTR SET_INTR(NULL)
344 #else
345 #define CLEAR_INTR
346 #endif
347
348 #define INIT_REQUEST \
349 if (!CURRENT) {\
350 CLEAR_INTR; \
351 return; \
352 } \
353 if (MAJOR(CURRENT->rq_dev) != MAJOR_NR) \
354 panic(DEVICE_NAME ": request list destroyed"); \
355 if (CURRENT->bh) { \
356 if (!buffer_locked(CURRENT->bh)) \
357 panic(DEVICE_NAME ": block not locked"); \
358 }
359
360 #endif
361
362
363
364
365 #if ! SCSI_MAJOR(MAJOR_NR) || (defined(MD_DRIVER) && !defined(MD_PERSONALITY))
366
367 #if defined(IDE_DRIVER) && !defined(_IDE_C)
368 void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup);
369 #else
370
371 #ifdef IDE_DRIVER
372 void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup) {
373 struct request *req = hwgroup->rq;
374 #elif defined(MD_DRIVER)
375 static void end_request (int uptodate, struct request * req) {
376 #else
377 static void end_request(int uptodate) {
378 struct request *req = CURRENT;
379 #endif
380 struct buffer_head * bh;
381
382 req->errors = 0;
383 if (!uptodate) {
384 printk("end_request: I/O error, dev %s, sector %lu\n",
385 kdevname(req->rq_dev), req->sector);
386 req->nr_sectors--;
387 req->nr_sectors &= ~SECTOR_MASK;
388 req->sector += (BLOCK_SIZE / 512);
389 req->sector &= ~SECTOR_MASK;
390 }
391
392 if ((bh = req->bh) != NULL) {
393 req->bh = bh->b_reqnext;
394 bh->b_reqnext = NULL;
395 mark_buffer_uptodate(bh, uptodate);
396 unlock_buffer(bh);
397 if ((bh = req->bh) != NULL) {
398 req->current_nr_sectors = bh->b_size >> 9;
399 if (req->nr_sectors < req->current_nr_sectors) {
400 req->nr_sectors = req->current_nr_sectors;
401 printk("end_request: buffer-list destroyed\n");
402 }
403 req->buffer = bh->b_data;
404 return;
405 }
406 }
407 #ifndef DEVICE_NO_RANDOM
408 add_blkdev_randomness(MAJOR(req->rq_dev));
409 #endif
410 #ifdef IDE_DRIVER
411 blk_dev[MAJOR(req->rq_dev)].current_request = req->next;
412 hwgroup->rq = NULL;
413 #elif !defined(MD_DRIVER)
414 DEVICE_OFF(req->rq_dev);
415 CURRENT = req->next;
416 #endif
417 if (req->sem != NULL)
418 up(req->sem);
419 req->rq_status = RQ_INACTIVE;
420 wake_up(&wait_for_request);
421 }
422 #endif
423 #endif
424
425 #ifdef MD_PERSONALITY
426 extern inline void end_redirect (struct request *req)
427 {
428 struct buffer_head * bh;
429
430 req->errors = 0;
431
432 if ((bh = req->bh) != NULL)
433 {
434 req->bh = bh->b_reqnext;
435 bh->b_reqnext = NULL;
436
437 if ((bh = req->bh) != NULL)
438 {
439 req->sector += req->current_nr_sectors;
440 req->current_nr_sectors = bh->b_size >> 9;
441
442 if (req->nr_sectors < req->current_nr_sectors)
443 {
444 req->nr_sectors = req->current_nr_sectors;
445 printk("end_redirect : buffer-list destroyed\n");
446 }
447
448 req->buffer = bh->b_data;
449 return;
450 }
451 }
452 }
453 #endif
454
455 #endif
456
457 #endif