This source file includes following definitions.
- end_request
1 #ifndef _BLK_H
2 #define _BLK_H
3
4 #include <linux/blkdev.h>
5 #include <linux/locks.h>
6
7
8
9
10
11
12
13
14
15
16
17 #define NR_REQUEST 64
18
19
20
21
22
23
24 #define IN_ORDER(s1,s2) \
25 ((s1)->cmd < (s2)->cmd || ((s1)->cmd == (s2)->cmd && \
26 ((s1)->dev < (s2)->dev || (((s1)->dev == (s2)->dev && \
27 (s1)->sector < (s2)->sector)))))
28
29
30
31
32
33 #define SECTOR_MASK (blksize_size[MAJOR_NR] && \
34 blksize_size[MAJOR_NR][MINOR(CURRENT->dev)] ? \
35 ((blksize_size[MAJOR_NR][MINOR(CURRENT->dev)] >> 9) - 1) : \
36 ((BLOCK_SIZE >> 9) - 1))
37
38 #define SUBSECTOR(block) (CURRENT->current_nr_sectors > 0)
39
40 extern unsigned long hd_init(unsigned long mem_start, unsigned long mem_end);
41 extern unsigned long cdu31a_init(unsigned long mem_start, unsigned long mem_end);
42 extern unsigned long mcd_init(unsigned long mem_start, unsigned long mem_end);
43 #ifdef CONFIG_SBPCD
44 extern unsigned long sbpcd_init(unsigned long, unsigned long);
45 #endif CONFIG_SBPCD
46 extern void set_device_ro(int dev,int flag);
47
48 extern void rd_load(void);
49 extern long rd_init(long mem_start, int length);
50 extern int ramdisk_size;
51
52 extern unsigned long xd_init(unsigned long mem_start, unsigned long mem_end);
53
54 #define RO_IOCTLS(dev,where) \
55 case BLKROSET: if (!suser()) return -EACCES; \
56 set_device_ro((dev),get_fs_long((long *) (where))); return 0; \
57 case BLKROGET: { int __err = verify_area(VERIFY_WRITE, (void *) (where), sizeof(long)); \
58 if (!__err) put_fs_long(0!=is_read_only(dev),(long *) (where)); return __err; }
59
60 #ifdef MAJOR_NR
61
62
63
64
65
66
67 #if (MAJOR_NR == MEM_MAJOR)
68
69
70 #define DEVICE_NAME "ramdisk"
71 #define DEVICE_REQUEST do_rd_request
72 #define DEVICE_NR(device) ((device) & 7)
73 #define DEVICE_ON(device)
74 #define DEVICE_OFF(device)
75
76 #elif (MAJOR_NR == FLOPPY_MAJOR)
77
78 static void floppy_on(unsigned int nr);
79 static void floppy_off(unsigned int nr);
80
81 #define DEVICE_NAME "floppy"
82 #define DEVICE_INTR do_floppy
83 #define DEVICE_REQUEST do_fd_request
84 #define DEVICE_NR(device) ( ((device) & 3) | (((device) & 0x80 ) >> 5 ))
85 #define DEVICE_ON(device) floppy_on(DEVICE_NR(device))
86 #define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
87
88 #elif (MAJOR_NR == HD_MAJOR)
89
90
91 #define DEVICE_NAME "harddisk"
92 #define DEVICE_INTR do_hd
93 #define DEVICE_TIMEOUT HD_TIMER
94 #define TIMEOUT_VALUE 600
95 #define DEVICE_REQUEST do_hd_request
96 #define DEVICE_NR(device) (MINOR(device)>>6)
97 #define DEVICE_ON(device)
98 #define DEVICE_OFF(device)
99
100 #elif (MAJOR_NR == SCSI_DISK_MAJOR)
101
102 #define DEVICE_NAME "scsidisk"
103 #define DEVICE_INTR do_sd
104 #define TIMEOUT_VALUE 200
105 #define DEVICE_REQUEST do_sd_request
106 #define DEVICE_NR(device) (MINOR(device) >> 4)
107 #define DEVICE_ON(device)
108 #define DEVICE_OFF(device)
109
110 #elif (MAJOR_NR == SCSI_TAPE_MAJOR)
111
112 #define DEVICE_NAME "scsitape"
113 #define DEVICE_INTR do_st
114 #define DEVICE_NR(device) (MINOR(device))
115 #define DEVICE_ON(device)
116 #define DEVICE_OFF(device)
117
118 #elif (MAJOR_NR == SCSI_CDROM_MAJOR)
119
120 #define DEVICE_NAME "CD-ROM"
121 #define DEVICE_INTR do_sr
122 #define DEVICE_REQUEST do_sr_request
123 #define DEVICE_NR(device) (MINOR(device))
124 #define DEVICE_ON(device)
125 #define DEVICE_OFF(device)
126
127 #elif (MAJOR_NR == XT_DISK_MAJOR)
128
129 #define DEVICE_NAME "xt disk"
130 #define DEVICE_REQUEST do_xd_request
131 #define DEVICE_NR(device) (MINOR(device) >> 6)
132 #define DEVICE_ON(device)
133 #define DEVICE_OFF(device)
134
135 #elif (MAJOR_NR == CDU31A_CDROM_MAJOR)
136
137 #define DEVICE_NAME "CDU31A"
138 #define DEVICE_REQUEST do_cdu31a_request
139 #define DEVICE_NR(device) (MINOR(device))
140 #define DEVICE_ON(device)
141 #define DEVICE_OFF(device)
142
143 #elif (MAJOR_NR == MITSUMI_CDROM_MAJOR)
144
145 #define DEVICE_NAME "Mitsumi CD-ROM"
146
147 #define DEVICE_REQUEST do_mcd_request
148 #define DEVICE_NR(device) (MINOR(device))
149 #define DEVICE_ON(device)
150 #define DEVICE_OFF(device)
151
152 #elif (MAJOR_NR == MATSUSHITA_CDROM_MAJOR)
153
154 #define DEVICE_NAME "Matsushita CD-ROM controller #1"
155 #define DEVICE_REQUEST do_sbpcd_request
156 #define DEVICE_NR(device) (MINOR(device))
157 #define DEVICE_ON(device)
158 #define DEVICE_OFF(device)
159
160 #elif (MAJOR_NR == MATSUSHITA_CDROM2_MAJOR)
161
162 #define DEVICE_NAME "Matsushita CD-ROM controller #2"
163 #define DEVICE_REQUEST do_sbpcd2_request
164 #define DEVICE_NR(device) (MINOR(device))
165 #define DEVICE_ON(device)
166 #define DEVICE_OFF(device)
167
168 #elif (MAJOR_NR == MATSUSHITA_CDROM3_MAJOR)
169
170 #define DEVICE_NAME "Matsushita CD-ROM controller #3"
171 #define DEVICE_REQUEST do_sbpcd3_request
172 #define DEVICE_NR(device) (MINOR(device))
173 #define DEVICE_ON(device)
174 #define DEVICE_OFF(device)
175
176 #elif (MAJOR_NR == MATSUSHITA_CDROM4_MAJOR)
177
178 #define DEVICE_NAME "Matsushita CD-ROM controller #4"
179 #define DEVICE_REQUEST do_sbpcd4_request
180 #define DEVICE_NR(device) (MINOR(device))
181 #define DEVICE_ON(device)
182 #define DEVICE_OFF(device)
183
184 #endif
185
186 #if (MAJOR_NR != SCSI_TAPE_MAJOR)
187
188 #ifndef CURRENT
189 #define CURRENT (blk_dev[MAJOR_NR].current_request)
190 #endif
191
192 #define CURRENT_DEV DEVICE_NR(CURRENT->dev)
193
194 #ifdef DEVICE_INTR
195 void (*DEVICE_INTR)(void) = NULL;
196 #endif
197 #ifdef DEVICE_TIMEOUT
198
199 #define SET_TIMER \
200 ((timer_table[DEVICE_TIMEOUT].expires = jiffies + TIMEOUT_VALUE), \
201 (timer_active |= 1<<DEVICE_TIMEOUT))
202
203 #define CLEAR_TIMER \
204 timer_active &= ~(1<<DEVICE_TIMEOUT)
205
206 #define SET_INTR(x) \
207 if ((DEVICE_INTR = (x)) != NULL) \
208 SET_TIMER; \
209 else \
210 CLEAR_TIMER;
211
212 #else
213
214 #define SET_INTR(x) (DEVICE_INTR = (x))
215
216 #endif
217 static void (DEVICE_REQUEST)(void);
218
219
220
221 #if ! SCSI_MAJOR(MAJOR_NR)
222
223 static void end_request(int uptodate)
224 {
225 struct request * req;
226 struct buffer_head * bh;
227
228 req = CURRENT;
229 req->errors = 0;
230 if (!uptodate) {
231 printk(DEVICE_NAME " I/O error\n");
232 printk("dev %04lX, sector %lu\n",
233 (unsigned long)req->dev, req->sector);
234 req->nr_sectors--;
235 req->nr_sectors &= ~SECTOR_MASK;
236 req->sector += (BLOCK_SIZE / 512);
237 req->sector &= ~SECTOR_MASK;
238 }
239
240 if ((bh = req->bh) != NULL) {
241 req->bh = bh->b_reqnext;
242 bh->b_reqnext = NULL;
243 bh->b_uptodate = uptodate;
244 if (!uptodate) bh->b_req = 0;
245 unlock_buffer(bh);
246 if ((bh = req->bh) != NULL) {
247 req->current_nr_sectors = bh->b_size >> 9;
248 if (req->nr_sectors < req->current_nr_sectors) {
249 req->nr_sectors = req->current_nr_sectors;
250 printk("end_request: buffer-list destroyed\n");
251 }
252 req->buffer = bh->b_data;
253 return;
254 }
255 }
256 DEVICE_OFF(req->dev);
257 CURRENT = req->next;
258 if (req->sem != NULL)
259 up(req->sem);
260 req->dev = -1;
261 wake_up(&wait_for_request);
262 }
263 #endif
264
265 #ifdef DEVICE_INTR
266 #define CLEAR_INTR SET_INTR(NULL)
267 #else
268 #define CLEAR_INTR
269 #endif
270
271 #define INIT_REQUEST \
272 if (!CURRENT) {\
273 CLEAR_INTR; \
274 return; \
275 } \
276 if (MAJOR(CURRENT->dev) != MAJOR_NR) \
277 panic(DEVICE_NAME ": request list destroyed"); \
278 if (CURRENT->bh) { \
279 if (!CURRENT->bh->b_lock) \
280 panic(DEVICE_NAME ": block not locked"); \
281 }
282
283 #endif
284
285 #endif
286 #endif