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