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