diff options
author | Borislav Petkov <petkovbb@gmail.com> | 2009-04-26 04:39:07 -0400 |
---|---|---|
committer | Borislav Petkov <petkovbb@gmail.com> | 2009-05-15 00:44:45 -0400 |
commit | 103f7033bd0f7b65ff3e0a5ea72449d08010b031 (patch) | |
tree | bf1e416a235ffde137c94ad1d5da8542b0e5ab4e /drivers/ide/ide-cd.c | |
parent | 239f7e25346e22c4a94bde004d845e7397947c01 (diff) |
ide: unify interrupt reason checking
Add ide_check_ireason() function that handles all ATAPI devices.
Reorganize all unlikely cases in ireason checking further down in the
code path.
In addition, add PFX for printks originating from ide-atapi. Finally,
remove ide_cd_check_ireason.
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index dca41ae0d048..d299713bfdc1 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -410,50 +410,6 @@ end_request: | |||
410 | return 2; | 410 | return 2; |
411 | } | 411 | } |
412 | 412 | ||
413 | /* | ||
414 | * Check the contents of the interrupt reason register from the cdrom | ||
415 | * and attempt to recover if there are problems. Returns 0 if everything's | ||
416 | * ok; nonzero if the request has been terminated. | ||
417 | */ | ||
418 | static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq, | ||
419 | int len, int ireason, int rw) | ||
420 | { | ||
421 | ide_hwif_t *hwif = drive->hwif; | ||
422 | |||
423 | ide_debug_log(IDE_DBG_FUNC, "ireason: 0x%x, rw: 0x%x", ireason, rw); | ||
424 | |||
425 | /* | ||
426 | * ireason == 0: the drive wants to receive data from us | ||
427 | * ireason == 2: the drive is expecting to transfer data to us | ||
428 | */ | ||
429 | if (ireason == (!rw << 1)) | ||
430 | return 0; | ||
431 | else if (ireason == (rw << 1)) { | ||
432 | |||
433 | /* whoops... */ | ||
434 | printk(KERN_ERR PFX "%s: %s: wrong transfer direction!\n", | ||
435 | drive->name, __func__); | ||
436 | |||
437 | ide_pad_transfer(drive, rw, len); | ||
438 | } else if (rw == 0 && ireason == 1) { | ||
439 | /* | ||
440 | * Some drives (ASUS) seem to tell us that status info is | ||
441 | * available. Just get it and ignore. | ||
442 | */ | ||
443 | (void)hwif->tp_ops->read_status(hwif); | ||
444 | return 0; | ||
445 | } else { | ||
446 | /* drive wants a command packet, or invalid ireason... */ | ||
447 | printk(KERN_ERR PFX "%s: %s: bad interrupt reason 0x%02x\n", | ||
448 | drive->name, __func__, ireason); | ||
449 | } | ||
450 | |||
451 | if (rq->cmd_type == REQ_TYPE_ATA_PC) | ||
452 | rq->cmd_flags |= REQ_FAILED; | ||
453 | |||
454 | return -1; | ||
455 | } | ||
456 | |||
457 | static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct ide_cmd *cmd) | 413 | static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct ide_cmd *cmd) |
458 | { | 414 | { |
459 | struct request *rq = cmd->rq; | 415 | struct request *rq = cmd->rq; |
@@ -645,8 +601,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
645 | goto out_end; | 601 | goto out_end; |
646 | } | 602 | } |
647 | 603 | ||
648 | /* check which way to transfer data */ | 604 | rc = ide_check_ireason(drive, rq, len, ireason, write); |
649 | rc = ide_cd_check_ireason(drive, rq, len, ireason, write); | ||
650 | if (rc) | 605 | if (rc) |
651 | goto out_end; | 606 | goto out_end; |
652 | 607 | ||