/[linux-patches]/genpatches-2.6/tags/2.6.21-4/2110_scsi-sd-printing.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.21-4/2110_scsi-sd-printing.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 974 - (show annotations) (download)
Thu May 24 23:17:59 2007 UTC (11 years, 1 month ago) by dsd
File size: 21580 byte(s)
2.6.21-4 release
1 From e73aec8247032ee730b5f38edf48922c4f72522e Mon Sep 17 00:00:00 2001
2 From: Martin K. Petersen <martin.petersen@oracle.com>
3 Date: Tue, 27 Feb 2007 22:40:55 -0500
4 Subject: [PATCH] [SCSI] sd: make printing use a common prefix
5
6 Make SCSI disk printing more consistent:
7
8 - Define sd_printk(), sd_print_sense_hdr() and sd_print_result()
9
10 - Move relevant header bits into sd.h
11
12 - Remove all the legacy disk_name passing and use scsi_disk pointers
13 where possible
14
15 - Switch printk() lines to the new sd_ functions so that output is
16 consistent
17
18 Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
19 Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
20 ---
21 drivers/scsi/sd.c | 253 ++++++++++++++++++++---------------------------------
22 include/scsi/sd.h | 70 +++++++++++++++
23 2 files changed, 165 insertions(+), 158 deletions(-)
24 create mode 100644 include/scsi/sd.h
25
26 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
27 index 5a8f55f..b5562b8 100644
28 --- a/drivers/scsi/sd.c
29 +++ b/drivers/scsi/sd.c
30 @@ -58,16 +58,10 @@
31 #include <scsi/scsi_host.h>
32 #include <scsi/scsi_ioctl.h>
33 #include <scsi/scsicam.h>
34 +#include <scsi/sd.h>
35
36 #include "scsi_logging.h"
37
38 -/*
39 - * More than enough for everybody ;) The huge number of majors
40 - * is a leftover from 16bit dev_t days, we don't really need that
41 - * much numberspace.
42 - */
43 -#define SD_MAJORS 16
44 -
45 MODULE_AUTHOR("Eric Youngdale");
46 MODULE_DESCRIPTION("SCSI disk (sd) driver");
47 MODULE_LICENSE("GPL");
48 @@ -89,45 +83,6 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK13_MAJOR);
49 MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK14_MAJOR);
50 MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_DISK15_MAJOR);
51
52 -/*
53 - * This is limited by the naming scheme enforced in sd_probe,
54 - * add another character to it if you really need more disks.
55 - */
56 -#define SD_MAX_DISKS (((26 * 26) + 26 + 1) * 26)
57 -
58 -/*
59 - * Time out in seconds for disks and Magneto-opticals (which are slower).
60 - */
61 -#define SD_TIMEOUT (30 * HZ)
62 -#define SD_MOD_TIMEOUT (75 * HZ)
63 -
64 -/*
65 - * Number of allowed retries
66 - */
67 -#define SD_MAX_RETRIES 5
68 -#define SD_PASSTHROUGH_RETRIES 1
69 -
70 -/*
71 - * Size of the initial data buffer for mode and read capacity data
72 - */
73 -#define SD_BUF_SIZE 512
74 -
75 -struct scsi_disk {
76 - struct scsi_driver *driver; /* always &sd_template */
77 - struct scsi_device *device;
78 - struct class_device cdev;
79 - struct gendisk *disk;
80 - unsigned int openers; /* protected by BKL for now, yuck */
81 - sector_t capacity; /* size in 512-byte sectors */
82 - u32 index;
83 - u8 media_present;
84 - u8 write_prot;
85 - unsigned WCE : 1; /* state of disk WCE bit */
86 - unsigned RCD : 1; /* state of disk RCD bit, unused */
87 - unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
88 -};
89 -#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
90 -
91 static DEFINE_IDR(sd_index_idr);
92 static DEFINE_SPINLOCK(sd_index_lock);
93
94 @@ -136,20 +91,6 @@ static DEFINE_SPINLOCK(sd_index_lock);
95 * object after last put) */
96 static DEFINE_MUTEX(sd_ref_mutex);
97
98 -static int sd_revalidate_disk(struct gendisk *disk);
99 -static void sd_rw_intr(struct scsi_cmnd * SCpnt);
100 -
101 -static int sd_probe(struct device *);
102 -static int sd_remove(struct device *);
103 -static void sd_shutdown(struct device *dev);
104 -static void sd_rescan(struct device *);
105 -static int sd_init_command(struct scsi_cmnd *);
106 -static int sd_issue_flush(struct device *, sector_t *);
107 -static void sd_prepare_flush(request_queue_t *, struct request *);
108 -static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
109 - unsigned char *buffer);
110 -static void scsi_disk_release(struct class_device *cdev);
111 -
112 static const char *sd_cache_types[] = {
113 "write through", "none", "write back",
114 "write back, no read (daft)"
115 @@ -199,7 +140,7 @@ static ssize_t sd_store_cache_type(struct class_device *cdev, const char *buf,
116 if (scsi_mode_select(sdp, 1, sp, 8, buffer_data, len, SD_TIMEOUT,
117 SD_MAX_RETRIES, &data, &sshdr)) {
118 if (scsi_sense_valid(&sshdr))
119 - scsi_print_sense_hdr(sdkp->disk->disk_name, &sshdr);
120 + sd_print_sense_hdr(sdkp, &sshdr);
121 return -EINVAL;
122 }
123 sd_revalidate_disk(sdkp->disk);
124 @@ -407,7 +348,8 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
125 */
126 if (sdp->sector_size == 1024) {
127 if ((block & 1) || (rq->nr_sectors & 1)) {
128 - printk(KERN_ERR "sd: Bad block number requested");
129 + scmd_printk(KERN_ERR, SCpnt,
130 + "Bad block number requested\n");
131 return 0;
132 } else {
133 block = block >> 1;
134 @@ -416,7 +358,8 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
135 }
136 if (sdp->sector_size == 2048) {
137 if ((block & 3) || (rq->nr_sectors & 3)) {
138 - printk(KERN_ERR "sd: Bad block number requested");
139 + scmd_printk(KERN_ERR, SCpnt,
140 + "Bad block number requested\n");
141 return 0;
142 } else {
143 block = block >> 2;
144 @@ -425,7 +368,8 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
145 }
146 if (sdp->sector_size == 4096) {
147 if ((block & 7) || (rq->nr_sectors & 7)) {
148 - printk(KERN_ERR "sd: Bad block number requested");
149 + scmd_printk(KERN_ERR, SCpnt,
150 + "Bad block number requested\n");
151 return 0;
152 } else {
153 block = block >> 3;
154 @@ -442,7 +386,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
155 SCpnt->cmnd[0] = READ_6;
156 SCpnt->sc_data_direction = DMA_FROM_DEVICE;
157 } else {
158 - printk(KERN_ERR "sd: Unknown command %x\n", rq->cmd_flags);
159 + scmd_printk(KERN_ERR, SCpnt, "Unknown command %x\n", rq->cmd_flags);
160 return 0;
161 }
162
163 @@ -490,7 +434,8 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
164 * during operation and thus turned off
165 * use_10_for_rw.
166 */
167 - printk(KERN_ERR "sd: FUA write on READ/WRITE(6) drive\n");
168 + scmd_printk(KERN_ERR, SCpnt,
169 + "FUA write on READ/WRITE(6) drive\n");
170 return 0;
171 }
172
173 @@ -786,9 +731,10 @@ not_present:
174 return 1;
175 }
176
177 -static int sd_sync_cache(struct scsi_device *sdp)
178 +static int sd_sync_cache(struct scsi_disk *sdkp)
179 {
180 int retries, res;
181 + struct scsi_device *sdp = sdkp->device;
182 struct scsi_sense_hdr sshdr;
183
184 if (!scsi_device_online(sdp))
185 @@ -809,12 +755,10 @@ static int sd_sync_cache(struct scsi_device *sdp)
186 break;
187 }
188
189 - if (res) { printk(KERN_WARNING "FAILED\n status = %x, message = %02x, "
190 - "host = %d, driver = %02x\n ",
191 - status_byte(res), msg_byte(res),
192 - host_byte(res), driver_byte(res));
193 - if (driver_byte(res) & DRIVER_SENSE)
194 - scsi_print_sense_hdr("sd", &sshdr);
195 + if (res) {
196 + sd_print_result(sdkp, res);
197 + if (driver_byte(res) & DRIVER_SENSE)
198 + sd_print_sense_hdr(sdkp, &sshdr);
199 }
200
201 return res;
202 @@ -823,14 +767,13 @@ static int sd_sync_cache(struct scsi_device *sdp)
203 static int sd_issue_flush(struct device *dev, sector_t *error_sector)
204 {
205 int ret = 0;
206 - struct scsi_device *sdp = to_scsi_device(dev);
207 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
208
209 if (!sdkp)
210 return -ENODEV;
211
212 if (sdkp->WCE)
213 - ret = sd_sync_cache(sdp);
214 + ret = sd_sync_cache(sdkp);
215 scsi_disk_put(sdkp);
216 return ret;
217 }
218 @@ -1025,7 +968,7 @@ static int media_not_present(struct scsi_disk *sdkp,
219 * spinup disk - called only in sd_revalidate_disk()
220 */
221 static void
222 -sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
223 +sd_spinup_disk(struct scsi_disk *sdkp)
224 {
225 unsigned char cmd[10];
226 unsigned long spintime_expire = 0;
227 @@ -1069,9 +1012,10 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
228 if ((driver_byte(the_result) & DRIVER_SENSE) == 0) {
229 /* no sense, TUR either succeeded or failed
230 * with a status error */
231 - if(!spintime && !scsi_status_is_good(the_result))
232 - printk(KERN_NOTICE "%s: Unit Not Ready, "
233 - "error = 0x%x\n", diskname, the_result);
234 + if(!spintime && !scsi_status_is_good(the_result)) {
235 + sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n");
236 + sd_print_result(sdkp, the_result);
237 + }
238 break;
239 }
240
241 @@ -1096,8 +1040,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
242 */
243 } else if (sense_valid && sshdr.sense_key == NOT_READY) {
244 if (!spintime) {
245 - printk(KERN_NOTICE "%s: Spinning up disk...",
246 - diskname);
247 + sd_printk(KERN_NOTICE, sdkp, "Spinning up disk...");
248 cmd[0] = START_STOP;
249 cmd[1] = 1; /* Return immediately */
250 memset((void *) &cmd[2], 0, 8);
251 @@ -1130,9 +1073,8 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
252 /* we don't understand the sense code, so it's
253 * probably pointless to loop */
254 if(!spintime) {
255 - printk(KERN_NOTICE "%s: Unit Not Ready, "
256 - "sense:\n", diskname);
257 - scsi_print_sense_hdr("", &sshdr);
258 + sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n");
259 + sd_print_sense_hdr(sdkp, &sshdr);
260 }
261 break;
262 }
263 @@ -1151,8 +1093,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
264 * read disk capacity
265 */
266 static void
267 -sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
268 - unsigned char *buffer)
269 +sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
270 {
271 unsigned char cmd[16];
272 int the_result, retries;
273 @@ -1191,18 +1132,12 @@ repeat:
274 } while (the_result && retries);
275
276 if (the_result && !longrc) {
277 - printk(KERN_NOTICE "%s : READ CAPACITY failed.\n"
278 - "%s : status=%x, message=%02x, host=%d, driver=%02x \n",
279 - diskname, diskname,
280 - status_byte(the_result),
281 - msg_byte(the_result),
282 - host_byte(the_result),
283 - driver_byte(the_result));
284 -
285 + sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY failed\n");
286 + sd_print_result(sdkp, the_result);
287 if (driver_byte(the_result) & DRIVER_SENSE)
288 - scsi_print_sense_hdr("sd", &sshdr);
289 + sd_print_sense_hdr(sdkp, &sshdr);
290 else
291 - printk("%s : sense not available. \n", diskname);
292 + sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n");
293
294 /* Set dirty bit for removable devices if not ready -
295 * sometimes drives will not report this properly. */
296 @@ -1218,16 +1153,10 @@ repeat:
297 return;
298 } else if (the_result && longrc) {
299 /* READ CAPACITY(16) has been failed */
300 - printk(KERN_NOTICE "%s : READ CAPACITY(16) failed.\n"
301 - "%s : status=%x, message=%02x, host=%d, driver=%02x \n",
302 - diskname, diskname,
303 - status_byte(the_result),
304 - msg_byte(the_result),
305 - host_byte(the_result),
306 - driver_byte(the_result));
307 - printk(KERN_NOTICE "%s : use 0xffffffff as device size\n",
308 - diskname);
309 -
310 + sd_printk(KERN_NOTICE, sdkp, "READ CAPACITY(16) failed\n");
311 + sd_print_result(sdkp, the_result);
312 + sd_printk(KERN_NOTICE, sdkp, "Use 0xffffffff as device size\n");
313 +
314 sdkp->capacity = 1 + (sector_t) 0xffffffff;
315 goto got_data;
316 }
317 @@ -1238,14 +1167,14 @@ repeat:
318 if (buffer[0] == 0xff && buffer[1] == 0xff &&
319 buffer[2] == 0xff && buffer[3] == 0xff) {
320 if(sizeof(sdkp->capacity) > 4) {
321 - printk(KERN_NOTICE "%s : very big device. try to use"
322 - " READ CAPACITY(16).\n", diskname);
323 + sd_printk(KERN_NOTICE, sdkp, "Very big device. "
324 + "Trying to use READ CAPACITY(16).\n");
325 longrc = 1;
326 goto repeat;
327 }
328 - printk(KERN_ERR "%s: too big for this kernel. Use a "
329 - "kernel compiled with support for large block "
330 - "devices.\n", diskname);
331 + sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use "
332 + "a kernel compiled with support for large "
333 + "block devices.\n");
334 sdkp->capacity = 0;
335 goto got_data;
336 }
337 @@ -1284,8 +1213,8 @@ repeat:
338 got_data:
339 if (sector_size == 0) {
340 sector_size = 512;
341 - printk(KERN_NOTICE "%s : sector size 0 reported, "
342 - "assuming 512.\n", diskname);
343 + sd_printk(KERN_NOTICE, sdkp, "Sector size 0 reported, "
344 + "assuming 512.\n");
345 }
346
347 if (sector_size != 512 &&
348 @@ -1293,8 +1222,8 @@ got_data:
349 sector_size != 2048 &&
350 sector_size != 4096 &&
351 sector_size != 256) {
352 - printk(KERN_NOTICE "%s : unsupported sector size "
353 - "%d.\n", diskname, sector_size);
354 + sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n",
355 + sector_size);
356 /*
357 * The user might want to re-format the drive with
358 * a supported sectorsize. Once this happens, it
359 @@ -1327,10 +1256,10 @@ got_data:
360 mb -= sz - 974;
361 sector_div(mb, 1950);
362
363 - printk(KERN_NOTICE "SCSI device %s: "
364 - "%llu %d-byte hdwr sectors (%llu MB)\n",
365 - diskname, (unsigned long long)sdkp->capacity,
366 - hard_sector, (unsigned long long)mb);
367 + sd_printk(KERN_NOTICE, sdkp,
368 + "%llu %d-byte hardware sectors (%llu MB)\n",
369 + (unsigned long long)sdkp->capacity,
370 + hard_sector, (unsigned long long)mb);
371 }
372
373 /* Rescale capacity to 512-byte units */
374 @@ -1362,8 +1291,7 @@ sd_do_mode_sense(struct scsi_device *sdp, int dbd, int modepage,
375 * called with buffer of length SD_BUF_SIZE
376 */
377 static void
378 -sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname,
379 - unsigned char *buffer)
380 +sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
381 {
382 int res;
383 struct scsi_device *sdp = sdkp->device;
384 @@ -1371,7 +1299,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname,
385
386 set_disk_ro(sdkp->disk, 0);
387 if (sdp->skip_ms_page_3f) {
388 - printk(KERN_NOTICE "%s: assuming Write Enabled\n", diskname);
389 + sd_printk(KERN_NOTICE, sdkp, "Assuming Write Enabled\n");
390 return;
391 }
392
393 @@ -1403,15 +1331,16 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname,
394 }
395
396 if (!scsi_status_is_good(res)) {
397 - printk(KERN_WARNING
398 - "%s: test WP failed, assume Write Enabled\n", diskname);
399 + sd_printk(KERN_WARNING, sdkp,
400 + "Test WP failed, assume Write Enabled\n");
401 } else {
402 sdkp->write_prot = ((data.device_specific & 0x80) != 0);
403 set_disk_ro(sdkp->disk, sdkp->write_prot);
404 - printk(KERN_NOTICE "%s: Write Protect is %s\n", diskname,
405 - sdkp->write_prot ? "on" : "off");
406 - printk(KERN_DEBUG "%s: Mode Sense: %02x %02x %02x %02x\n",
407 - diskname, buffer[0], buffer[1], buffer[2], buffer[3]);
408 + sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
409 + sdkp->write_prot ? "on" : "off");
410 + sd_printk(KERN_DEBUG, sdkp,
411 + "Mode Sense: %02x %02x %02x %02x\n",
412 + buffer[0], buffer[1], buffer[2], buffer[3]);
413 }
414 }
415
416 @@ -1420,8 +1349,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname,
417 * called with buffer of length SD_BUF_SIZE
418 */
419 static void
420 -sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
421 - unsigned char *buffer)
422 +sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
423 {
424 int len = 0, res;
425 struct scsi_device *sdp = sdkp->device;
426 @@ -1450,8 +1378,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
427
428 if (!data.header_length) {
429 modepage = 6;
430 - printk(KERN_ERR "%s: missing header in MODE_SENSE response\n",
431 - diskname);
432 + sd_printk(KERN_ERR, sdkp, "Missing header in MODE_SENSE response\n");
433 }
434
435 /* that went OK, now ask for the proper length */
436 @@ -1478,13 +1405,12 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
437 int offset = data.header_length + data.block_descriptor_length;
438
439 if (offset >= SD_BUF_SIZE - 2) {
440 - printk(KERN_ERR "%s: malformed MODE SENSE response",
441 - diskname);
442 + sd_printk(KERN_ERR, sdkp, "Malformed MODE SENSE response\n");
443 goto defaults;
444 }
445
446 if ((buffer[offset] & 0x3f) != modepage) {
447 - printk(KERN_ERR "%s: got wrong page\n", diskname);
448 + sd_printk(KERN_ERR, sdkp, "Got wrong page\n");
449 goto defaults;
450 }
451
452 @@ -1498,14 +1424,13 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
453
454 sdkp->DPOFUA = (data.device_specific & 0x10) != 0;
455 if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) {
456 - printk(KERN_NOTICE "SCSI device %s: uses "
457 - "READ/WRITE(6), disabling FUA\n", diskname);
458 + sd_printk(KERN_NOTICE, sdkp,
459 + "Uses READ/WRITE(6), disabling FUA\n");
460 sdkp->DPOFUA = 0;
461 }
462
463 - printk(KERN_NOTICE "SCSI device %s: "
464 - "write cache: %s, read cache: %s, %s\n",
465 - diskname,
466 + sd_printk(KERN_NOTICE, sdkp,
467 + "Write cache: %s, read cache: %s, %s\n",
468 sdkp->WCE ? "enabled" : "disabled",
469 sdkp->RCD ? "disabled" : "enabled",
470 sdkp->DPOFUA ? "supports DPO and FUA"
471 @@ -1518,15 +1443,13 @@ bad_sense:
472 if (scsi_sense_valid(&sshdr) &&
473 sshdr.sense_key == ILLEGAL_REQUEST &&
474 sshdr.asc == 0x24 && sshdr.ascq == 0x0)
475 - printk(KERN_NOTICE "%s: cache data unavailable\n",
476 - diskname); /* Invalid field in CDB */
477 + /* Invalid field in CDB */
478 + sd_printk(KERN_NOTICE, sdkp, "Cache data unavailable\n");
479 else
480 - printk(KERN_ERR "%s: asking for cache data failed\n",
481 - diskname);
482 + sd_printk(KERN_ERR, sdkp, "Asking for cache data failed\n");
483
484 defaults:
485 - printk(KERN_ERR "%s: assuming drive cache: write through\n",
486 - diskname);
487 + sd_printk(KERN_ERR, sdkp, "Assuming drive cache: write through\n");
488 sdkp->WCE = 0;
489 sdkp->RCD = 0;
490 sdkp->DPOFUA = 0;
491 @@ -1555,8 +1478,8 @@ static int sd_revalidate_disk(struct gendisk *disk)
492
493 buffer = kmalloc(SD_BUF_SIZE, GFP_KERNEL | __GFP_DMA);
494 if (!buffer) {
495 - printk(KERN_WARNING "(sd_revalidate_disk:) Memory allocation "
496 - "failure.\n");
497 + sd_printk(KERN_WARNING, sdkp, "sd_revalidate_disk: Memory "
498 + "allocation failure.\n");
499 goto out;
500 }
501
502 @@ -1568,16 +1491,16 @@ static int sd_revalidate_disk(struct gendisk *disk)
503 sdkp->WCE = 0;
504 sdkp->RCD = 0;
505
506 - sd_spinup_disk(sdkp, disk->disk_name);
507 + sd_spinup_disk(sdkp);
508
509 /*
510 * Without media there is no reason to ask; moreover, some devices
511 * react badly if we do.
512 */
513 if (sdkp->media_present) {
514 - sd_read_capacity(sdkp, disk->disk_name, buffer);
515 - sd_read_write_protect_flag(sdkp, disk->disk_name, buffer);
516 - sd_read_cache_type(sdkp, disk->disk_name, buffer);
517 + sd_read_capacity(sdkp, buffer);
518 + sd_read_write_protect_flag(sdkp, buffer);
519 + sd_read_cache_type(sdkp, buffer);
520 }
521
522 /*
523 @@ -1709,8 +1632,8 @@ static int sd_probe(struct device *dev)
524 dev_set_drvdata(dev, sdkp);
525 add_disk(gd);
526
527 - sdev_printk(KERN_NOTICE, sdp, "Attached scsi %sdisk %s\n",
528 - sdp->removable ? "removable " : "", gd->disk_name);
529 + sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
530 + sdp->removable ? "removable " : "");
531
532 return 0;
533
534 @@ -1781,16 +1704,14 @@ static void scsi_disk_release(struct class_device *cdev)
535 */
536 static void sd_shutdown(struct device *dev)
537 {
538 - struct scsi_device *sdp = to_scsi_device(dev);
539 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
540
541 if (!sdkp)
542 return; /* this can happen */
543
544 if (sdkp->WCE) {
545 - printk(KERN_NOTICE "Synchronizing SCSI cache for disk %s: \n",
546 - sdkp->disk->disk_name);
547 - sd_sync_cache(sdp);
548 + sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
549 + sd_sync_cache(sdkp);
550 }
551 scsi_disk_put(sdkp);
552 }
553 @@ -1852,3 +1773,19 @@ static void __exit exit_sd(void)
554
555 module_init(init_sd);
556 module_exit(exit_sd);
557 +
558 +static void sd_print_sense_hdr(struct scsi_disk *sdkp,
559 + struct scsi_sense_hdr *sshdr)
560 +{
561 + sd_printk(KERN_INFO, sdkp, "");
562 + scsi_show_sense_hdr(sshdr);
563 + sd_printk(KERN_INFO, sdkp, "");
564 + scsi_show_extd_sense(sshdr->asc, sshdr->ascq);
565 +}
566 +
567 +static void sd_print_result(struct scsi_disk *sdkp, int result)
568 +{
569 + sd_printk(KERN_INFO, sdkp, "");
570 + scsi_show_result(result);
571 +}
572 +
573 diff --git a/include/scsi/sd.h b/include/scsi/sd.h
574 new file mode 100644
575 index 0000000..82e6a84
576 --- /dev/null
577 +++ b/include/scsi/sd.h
578 @@ -0,0 +1,70 @@
579 +#ifndef _SCSI_DISK_H
580 +#define _SCSI_DISK_H
581 +
582 +/*
583 + * More than enough for everybody ;) The huge number of majors
584 + * is a leftover from 16bit dev_t days, we don't really need that
585 + * much numberspace.
586 + */
587 +#define SD_MAJORS 16
588 +
589 +/*
590 + * This is limited by the naming scheme enforced in sd_probe,
591 + * add another character to it if you really need more disks.
592 + */
593 +#define SD_MAX_DISKS (((26 * 26) + 26 + 1) * 26)
594 +
595 +/*
596 + * Time out in seconds for disks and Magneto-opticals (which are slower).
597 + */
598 +#define SD_TIMEOUT (30 * HZ)
599 +#define SD_MOD_TIMEOUT (75 * HZ)
600 +
601 +/*
602 + * Number of allowed retries
603 + */
604 +#define SD_MAX_RETRIES 5
605 +#define SD_PASSTHROUGH_RETRIES 1
606 +
607 +/*
608 + * Size of the initial data buffer for mode and read capacity data
609 + */
610 +#define SD_BUF_SIZE 512
611 +
612 +struct scsi_disk {
613 + struct scsi_driver *driver; /* always &sd_template */
614 + struct scsi_device *device;
615 + struct class_device cdev;
616 + struct gendisk *disk;
617 + unsigned int openers; /* protected by BKL for now, yuck */
618 + sector_t capacity; /* size in 512-byte sectors */
619 + u32 index;
620 + u8 media_present;
621 + u8 write_prot;
622 + unsigned WCE : 1; /* state of disk WCE bit */
623 + unsigned RCD : 1; /* state of disk RCD bit, unused */
624 + unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
625 +};
626 +#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
627 +
628 +static int sd_revalidate_disk(struct gendisk *disk);
629 +static void sd_rw_intr(struct scsi_cmnd * SCpnt);
630 +static int sd_probe(struct device *);
631 +static int sd_remove(struct device *);
632 +static void sd_shutdown(struct device *dev);
633 +static void sd_rescan(struct device *);
634 +static int sd_init_command(struct scsi_cmnd *);
635 +static int sd_issue_flush(struct device *, sector_t *);
636 +static void sd_prepare_flush(request_queue_t *, struct request *);
637 +static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
638 +static void scsi_disk_release(struct class_device *cdev);
639 +static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
640 +static void sd_print_result(struct scsi_disk *, int);
641 +
642 +#define sd_printk(prefix, sdsk, fmt, a...) \
643 + (sdsk)->disk ? \
644 + sdev_printk(prefix, (sdsk)->device, "[%s] " fmt, \
645 + (sdsk)->disk->disk_name, ##a) : \
646 + sdev_printk(prefix, (sdsk)->device, fmt, ##a)
647 +
648 +#endif /* _SCSI_DISK_H */
649 --
650 1.5.1.4
651

  ViewVC Help
Powered by ViewVC 1.1.20