diff options
author | Borislav Petkov <petkovbb@googlemail.com> | 2008-04-26 16:25:15 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-26 16:25:15 -0400 |
commit | 5a3ea3b424369ea8a661f2fe8f4b24ffc90e4543 (patch) | |
tree | dc494ee536031bf5f76086ede4843f3776e54b9c /drivers/ide/ide-cd.c | |
parent | 5e657a9e29baa0d8f5c0cf99372100d397340f00 (diff) |
ide-cd: fixup comments
[bart: minor fixups, md5sum checked]
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 401 |
1 files changed, 191 insertions, 210 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 90714494c796..cc9e7f40d2ea 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -39,7 +39,8 @@ | |||
39 | #include <linux/mutex.h> | 39 | #include <linux/mutex.h> |
40 | #include <linux/bcd.h> | 40 | #include <linux/bcd.h> |
41 | 41 | ||
42 | #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ | 42 | /* For SCSI -> ATAPI command conversion */ |
43 | #include <scsi/scsi.h> | ||
43 | 44 | ||
44 | #include <linux/irq.h> | 45 | #include <linux/irq.h> |
45 | #include <linux/io.h> | 46 | #include <linux/io.h> |
@@ -77,12 +78,11 @@ static void ide_cd_put(struct cdrom_info *cd) | |||
77 | mutex_unlock(&idecd_ref_mutex); | 78 | mutex_unlock(&idecd_ref_mutex); |
78 | } | 79 | } |
79 | 80 | ||
80 | /**************************************************************************** | 81 | /* |
81 | * Generic packet command support and error handling routines. | 82 | * Generic packet command support and error handling routines. |
82 | */ | 83 | */ |
83 | 84 | ||
84 | /* Mark that we've seen a media change, and invalidate our internal | 85 | /* Mark that we've seen a media change and invalidate our internal buffers. */ |
85 | buffers. */ | ||
86 | static void cdrom_saw_media_change(ide_drive_t *drive) | 86 | static void cdrom_saw_media_change(ide_drive_t *drive) |
87 | { | 87 | { |
88 | struct cdrom_info *cd = drive->driver_data; | 88 | struct cdrom_info *cd = drive->driver_data; |
@@ -105,9 +105,8 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | |||
105 | break; | 105 | break; |
106 | case NOT_READY: | 106 | case NOT_READY: |
107 | /* | 107 | /* |
108 | * don't care about tray state messages for | 108 | * don't care about tray state messages for e.g. capacity |
109 | * e.g. capacity commands or in-progress or | 109 | * commands or in-progress or becoming ready |
110 | * becoming ready | ||
111 | */ | 110 | */ |
112 | if (sense->asc == 0x3a || sense->asc == 0x04) | 111 | if (sense->asc == 0x3a || sense->asc == 0x04) |
113 | break; | 112 | break; |
@@ -115,8 +114,8 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | |||
115 | break; | 114 | break; |
116 | case ILLEGAL_REQUEST: | 115 | case ILLEGAL_REQUEST: |
117 | /* | 116 | /* |
118 | * don't log START_STOP unit with LoEj set, since | 117 | * don't log START_STOP unit with LoEj set, since we cannot |
119 | * we cannot reliably check if drive can auto-close | 118 | * reliably check if drive can auto-close |
120 | */ | 119 | */ |
121 | if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24) | 120 | if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24) |
122 | break; | 121 | break; |
@@ -124,9 +123,9 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | |||
124 | break; | 123 | break; |
125 | case UNIT_ATTENTION: | 124 | case UNIT_ATTENTION: |
126 | /* | 125 | /* |
127 | * Make good and sure we've seen this potential media | 126 | * Make good and sure we've seen this potential media change. |
128 | * change. Some drives (i.e. Creative) fail to present | 127 | * Some drives (i.e. Creative) fail to present the correct sense |
129 | * the correct sense key in the error register. | 128 | * key in the error register. |
130 | */ | 129 | */ |
131 | cdrom_saw_media_change(drive); | 130 | cdrom_saw_media_change(drive); |
132 | break; | 131 | break; |
@@ -151,15 +150,16 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
151 | return; | 150 | return; |
152 | 151 | ||
153 | /* | 152 | /* |
154 | * If a read toc is executed for a CD-R or CD-RW medium where | 153 | * If a read toc is executed for a CD-R or CD-RW medium where the first |
155 | * the first toc has not been recorded yet, it will fail with | 154 | * toc has not been recorded yet, it will fail with 05/24/00 (which is a |
156 | * 05/24/00 (which is a confusing error) | 155 | * confusing error) |
157 | */ | 156 | */ |
158 | if (failed_command && failed_command->cmd[0] == GPCMD_READ_TOC_PMA_ATIP) | 157 | if (failed_command && failed_command->cmd[0] == GPCMD_READ_TOC_PMA_ATIP) |
159 | if (sense->sense_key == 0x05 && sense->asc == 0x24) | 158 | if (sense->sense_key == 0x05 && sense->asc == 0x24) |
160 | return; | 159 | return; |
161 | 160 | ||
162 | if (sense->error_code == 0x70) { /* Current Error */ | 161 | /* current error */ |
162 | if (sense->error_code == 0x70) { | ||
163 | switch (sense->sense_key) { | 163 | switch (sense->sense_key) { |
164 | case MEDIUM_ERROR: | 164 | case MEDIUM_ERROR: |
165 | case VOLUME_OVERFLOW: | 165 | case VOLUME_OVERFLOW: |
@@ -178,7 +178,8 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
178 | if (bio_sectors < 4) | 178 | if (bio_sectors < 4) |
179 | bio_sectors = 4; | 179 | bio_sectors = 4; |
180 | if (drive->queue->hardsect_size == 2048) | 180 | if (drive->queue->hardsect_size == 2048) |
181 | sector <<= 2; /* Device sector size is 2K */ | 181 | /* device sector size is 2K */ |
182 | sector <<= 2; | ||
182 | sector &= ~(bio_sectors - 1); | 183 | sector &= ~(bio_sectors - 1); |
183 | valid = (sector - failed_command->sector) << 9; | 184 | valid = (sector - failed_command->sector) << 9; |
184 | 185 | ||
@@ -194,9 +195,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
194 | ide_cd_log_error(drive->name, failed_command, sense); | 195 | ide_cd_log_error(drive->name, failed_command, sense); |
195 | } | 196 | } |
196 | 197 | ||
197 | /* | 198 | /* Initialize a ide-cd packet command request */ |
198 | * Initialize a ide-cd packet command request | ||
199 | */ | ||
200 | void ide_cd_init_rq(ide_drive_t *drive, struct request *rq) | 199 | void ide_cd_init_rq(ide_drive_t *drive, struct request *rq) |
201 | { | 200 | { |
202 | struct cdrom_info *cd = drive->driver_data; | 201 | struct cdrom_info *cd = drive->driver_data; |
@@ -252,7 +251,7 @@ static void cdrom_end_request(ide_drive_t *drive, int uptodate) | |||
252 | } | 251 | } |
253 | cdrom_analyze_sense_data(drive, failed, sense); | 252 | cdrom_analyze_sense_data(drive, failed, sense); |
254 | /* | 253 | /* |
255 | * now end failed request | 254 | * now end the failed request |
256 | */ | 255 | */ |
257 | if (blk_fs_request(failed)) { | 256 | if (blk_fs_request(failed)) { |
258 | if (ide_end_dequeued_request(drive, failed, 0, | 257 | if (ide_end_dequeued_request(drive, failed, 0, |
@@ -287,14 +286,17 @@ static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 sta | |||
287 | ide_dump_status(drive, msg, stat); | 286 | ide_dump_status(drive, msg, stat); |
288 | } | 287 | } |
289 | 288 | ||
290 | /* Returns 0 if the request should be continued. | 289 | /* |
291 | Returns 1 if the request was ended. */ | 290 | * Returns: |
291 | * 0: if the request should be continued. | ||
292 | * 1: if the request was ended. | ||
293 | */ | ||
292 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | 294 | static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) |
293 | { | 295 | { |
294 | struct request *rq = HWGROUP(drive)->rq; | 296 | struct request *rq = HWGROUP(drive)->rq; |
295 | int stat, err, sense_key; | 297 | int stat, err, sense_key; |
296 | 298 | ||
297 | /* Check for errors. */ | 299 | /* check for errors */ |
298 | stat = ide_read_status(drive); | 300 | stat = ide_read_status(drive); |
299 | 301 | ||
300 | if (stat_ret) | 302 | if (stat_ret) |
@@ -303,7 +305,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
303 | if (OK_STAT(stat, good_stat, BAD_R_STAT)) | 305 | if (OK_STAT(stat, good_stat, BAD_R_STAT)) |
304 | return 0; | 306 | return 0; |
305 | 307 | ||
306 | /* Get the IDE error register. */ | 308 | /* get the IDE error register */ |
307 | err = ide_read_error(drive); | 309 | err = ide_read_error(drive); |
308 | sense_key = err >> 4; | 310 | sense_key = err >> 4; |
309 | 311 | ||
@@ -313,10 +315,11 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
313 | } | 315 | } |
314 | 316 | ||
315 | if (blk_sense_request(rq)) { | 317 | if (blk_sense_request(rq)) { |
316 | /* We got an error trying to get sense info | 318 | /* |
317 | from the drive (probably while trying | 319 | * We got an error trying to get sense info from the drive |
318 | to recover from a former error). Just give up. */ | 320 | * (probably while trying to recover from a former error). |
319 | 321 | * Just give up. | |
322 | */ | ||
320 | rq->cmd_flags |= REQ_FAILED; | 323 | rq->cmd_flags |= REQ_FAILED; |
321 | cdrom_end_request(drive, 0); | 324 | cdrom_end_request(drive, 0); |
322 | ide_error(drive, "request sense failure", stat); | 325 | ide_error(drive, "request sense failure", stat); |
@@ -332,13 +335,12 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
332 | if (blk_pc_request(rq) && !rq->errors) | 335 | if (blk_pc_request(rq) && !rq->errors) |
333 | rq->errors = SAM_STAT_CHECK_CONDITION; | 336 | rq->errors = SAM_STAT_CHECK_CONDITION; |
334 | 337 | ||
335 | /* Check for tray open. */ | 338 | /* check for tray open */ |
336 | if (sense_key == NOT_READY) { | 339 | if (sense_key == NOT_READY) { |
337 | cdrom_saw_media_change(drive); | 340 | cdrom_saw_media_change(drive); |
338 | } else if (sense_key == UNIT_ATTENTION) { | 341 | } else if (sense_key == UNIT_ATTENTION) { |
339 | /* Check for media change. */ | 342 | /* check for media change */ |
340 | cdrom_saw_media_change(drive); | 343 | cdrom_saw_media_change(drive); |
341 | /*printk("%s: media changed\n",drive->name);*/ | ||
342 | return 0; | 344 | return 0; |
343 | } else if (sense_key == ILLEGAL_REQUEST && | 345 | } else if (sense_key == ILLEGAL_REQUEST && |
344 | rq->cmd[0] == GPCMD_START_STOP_UNIT) { | 346 | rq->cmd[0] == GPCMD_START_STOP_UNIT) { |
@@ -350,7 +352,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
350 | * cdrom_log_sense() knows this! | 352 | * cdrom_log_sense() knows this! |
351 | */ | 353 | */ |
352 | } else if (!(rq->cmd_flags & REQ_QUIET)) { | 354 | } else if (!(rq->cmd_flags & REQ_QUIET)) { |
353 | /* Otherwise, print an error. */ | 355 | /* otherwise, print an error */ |
354 | ide_dump_status(drive, "packet command error", stat); | 356 | ide_dump_status(drive, "packet command error", stat); |
355 | } | 357 | } |
356 | 358 | ||
@@ -366,25 +368,27 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
366 | } else if (blk_fs_request(rq)) { | 368 | } else if (blk_fs_request(rq)) { |
367 | int do_end_request = 0; | 369 | int do_end_request = 0; |
368 | 370 | ||
369 | /* Handle errors from READ and WRITE requests. */ | 371 | /* handle errors from READ and WRITE requests */ |
370 | 372 | ||
371 | if (blk_noretry_request(rq)) | 373 | if (blk_noretry_request(rq)) |
372 | do_end_request = 1; | 374 | do_end_request = 1; |
373 | 375 | ||
374 | if (sense_key == NOT_READY) { | 376 | if (sense_key == NOT_READY) { |
375 | /* Tray open. */ | 377 | /* tray open */ |
376 | if (rq_data_dir(rq) == READ) { | 378 | if (rq_data_dir(rq) == READ) { |
377 | cdrom_saw_media_change(drive); | 379 | cdrom_saw_media_change(drive); |
378 | 380 | ||
379 | /* Fail the request. */ | 381 | /* fail the request */ |
380 | printk("%s: tray open\n", drive->name); | 382 | printk("%s: tray open\n", drive->name); |
381 | do_end_request = 1; | 383 | do_end_request = 1; |
382 | } else { | 384 | } else { |
383 | struct cdrom_info *info = drive->driver_data; | 385 | struct cdrom_info *info = drive->driver_data; |
384 | 386 | ||
385 | /* allow the drive 5 seconds to recover, some | 387 | /* |
388 | * Allow the drive 5 seconds to recover, some | ||
386 | * devices will return this error while flushing | 389 | * devices will return this error while flushing |
387 | * data from cache */ | 390 | * data from cache. |
391 | */ | ||
388 | if (!rq->errors) | 392 | if (!rq->errors) |
389 | info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY; | 393 | info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY; |
390 | rq->errors = 1; | 394 | rq->errors = 1; |
@@ -394,8 +398,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
394 | unsigned long flags; | 398 | unsigned long flags; |
395 | 399 | ||
396 | /* | 400 | /* |
397 | * take a breather relying on the | 401 | * take a breather relying on the unplug |
398 | * unplug timer to kick us again | 402 | * timer to kick us again |
399 | */ | 403 | */ |
400 | spin_lock_irqsave(&ide_lock, flags); | 404 | spin_lock_irqsave(&ide_lock, flags); |
401 | blk_plug_device(drive->queue); | 405 | blk_plug_device(drive->queue); |
@@ -404,55 +408,54 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
404 | } | 408 | } |
405 | } | 409 | } |
406 | } else if (sense_key == UNIT_ATTENTION) { | 410 | } else if (sense_key == UNIT_ATTENTION) { |
407 | /* Media change. */ | 411 | /* media change */ |
408 | cdrom_saw_media_change (drive); | 412 | cdrom_saw_media_change (drive); |
409 | 413 | ||
410 | /* | 414 | /* |
411 | * Arrange to retry the request. | 415 | * Arrange to retry the request but be sure to give up |
412 | * But be sure to give up if we've retried | 416 | * if we've retried too many times. |
413 | * too many times. | ||
414 | */ | 417 | */ |
415 | if (++rq->errors > ERROR_MAX) | 418 | if (++rq->errors > ERROR_MAX) |
416 | do_end_request = 1; | 419 | do_end_request = 1; |
417 | } else if (sense_key == ILLEGAL_REQUEST || | 420 | } else if (sense_key == ILLEGAL_REQUEST || |
418 | sense_key == DATA_PROTECT) { | 421 | sense_key == DATA_PROTECT) { |
419 | /* | 422 | /* |
420 | * No point in retrying after an illegal | 423 | * No point in retrying after an illegal request or data |
421 | * request or data protect error. | 424 | * protect error. |
422 | */ | 425 | */ |
423 | ide_dump_status_no_sense(drive, "command error", stat); | 426 | ide_dump_status_no_sense(drive, "command error", stat); |
424 | do_end_request = 1; | 427 | do_end_request = 1; |
425 | } else if (sense_key == MEDIUM_ERROR) { | 428 | } else if (sense_key == MEDIUM_ERROR) { |
426 | /* | 429 | /* |
427 | * No point in re-trying a zillion times on a bad | 430 | * No point in re-trying a zillion times on a bad |
428 | * sector... If we got here the error is not correctable | 431 | * sector. If we got here the error is not correctable. |
429 | */ | 432 | */ |
430 | ide_dump_status_no_sense(drive, "media error (bad sector)", stat); | 433 | ide_dump_status_no_sense(drive, "media error (bad sector)", stat); |
431 | do_end_request = 1; | 434 | do_end_request = 1; |
432 | } else if (sense_key == BLANK_CHECK) { | 435 | } else if (sense_key == BLANK_CHECK) { |
433 | /* Disk appears blank ?? */ | 436 | /* disk appears blank ?? */ |
434 | ide_dump_status_no_sense(drive, "media error (blank)", stat); | 437 | ide_dump_status_no_sense(drive, "media error (blank)", stat); |
435 | do_end_request = 1; | 438 | do_end_request = 1; |
436 | } else if ((err & ~ABRT_ERR) != 0) { | 439 | } else if ((err & ~ABRT_ERR) != 0) { |
437 | /* Go to the default handler | 440 | /* go to the default handler for other errors */ |
438 | for other errors. */ | ||
439 | ide_error(drive, "cdrom_decode_status", stat); | 441 | ide_error(drive, "cdrom_decode_status", stat); |
440 | return 1; | 442 | return 1; |
441 | } else if ((++rq->errors > ERROR_MAX)) { | 443 | } else if ((++rq->errors > ERROR_MAX)) { |
442 | /* We've racked up too many retries. Abort. */ | 444 | /* we've racked up too many retries, abort */ |
443 | do_end_request = 1; | 445 | do_end_request = 1; |
444 | } | 446 | } |
445 | 447 | ||
446 | /* End a request through request sense analysis when we have | 448 | /* |
447 | sense data. We need this in order to perform end of media | 449 | * End a request through request sense analysis when we have |
448 | processing */ | 450 | * sense data. We need this in order to perform end of media |
449 | 451 | * processing. | |
452 | */ | ||
450 | if (do_end_request) | 453 | if (do_end_request) |
451 | goto end_request; | 454 | goto end_request; |
452 | 455 | ||
453 | /* | 456 | /* |
454 | * If we got a CHECK_CONDITION status, | 457 | * If we got a CHECK_CONDITION status, queue |
455 | * queue a request sense command. | 458 | * a request sense command. |
456 | */ | 459 | */ |
457 | if (stat & ERR_STAT) | 460 | if (stat & ERR_STAT) |
458 | cdrom_queue_request_sense(drive, NULL, NULL); | 461 | cdrom_queue_request_sense(drive, NULL, NULL); |
@@ -461,7 +464,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
461 | cdrom_end_request(drive, 0); | 464 | cdrom_end_request(drive, 0); |
462 | } | 465 | } |
463 | 466 | ||
464 | /* Retry, or handle the next request. */ | 467 | /* retry, or handle the next request */ |
465 | return 1; | 468 | return 1; |
466 | 469 | ||
467 | end_request: | 470 | end_request: |
@@ -486,10 +489,10 @@ static int cdrom_timer_expiry(ide_drive_t *drive) | |||
486 | unsigned long wait = 0; | 489 | unsigned long wait = 0; |
487 | 490 | ||
488 | /* | 491 | /* |
489 | * Some commands are *slow* and normally take a long time to | 492 | * Some commands are *slow* and normally take a long time to complete. |
490 | * complete. Usually we can use the ATAPI "disconnect" to bypass | 493 | * Usually we can use the ATAPI "disconnect" to bypass this, but not all |
491 | * this, but not all commands/drives support that. Let | 494 | * commands/drives support that. Let ide_timer_expiry keep polling us |
492 | * ide_timer_expiry keep polling us for these. | 495 | * for these. |
493 | */ | 496 | */ |
494 | switch (rq->cmd[0]) { | 497 | switch (rq->cmd[0]) { |
495 | case GPCMD_BLANK: | 498 | case GPCMD_BLANK: |
@@ -508,13 +511,14 @@ static int cdrom_timer_expiry(ide_drive_t *drive) | |||
508 | return wait; | 511 | return wait; |
509 | } | 512 | } |
510 | 513 | ||
511 | /* Set up the device registers for transferring a packet command on DEV, | 514 | /* |
512 | expecting to later transfer XFERLEN bytes. HANDLER is the routine | 515 | * Set up the device registers for transferring a packet command on DEV, |
513 | which actually transfers the command to the drive. If this is a | 516 | * expecting to later transfer XFERLEN bytes. HANDLER is the routine |
514 | drq_interrupt device, this routine will arrange for HANDLER to be | 517 | * which actually transfers the command to the drive. If this is a |
515 | called when the interrupt from the drive arrives. Otherwise, HANDLER | 518 | * drq_interrupt device, this routine will arrange for HANDLER to be |
516 | will be called immediately after the drive is prepared for the transfer. */ | 519 | * called when the interrupt from the drive arrives. Otherwise, HANDLER |
517 | 520 | * will be called immediately after the drive is prepared for the transfer. | |
521 | */ | ||
518 | static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | 522 | static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, |
519 | int xferlen, | 523 | int xferlen, |
520 | ide_handler_t *handler) | 524 | ide_handler_t *handler) |
@@ -523,7 +527,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
523 | struct cdrom_info *info = drive->driver_data; | 527 | struct cdrom_info *info = drive->driver_data; |
524 | ide_hwif_t *hwif = drive->hwif; | 528 | ide_hwif_t *hwif = drive->hwif; |
525 | 529 | ||
526 | /* Wait for the controller to be idle. */ | 530 | /* wait for the controller to be idle */ |
527 | if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY)) | 531 | if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY)) |
528 | return startstop; | 532 | return startstop; |
529 | 533 | ||
@@ -531,7 +535,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
531 | if (info->dma) | 535 | if (info->dma) |
532 | info->dma = !hwif->dma_setup(drive); | 536 | info->dma = !hwif->dma_setup(drive); |
533 | 537 | ||
534 | /* Set up the controller registers. */ | 538 | /* set up the controller registers */ |
535 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | | 539 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | |
536 | IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); | 540 | IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); |
537 | 541 | ||
@@ -557,11 +561,12 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
557 | } | 561 | } |
558 | } | 562 | } |
559 | 563 | ||
560 | /* Send a packet command to DRIVE described by CMD_BUF and CMD_LEN. | 564 | /* |
561 | The device registers must have already been prepared | 565 | * Send a packet command to DRIVE described by CMD_BUF and CMD_LEN. The device |
562 | by cdrom_start_packet_command. | 566 | * registers must have already been prepared by cdrom_start_packet_command. |
563 | HANDLER is the interrupt handler to call when the command completes | 567 | * HANDLER is the interrupt handler to call when the command completes or |
564 | or there's data ready. */ | 568 | * there's data ready. |
569 | */ | ||
565 | #define ATAPI_MIN_CDB_BYTES 12 | 570 | #define ATAPI_MIN_CDB_BYTES 12 |
566 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | 571 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, |
567 | struct request *rq, | 572 | struct request *rq, |
@@ -573,24 +578,26 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | |||
573 | ide_startstop_t startstop; | 578 | ide_startstop_t startstop; |
574 | 579 | ||
575 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { | 580 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { |
576 | /* Here we should have been called after receiving an interrupt | 581 | /* |
577 | from the device. DRQ should how be set. */ | 582 | * Here we should have been called after receiving an interrupt |
583 | * from the device. DRQ should how be set. | ||
584 | */ | ||
578 | 585 | ||
579 | /* Check for errors. */ | 586 | /* check for errors */ |
580 | if (cdrom_decode_status(drive, DRQ_STAT, NULL)) | 587 | if (cdrom_decode_status(drive, DRQ_STAT, NULL)) |
581 | return ide_stopped; | 588 | return ide_stopped; |
582 | 589 | ||
583 | /* Ok, next interrupt will be DMA interrupt. */ | 590 | /* ok, next interrupt will be DMA interrupt */ |
584 | if (info->dma) | 591 | if (info->dma) |
585 | drive->waiting_for_dma = 1; | 592 | drive->waiting_for_dma = 1; |
586 | } else { | 593 | } else { |
587 | /* Otherwise, we must wait for DRQ to get set. */ | 594 | /* otherwise, we must wait for DRQ to get set */ |
588 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, | 595 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, |
589 | BUSY_STAT, WAIT_READY)) | 596 | BUSY_STAT, WAIT_READY)) |
590 | return startstop; | 597 | return startstop; |
591 | } | 598 | } |
592 | 599 | ||
593 | /* Arm the interrupt handler. */ | 600 | /* arm the interrupt handler */ |
594 | ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry); | 601 | ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry); |
595 | 602 | ||
596 | /* ATAPI commands get padded out to 12 bytes minimum */ | 603 | /* ATAPI commands get padded out to 12 bytes minimum */ |
@@ -598,20 +605,19 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | |||
598 | if (cmd_len < ATAPI_MIN_CDB_BYTES) | 605 | if (cmd_len < ATAPI_MIN_CDB_BYTES) |
599 | cmd_len = ATAPI_MIN_CDB_BYTES; | 606 | cmd_len = ATAPI_MIN_CDB_BYTES; |
600 | 607 | ||
601 | /* Send the command to the device. */ | 608 | /* send the command to the device */ |
602 | HWIF(drive)->atapi_output_bytes(drive, rq->cmd, cmd_len); | 609 | HWIF(drive)->atapi_output_bytes(drive, rq->cmd, cmd_len); |
603 | 610 | ||
604 | /* Start the DMA if need be */ | 611 | /* start the DMA if need be */ |
605 | if (info->dma) | 612 | if (info->dma) |
606 | hwif->dma_start(drive); | 613 | hwif->dma_start(drive); |
607 | 614 | ||
608 | return ide_started; | 615 | return ide_started; |
609 | } | 616 | } |
610 | 617 | ||
611 | /**************************************************************************** | 618 | /* |
612 | * Block read functions. | 619 | * Block read functions. |
613 | */ | 620 | */ |
614 | |||
615 | static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) | 621 | static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) |
616 | { | 622 | { |
617 | while (len > 0) { | 623 | while (len > 0) { |
@@ -649,20 +655,21 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq, | |||
649 | ide_hwif_t *hwif = drive->hwif; | 655 | ide_hwif_t *hwif = drive->hwif; |
650 | xfer_func_t *xf; | 656 | xfer_func_t *xf; |
651 | 657 | ||
652 | /* Whoops... */ | 658 | /* whoops... */ |
653 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", | 659 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", |
654 | drive->name, __func__); | 660 | drive->name, __func__); |
655 | 661 | ||
656 | xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes; | 662 | xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes; |
657 | ide_cd_pad_transfer(drive, xf, len); | 663 | ide_cd_pad_transfer(drive, xf, len); |
658 | } else if (rw == 0 && ireason == 1) { | 664 | } else if (rw == 0 && ireason == 1) { |
659 | /* Some drives (ASUS) seem to tell us that status | 665 | /* |
660 | * info is available. just get it and ignore. | 666 | * Some drives (ASUS) seem to tell us that status info is |
667 | * available. Just get it and ignore. | ||
661 | */ | 668 | */ |
662 | (void)ide_read_status(drive); | 669 | (void)ide_read_status(drive); |
663 | return 0; | 670 | return 0; |
664 | } else { | 671 | } else { |
665 | /* Drive wants a command packet, or invalid ireason... */ | 672 | /* drive wants a command packet, or invalid ireason... */ |
666 | printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", | 673 | printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", |
667 | drive->name, __func__, ireason); | 674 | drive->name, __func__, ireason); |
668 | } | 675 | } |
@@ -702,10 +709,10 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) | |||
702 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); | 709 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); |
703 | 710 | ||
704 | /* | 711 | /* |
705 | * Routine to send a read/write packet command to the drive. | 712 | * Routine to send a read/write packet command to the drive. This is usually |
706 | * This is usually called directly from cdrom_start_{read,write}(). | 713 | * called directly from cdrom_start_{read,write}(). However, for drq_interrupt |
707 | * However, for drq_interrupt devices, it is called from an interrupt | 714 | * devices, it is called from an interrupt when the drive is ready to accept |
708 | * when the drive is ready to accept the command. | 715 | * the command. |
709 | */ | 716 | */ |
710 | static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | 717 | static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) |
711 | { | 718 | { |
@@ -727,7 +734,7 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | |||
727 | * is larger than the buffer size. | 734 | * is larger than the buffer size. |
728 | */ | 735 | */ |
729 | if (nskip > 0) { | 736 | if (nskip > 0) { |
730 | /* Sanity check... */ | 737 | /* sanity check... */ |
731 | if (rq->current_nr_sectors != | 738 | if (rq->current_nr_sectors != |
732 | bio_cur_sectors(rq->bio)) { | 739 | bio_cur_sectors(rq->bio)) { |
733 | printk(KERN_ERR "%s: %s: buffer botch (%u)\n", | 740 | printk(KERN_ERR "%s: %s: buffer botch (%u)\n", |
@@ -744,10 +751,10 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | |||
744 | /* the immediate bit */ | 751 | /* the immediate bit */ |
745 | rq->cmd[1] = 1 << 3; | 752 | rq->cmd[1] = 1 << 3; |
746 | #endif | 753 | #endif |
747 | /* Set up the command */ | 754 | /* set up the command */ |
748 | rq->timeout = ATAPI_WAIT_PC; | 755 | rq->timeout = ATAPI_WAIT_PC; |
749 | 756 | ||
750 | /* Send the command to the drive and return. */ | 757 | /* send the command to the drive and return */ |
751 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); | 758 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); |
752 | } | 759 | } |
753 | 760 | ||
@@ -767,14 +774,8 @@ static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive) | |||
767 | info->cd_flags |= IDE_CD_FLAG_SEEKING; | 774 | info->cd_flags |= IDE_CD_FLAG_SEEKING; |
768 | 775 | ||
769 | if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { | 776 | if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { |
770 | if (--retry == 0) { | 777 | if (--retry == 0) |
771 | /* | ||
772 | * this condition is far too common, to bother | ||
773 | * users about it | ||
774 | */ | ||
775 | /* printk("%s: disabled DSC seek overlap\n", drive->name);*/ | ||
776 | drive->dsc_overlap = 0; | 778 | drive->dsc_overlap = 0; |
777 | } | ||
778 | } | 779 | } |
779 | return ide_stopped; | 780 | return ide_stopped; |
780 | } | 781 | } |
@@ -804,8 +805,8 @@ static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block) | |||
804 | } | 805 | } |
805 | 806 | ||
806 | /* | 807 | /* |
807 | * Fix up a possibly partially-processed request so that we can | 808 | * Fix up a possibly partially-processed request so that we can start it over |
808 | * start it over entirely, or even put it back on the request queue. | 809 | * entirely, or even put it back on the request queue. |
809 | */ | 810 | */ |
810 | static void restore_request(struct request *rq) | 811 | static void restore_request(struct request *rq) |
811 | { | 812 | { |
@@ -822,10 +823,9 @@ static void restore_request(struct request *rq) | |||
822 | rq->q->prep_rq_fn(rq->q, rq); | 823 | rq->q->prep_rq_fn(rq->q, rq); |
823 | } | 824 | } |
824 | 825 | ||
825 | /**************************************************************************** | 826 | /* |
826 | * Execute all other packet commands. | 827 | * All other packet commands. |
827 | */ | 828 | */ |
828 | |||
829 | static void ide_cd_request_sense_fixup(struct request *rq) | 829 | static void ide_cd_request_sense_fixup(struct request *rq) |
830 | { | 830 | { |
831 | /* | 831 | /* |
@@ -849,7 +849,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | |||
849 | if (rq->sense == NULL) | 849 | if (rq->sense == NULL) |
850 | rq->sense = &sense; | 850 | rq->sense = &sense; |
851 | 851 | ||
852 | /* Start of retry loop. */ | 852 | /* start of retry loop */ |
853 | do { | 853 | do { |
854 | int error; | 854 | int error; |
855 | unsigned long time = jiffies; | 855 | unsigned long time = jiffies; |
@@ -858,41 +858,45 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | |||
858 | error = ide_do_drive_cmd(drive, rq, ide_wait); | 858 | error = ide_do_drive_cmd(drive, rq, ide_wait); |
859 | time = jiffies - time; | 859 | time = jiffies - time; |
860 | 860 | ||
861 | /* FIXME: we should probably abort/retry or something | 861 | /* |
862 | * in case of failure */ | 862 | * FIXME: we should probably abort/retry or something in case of |
863 | * failure. | ||
864 | */ | ||
863 | if (rq->cmd_flags & REQ_FAILED) { | 865 | if (rq->cmd_flags & REQ_FAILED) { |
864 | /* The request failed. Retry if it was due to a unit | 866 | /* |
865 | attention status | 867 | * The request failed. Retry if it was due to a unit |
866 | (usually means media was changed). */ | 868 | * attention status (usually means media was changed). |
869 | */ | ||
867 | struct request_sense *reqbuf = rq->sense; | 870 | struct request_sense *reqbuf = rq->sense; |
868 | 871 | ||
869 | if (reqbuf->sense_key == UNIT_ATTENTION) | 872 | if (reqbuf->sense_key == UNIT_ATTENTION) |
870 | cdrom_saw_media_change(drive); | 873 | cdrom_saw_media_change(drive); |
871 | else if (reqbuf->sense_key == NOT_READY && | 874 | else if (reqbuf->sense_key == NOT_READY && |
872 | reqbuf->asc == 4 && reqbuf->ascq != 4) { | 875 | reqbuf->asc == 4 && reqbuf->ascq != 4) { |
873 | /* The drive is in the process of loading | 876 | /* |
874 | a disk. Retry, but wait a little to give | 877 | * The drive is in the process of loading |
875 | the drive time to complete the load. */ | 878 | * a disk. Retry, but wait a little to give |
879 | * the drive time to complete the load. | ||
880 | */ | ||
876 | ssleep(2); | 881 | ssleep(2); |
877 | } else { | 882 | } else { |
878 | /* Otherwise, don't retry. */ | 883 | /* otherwise, don't retry */ |
879 | retries = 0; | 884 | retries = 0; |
880 | } | 885 | } |
881 | --retries; | 886 | --retries; |
882 | } | 887 | } |
883 | 888 | ||
884 | /* End of retry loop. */ | 889 | /* end of retry loop */ |
885 | } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); | 890 | } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); |
886 | 891 | ||
887 | /* Return an error if the command failed. */ | 892 | /* return an error if the command failed */ |
888 | return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; | 893 | return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; |
889 | } | 894 | } |
890 | 895 | ||
891 | /* | 896 | /* |
892 | * Called from blk_end_request_callback() after the data of the request | 897 | * Called from blk_end_request_callback() after the data of the request is |
893 | * is completed and before the request is completed. | 898 | * completed and before the request itself is completed. By returning value '1', |
894 | * By returning value '1', blk_end_request_callback() returns immediately | 899 | * blk_end_request_callback() returns immediately without completing it. |
895 | * without completing the request. | ||
896 | */ | 900 | */ |
897 | static int cdrom_newpc_intr_dummy_cb(struct request *rq) | 901 | static int cdrom_newpc_intr_dummy_cb(struct request *rq) |
898 | { | 902 | { |
@@ -911,7 +915,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
911 | unsigned int timeout; | 915 | unsigned int timeout; |
912 | u8 lowcyl, highcyl; | 916 | u8 lowcyl, highcyl; |
913 | 917 | ||
914 | /* Check for errors. */ | 918 | /* check for errors */ |
915 | dma = info->dma; | 919 | dma = info->dma; |
916 | if (dma) { | 920 | if (dma) { |
917 | info->dma = 0; | 921 | info->dma = 0; |
@@ -926,9 +930,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
926 | if (cdrom_decode_status(drive, 0, &stat)) | 930 | if (cdrom_decode_status(drive, 0, &stat)) |
927 | return ide_stopped; | 931 | return ide_stopped; |
928 | 932 | ||
929 | /* | 933 | /* using dma, transfer is complete now */ |
930 | * using dma, transfer is complete now | ||
931 | */ | ||
932 | if (dma) { | 934 | if (dma) { |
933 | if (dma_error) | 935 | if (dma_error) |
934 | return ide_error(drive, "dma error", stat); | 936 | return ide_error(drive, "dma error", stat); |
@@ -939,9 +941,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
939 | goto end_request; | 941 | goto end_request; |
940 | } | 942 | } |
941 | 943 | ||
942 | /* | 944 | /* ok we fall to pio :/ */ |
943 | * ok we fall to pio :/ | ||
944 | */ | ||
945 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]) & 0x3; | 945 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]) & 0x3; |
946 | lowcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]); | 946 | lowcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]); |
947 | highcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]); | 947 | highcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]); |
@@ -952,9 +952,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
952 | if (thislen > len) | 952 | if (thislen > len) |
953 | thislen = len; | 953 | thislen = len; |
954 | 954 | ||
955 | /* | 955 | /* If DRQ is clear, the command has completed. */ |
956 | * If DRQ is clear, the command has completed. | ||
957 | */ | ||
958 | if ((stat & DRQ_STAT) == 0) { | 956 | if ((stat & DRQ_STAT) == 0) { |
959 | if (blk_fs_request(rq)) { | 957 | if (blk_fs_request(rq)) { |
960 | /* | 958 | /* |
@@ -975,15 +973,13 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
975 | return ide_stopped; | 973 | return ide_stopped; |
976 | } else if (!blk_pc_request(rq)) { | 974 | } else if (!blk_pc_request(rq)) { |
977 | ide_cd_request_sense_fixup(rq); | 975 | ide_cd_request_sense_fixup(rq); |
978 | /* Complain if we still have data left to transfer. */ | 976 | /* complain if we still have data left to transfer */ |
979 | uptodate = rq->data_len ? 0 : 1; | 977 | uptodate = rq->data_len ? 0 : 1; |
980 | } | 978 | } |
981 | goto end_request; | 979 | goto end_request; |
982 | } | 980 | } |
983 | 981 | ||
984 | /* | 982 | /* check which way to transfer data */ |
985 | * check which way to transfer data | ||
986 | */ | ||
987 | if (ide_cd_check_ireason(drive, rq, len, ireason, write)) | 983 | if (ide_cd_check_ireason(drive, rq, len, ireason, write)) |
988 | return ide_stopped; | 984 | return ide_stopped; |
989 | 985 | ||
@@ -1019,16 +1015,12 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1019 | xferfunc = HWIF(drive)->atapi_input_bytes; | 1015 | xferfunc = HWIF(drive)->atapi_input_bytes; |
1020 | } | 1016 | } |
1021 | 1017 | ||
1022 | /* | 1018 | /* transfer data */ |
1023 | * transfer data | ||
1024 | */ | ||
1025 | while (thislen > 0) { | 1019 | while (thislen > 0) { |
1026 | u8 *ptr = blk_fs_request(rq) ? NULL : rq->data; | 1020 | u8 *ptr = blk_fs_request(rq) ? NULL : rq->data; |
1027 | int blen = rq->data_len; | 1021 | int blen = rq->data_len; |
1028 | 1022 | ||
1029 | /* | 1023 | /* bio backed? */ |
1030 | * bio backed? | ||
1031 | */ | ||
1032 | if (rq->bio) { | 1024 | if (rq->bio) { |
1033 | if (blk_fs_request(rq)) { | 1025 | if (blk_fs_request(rq)) { |
1034 | ptr = rq->buffer; | 1026 | ptr = rq->buffer; |
@@ -1043,7 +1035,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1043 | if (blk_fs_request(rq) && !write) | 1035 | if (blk_fs_request(rq) && !write) |
1044 | /* | 1036 | /* |
1045 | * If the buffers are full, pipe the rest into | 1037 | * If the buffers are full, pipe the rest into |
1046 | * oblivion. */ | 1038 | * oblivion. |
1039 | */ | ||
1047 | ide_cd_drain_data(drive, thislen >> 9); | 1040 | ide_cd_drain_data(drive, thislen >> 9); |
1048 | else { | 1041 | else { |
1049 | printk(KERN_ERR "%s: confused, missing data\n", | 1042 | printk(KERN_ERR "%s: confused, missing data\n", |
@@ -1090,9 +1083,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1090 | rq->sense_len += blen; | 1083 | rq->sense_len += blen; |
1091 | } | 1084 | } |
1092 | 1085 | ||
1093 | /* | 1086 | /* pad, if necessary */ |
1094 | * pad, if necessary | ||
1095 | */ | ||
1096 | if (!blk_fs_request(rq) && len > 0) | 1087 | if (!blk_fs_request(rq) && len > 0) |
1097 | ide_cd_pad_transfer(drive, xferfunc, len); | 1088 | ide_cd_pad_transfer(drive, xferfunc, len); |
1098 | 1089 | ||
@@ -1136,9 +1127,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1136 | queue_hardsect_size(drive->queue) >> SECTOR_BITS; | 1127 | queue_hardsect_size(drive->queue) >> SECTOR_BITS; |
1137 | 1128 | ||
1138 | if (write) { | 1129 | if (write) { |
1139 | /* | 1130 | /* disk has become write protected */ |
1140 | * disk has become write protected | ||
1141 | */ | ||
1142 | if (cd->disk->policy) { | 1131 | if (cd->disk->policy) { |
1143 | cdrom_end_request(drive, 0); | 1132 | cdrom_end_request(drive, 0); |
1144 | return ide_stopped; | 1133 | return ide_stopped; |
@@ -1151,9 +1140,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1151 | restore_request(rq); | 1140 | restore_request(rq); |
1152 | } | 1141 | } |
1153 | 1142 | ||
1154 | /* | 1143 | /* use DMA, if possible / writes *must* be hardware frame aligned */ |
1155 | * use DMA, if possible / writes *must* be hardware frame aligned | ||
1156 | */ | ||
1157 | if ((rq->nr_sectors & (sectors_per_frame - 1)) || | 1144 | if ((rq->nr_sectors & (sectors_per_frame - 1)) || |
1158 | (rq->sector & (sectors_per_frame - 1))) { | 1145 | (rq->sector & (sectors_per_frame - 1))) { |
1159 | if (write) { | 1146 | if (write) { |
@@ -1167,7 +1154,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1167 | if (write) | 1154 | if (write) |
1168 | cd->devinfo.media_written = 1; | 1155 | cd->devinfo.media_written = 1; |
1169 | 1156 | ||
1170 | /* Start sending the read/write request to the drive. */ | 1157 | /* start sending the read/write request to the drive */ |
1171 | return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); | 1158 | return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); |
1172 | } | 1159 | } |
1173 | 1160 | ||
@@ -1192,9 +1179,7 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1192 | 1179 | ||
1193 | info->dma = 0; | 1180 | info->dma = 0; |
1194 | 1181 | ||
1195 | /* | 1182 | /* sg request */ |
1196 | * sg request | ||
1197 | */ | ||
1198 | if (rq->bio) { | 1183 | if (rq->bio) { |
1199 | int mask = drive->queue->dma_alignment; | 1184 | int mask = drive->queue->dma_alignment; |
1200 | unsigned long addr = (unsigned long) page_address(bio_page(rq->bio)); | 1185 | unsigned long addr = (unsigned long) page_address(bio_page(rq->bio)); |
@@ -1211,11 +1196,11 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1211 | info->dma = 0; | 1196 | info->dma = 0; |
1212 | } | 1197 | } |
1213 | 1198 | ||
1214 | /* Start sending the command to the drive. */ | 1199 | /* start sending the command to the drive */ |
1215 | return cdrom_start_packet_command(drive, rq->data_len, cdrom_do_newpc_cont); | 1200 | return cdrom_start_packet_command(drive, rq->data_len, cdrom_do_newpc_cont); |
1216 | } | 1201 | } |
1217 | 1202 | ||
1218 | /**************************************************************************** | 1203 | /* |
1219 | * cdrom driver request routine. | 1204 | * cdrom driver request routine. |
1220 | */ | 1205 | */ |
1221 | static ide_startstop_t | 1206 | static ide_startstop_t |
@@ -1248,9 +1233,7 @@ ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block) | |||
1248 | rq->cmd_type == REQ_TYPE_ATA_PC) { | 1233 | rq->cmd_type == REQ_TYPE_ATA_PC) { |
1249 | return cdrom_do_block_pc(drive, rq); | 1234 | return cdrom_do_block_pc(drive, rq); |
1250 | } else if (blk_special_request(rq)) { | 1235 | } else if (blk_special_request(rq)) { |
1251 | /* | 1236 | /* right now this can only be a reset... */ |
1252 | * right now this can only be a reset... | ||
1253 | */ | ||
1254 | cdrom_end_request(drive, 1); | 1237 | cdrom_end_request(drive, 1); |
1255 | return ide_stopped; | 1238 | return ide_stopped; |
1256 | } | 1239 | } |
@@ -1262,16 +1245,15 @@ ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block) | |||
1262 | 1245 | ||
1263 | 1246 | ||
1264 | 1247 | ||
1265 | /**************************************************************************** | 1248 | /* |
1266 | * Ioctl handling. | 1249 | * Ioctl handling. |
1267 | * | 1250 | * |
1268 | * Routines which queue packet commands take as a final argument a pointer | 1251 | * Routines which queue packet commands take as a final argument a pointer to a |
1269 | * to a request_sense struct. If execution of the command results | 1252 | * request_sense struct. If execution of the command results in an error with a |
1270 | * in an error with a CHECK CONDITION status, this structure will be filled | 1253 | * CHECK CONDITION status, this structure will be filled with the results of the |
1271 | * with the results of the subsequent request sense command. The pointer | 1254 | * subsequent request sense command. The pointer can also be NULL, in which case |
1272 | * can also be NULL, in which case no sense information is returned. | 1255 | * no sense information is returned. |
1273 | */ | 1256 | */ |
1274 | |||
1275 | static | 1257 | static |
1276 | void msf_from_bcd(struct atapi_msf *msf) | 1258 | void msf_from_bcd(struct atapi_msf *msf) |
1277 | { | 1259 | { |
@@ -1293,8 +1275,8 @@ int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) | |||
1293 | req.cmd_flags |= REQ_QUIET; | 1275 | req.cmd_flags |= REQ_QUIET; |
1294 | 1276 | ||
1295 | /* | 1277 | /* |
1296 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to | 1278 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs |
1297 | * switch CDs instead of supporting the LOAD_UNLOAD opcode. | 1279 | * instead of supporting the LOAD_UNLOAD opcode. |
1298 | */ | 1280 | */ |
1299 | req.cmd[7] = cdi->sanyo_slot % 3; | 1281 | req.cmd[7] = cdi->sanyo_slot % 3; |
1300 | 1282 | ||
@@ -1370,7 +1352,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1370 | unsigned long sectors_per_frame = SECTORS_PER_FRAME; | 1352 | unsigned long sectors_per_frame = SECTORS_PER_FRAME; |
1371 | 1353 | ||
1372 | if (toc == NULL) { | 1354 | if (toc == NULL) { |
1373 | /* Try to allocate space. */ | 1355 | /* try to allocate space */ |
1374 | toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); | 1356 | toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); |
1375 | if (toc == NULL) { | 1357 | if (toc == NULL) { |
1376 | printk(KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); | 1358 | printk(KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); |
@@ -1379,27 +1361,29 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1379 | info->toc = toc; | 1361 | info->toc = toc; |
1380 | } | 1362 | } |
1381 | 1363 | ||
1382 | /* Check to see if the existing data is still valid. | 1364 | /* |
1383 | If it is, just return. */ | 1365 | * Check to see if the existing data is still valid. If it is, |
1366 | * just return. | ||
1367 | */ | ||
1384 | (void) cdrom_check_status(drive, sense); | 1368 | (void) cdrom_check_status(drive, sense); |
1385 | 1369 | ||
1386 | if (info->cd_flags & IDE_CD_FLAG_TOC_VALID) | 1370 | if (info->cd_flags & IDE_CD_FLAG_TOC_VALID) |
1387 | return 0; | 1371 | return 0; |
1388 | 1372 | ||
1389 | /* Try to get the total cdrom capacity and sector size. */ | 1373 | /* try to get the total cdrom capacity and sector size */ |
1390 | stat = cdrom_read_capacity(drive, &toc->capacity, §ors_per_frame, | 1374 | stat = cdrom_read_capacity(drive, &toc->capacity, §ors_per_frame, |
1391 | sense); | 1375 | sense); |
1392 | if (stat) | 1376 | if (stat) |
1393 | toc->capacity = 0x1fffff; | 1377 | toc->capacity = 0x1fffff; |
1394 | 1378 | ||
1395 | set_capacity(info->disk, toc->capacity * sectors_per_frame); | 1379 | set_capacity(info->disk, toc->capacity * sectors_per_frame); |
1396 | /* Save a private copy of te TOC capacity for error handling */ | 1380 | /* save a private copy of the TOC capacity for error handling */ |
1397 | drive->probed_capacity = toc->capacity * sectors_per_frame; | 1381 | drive->probed_capacity = toc->capacity * sectors_per_frame; |
1398 | 1382 | ||
1399 | blk_queue_hardsect_size(drive->queue, | 1383 | blk_queue_hardsect_size(drive->queue, |
1400 | sectors_per_frame << SECTOR_BITS); | 1384 | sectors_per_frame << SECTOR_BITS); |
1401 | 1385 | ||
1402 | /* First read just the header, so we know how long the TOC is. */ | 1386 | /* first read just the header, so we know how long the TOC is */ |
1403 | stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, | 1387 | stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, |
1404 | sizeof(struct atapi_toc_header), sense); | 1388 | sizeof(struct atapi_toc_header), sense); |
1405 | if (stat) | 1389 | if (stat) |
@@ -1416,7 +1400,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1416 | if (ntracks > MAX_TRACKS) | 1400 | if (ntracks > MAX_TRACKS) |
1417 | ntracks = MAX_TRACKS; | 1401 | ntracks = MAX_TRACKS; |
1418 | 1402 | ||
1419 | /* Now read the whole schmeer. */ | 1403 | /* now read the whole schmeer */ |
1420 | stat = cdrom_read_tocentry(drive, toc->hdr.first_track, 1, 0, | 1404 | stat = cdrom_read_tocentry(drive, toc->hdr.first_track, 1, 0, |
1421 | (char *)&toc->hdr, | 1405 | (char *)&toc->hdr, |
1422 | sizeof(struct atapi_toc_header) + | 1406 | sizeof(struct atapi_toc_header) + |
@@ -1424,15 +1408,18 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1424 | sizeof(struct atapi_toc_entry), sense); | 1408 | sizeof(struct atapi_toc_entry), sense); |
1425 | 1409 | ||
1426 | if (stat && toc->hdr.first_track > 1) { | 1410 | if (stat && toc->hdr.first_track > 1) { |
1427 | /* Cds with CDI tracks only don't have any TOC entries, | 1411 | /* |
1428 | despite of this the returned values are | 1412 | * Cds with CDI tracks only don't have any TOC entries, despite |
1429 | first_track == last_track = number of CDI tracks + 1, | 1413 | * of this the returned values are |
1430 | so that this case is indistinguishable from the same | 1414 | * first_track == last_track = number of CDI tracks + 1, |
1431 | layout plus an additional audio track. | 1415 | * so that this case is indistinguishable from the same layout |
1432 | If we get an error for the regular case, we assume | 1416 | * plus an additional audio track. If we get an error for the |
1433 | a CDI without additional audio tracks. In this case | 1417 | * regular case, we assume a CDI without additional audio |
1434 | the readable TOC is empty (CDI tracks are not included) | 1418 | * tracks. In this case the readable TOC is empty (CDI tracks |
1435 | and only holds the Leadout entry. Heiko Eißfeldt */ | 1419 | * are not included) and only holds the Leadout entry. |
1420 | * | ||
1421 | * Heiko Eißfeldt. | ||
1422 | */ | ||
1436 | ntracks = 0; | 1423 | ntracks = 0; |
1437 | stat = cdrom_read_tocentry(drive, CDROM_LEADOUT, 1, 0, | 1424 | stat = cdrom_read_tocentry(drive, CDROM_LEADOUT, 1, 0, |
1438 | (char *)&toc->hdr, | 1425 | (char *)&toc->hdr, |
@@ -1473,9 +1460,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1473 | toc->ent[i].addr.msf.frame); | 1460 | toc->ent[i].addr.msf.frame); |
1474 | } | 1461 | } |
1475 | 1462 | ||
1476 | /* Read the multisession information. */ | ||
1477 | if (toc->hdr.first_track != CDROM_LEADOUT) { | 1463 | if (toc->hdr.first_track != CDROM_LEADOUT) { |
1478 | /* Read the multisession information. */ | 1464 | /* read the multisession information */ |
1479 | stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp, | 1465 | stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp, |
1480 | sizeof(ms_tmp), sense); | 1466 | sizeof(ms_tmp), sense); |
1481 | if (stat) | 1467 | if (stat) |
@@ -1488,7 +1474,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1488 | } | 1474 | } |
1489 | 1475 | ||
1490 | if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { | 1476 | if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { |
1491 | /* Re-read multisession information using MSF format */ | 1477 | /* re-read multisession information using MSF format */ |
1492 | stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, | 1478 | stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, |
1493 | sizeof(ms_tmp), sense); | 1479 | sizeof(ms_tmp), sense); |
1494 | if (stat) | 1480 | if (stat) |
@@ -1502,7 +1488,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1502 | 1488 | ||
1503 | toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track); | 1489 | toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track); |
1504 | 1490 | ||
1505 | /* Now try to get the total cdrom capacity. */ | 1491 | /* now try to get the total cdrom capacity */ |
1506 | stat = cdrom_get_last_written(cdi, &last_written); | 1492 | stat = cdrom_get_last_written(cdi, &last_written); |
1507 | if (!stat && (last_written > toc->capacity)) { | 1493 | if (!stat && (last_written > toc->capacity)) { |
1508 | toc->capacity = last_written; | 1494 | toc->capacity = last_written; |
@@ -1527,7 +1513,8 @@ int ide_cdrom_get_capabilities(ide_drive_t *drive, u8 *buf) | |||
1527 | size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; | 1513 | size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; |
1528 | 1514 | ||
1529 | init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); | 1515 | init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); |
1530 | do { /* we seem to get stat=0x01,err=0x00 the first time (??) */ | 1516 | do { |
1517 | /* we seem to get stat=0x01,err=0x00 the first time (??) */ | ||
1531 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); | 1518 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); |
1532 | if (!stat) | 1519 | if (!stat) |
1533 | break; | 1520 | break; |
@@ -1622,11 +1609,10 @@ int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1622 | } | 1609 | } |
1623 | 1610 | ||
1624 | /* | 1611 | /* |
1625 | * we have to cheat a little here. the packet will eventually | 1612 | * We have to cheat a little here. the packet will eventually be queued |
1626 | * be queued with ide_cdrom_packet(), which extracts the | 1613 | * with ide_cdrom_packet(), which extracts the drive from cdi->handle. |
1627 | * drive from cdi->handle. Since this device hasn't been | 1614 | * Since this device hasn't been registered with the Uniform layer yet, |
1628 | * registered with the Uniform layer yet, it can't do this. | 1615 | * it can't do this. Same goes for cdi->ops. |
1629 | * Same goes for cdi->ops. | ||
1630 | */ | 1616 | */ |
1631 | cdi->handle = drive; | 1617 | cdi->handle = drive; |
1632 | cdi->ops = &ide_cdrom_dops; | 1618 | cdi->ops = &ide_cdrom_dops; |
@@ -1695,9 +1681,7 @@ int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1695 | return nslots; | 1681 | return nslots; |
1696 | } | 1682 | } |
1697 | 1683 | ||
1698 | /* | 1684 | /* standard prep_rq_fn that builds 10 byte cmds */ |
1699 | * standard prep_rq_fn that builds 10 byte cmds | ||
1700 | */ | ||
1701 | static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) | 1685 | static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) |
1702 | { | 1686 | { |
1703 | int hard_sect = queue_hardsect_size(q); | 1687 | int hard_sect = queue_hardsect_size(q); |
@@ -1736,9 +1720,7 @@ static int ide_cdrom_prep_pc(struct request *rq) | |||
1736 | { | 1720 | { |
1737 | u8 *c = rq->cmd; | 1721 | u8 *c = rq->cmd; |
1738 | 1722 | ||
1739 | /* | 1723 | /* transform 6-byte read/write commands to the 10-byte version */ |
1740 | * Transform 6-byte read/write commands to the 10-byte version | ||
1741 | */ | ||
1742 | if (c[0] == READ_6 || c[0] == WRITE_6) { | 1724 | if (c[0] == READ_6 || c[0] == WRITE_6) { |
1743 | c[8] = c[4]; | 1725 | c[8] = c[4]; |
1744 | c[5] = c[3]; | 1726 | c[5] = c[3]; |
@@ -1902,13 +1884,12 @@ int ide_cdrom_setup(ide_drive_t *drive) | |||
1902 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') | 1884 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') |
1903 | cd->cd_flags |= IDE_CD_FLAG_TOCTRACKS_AS_BCD; | 1885 | cd->cd_flags |= IDE_CD_FLAG_TOCTRACKS_AS_BCD; |
1904 | else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) | 1886 | else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) |
1905 | cdi->sanyo_slot = 3; /* 3 => use CD in slot 0 */ | 1887 | /* 3 => use CD in slot 0 */ |
1888 | cdi->sanyo_slot = 3; | ||
1906 | 1889 | ||
1907 | nslots = ide_cdrom_probe_capabilities(drive); | 1890 | nslots = ide_cdrom_probe_capabilities(drive); |
1908 | 1891 | ||
1909 | /* | 1892 | /* set correct block size */ |
1910 | * set correct block size | ||
1911 | */ | ||
1912 | blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE); | 1893 | blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE); |
1913 | 1894 | ||
1914 | if (drive->autotune == IDE_TUNE_DEFAULT || | 1895 | if (drive->autotune == IDE_TUNE_DEFAULT || |
@@ -2092,7 +2073,7 @@ static struct block_device_operations idecd_ops = { | |||
2092 | .revalidate_disk = idecd_revalidate_disk | 2073 | .revalidate_disk = idecd_revalidate_disk |
2093 | }; | 2074 | }; |
2094 | 2075 | ||
2095 | /* options */ | 2076 | /* module options */ |
2096 | static char *ignore; | 2077 | static char *ignore; |
2097 | 2078 | ||
2098 | module_param(ignore, charp, 0400); | 2079 | module_param(ignore, charp, 0400); |