diff options
Diffstat (limited to 'drivers/ide/ide-lib.c')
-rw-r--r-- | drivers/ide/ide-lib.c | 105 |
1 files changed, 37 insertions, 68 deletions
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 6b2e810cb9e0..8649db33f67d 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c | |||
@@ -517,61 +517,51 @@ static void ide_dump_sector(ide_drive_t *drive) | |||
517 | tf->device & 0xf, tf->lbal); | 517 | tf->device & 0xf, tf->lbal); |
518 | } | 518 | } |
519 | 519 | ||
520 | static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat) | 520 | static void ide_dump_ata_error(ide_drive_t *drive, u8 err) |
521 | { | 521 | { |
522 | ide_hwif_t *hwif = HWIF(drive); | 522 | printk("{ "); |
523 | unsigned long flags; | 523 | if (err & ABRT_ERR) printk("DriveStatusError "); |
524 | u8 err = 0; | 524 | if (err & ICRC_ERR) |
525 | 525 | printk((err & ABRT_ERR) ? "BadCRC " : "BadSector "); | |
526 | local_irq_save(flags); | 526 | if (err & ECC_ERR) printk("UncorrectableError "); |
527 | printk("%s: %s: status=0x%02x { ", drive->name, msg, stat); | 527 | if (err & ID_ERR) printk("SectorIdNotFound "); |
528 | if (stat & BUSY_STAT) | 528 | if (err & TRK0_ERR) printk("TrackZeroNotFound "); |
529 | printk("Busy "); | 529 | if (err & MARK_ERR) printk("AddrMarkNotFound "); |
530 | else { | 530 | printk("}"); |
531 | if (stat & READY_STAT) printk("DriveReady "); | 531 | if ((err & (BBD_ERR | ABRT_ERR)) == BBD_ERR || |
532 | if (stat & WRERR_STAT) printk("DeviceFault "); | 532 | (err & (ECC_ERR|ID_ERR|MARK_ERR))) { |
533 | if (stat & SEEK_STAT) printk("SeekComplete "); | 533 | ide_dump_sector(drive); |
534 | if (stat & DRQ_STAT) printk("DataRequest "); | 534 | if (HWGROUP(drive) && HWGROUP(drive)->rq) |
535 | if (stat & ECC_STAT) printk("CorrectedError "); | 535 | printk(", sector=%llu", |
536 | if (stat & INDEX_STAT) printk("Index "); | 536 | (unsigned long long)HWGROUP(drive)->rq->sector); |
537 | if (stat & ERR_STAT) printk("Error "); | ||
538 | } | 537 | } |
538 | printk("\n"); | ||
539 | } | ||
540 | |||
541 | static void ide_dump_atapi_error(ide_drive_t *drive, u8 err) | ||
542 | { | ||
543 | printk("{ "); | ||
544 | if (err & ILI_ERR) printk("IllegalLengthIndication "); | ||
545 | if (err & EOM_ERR) printk("EndOfMedia "); | ||
546 | if (err & ABRT_ERR) printk("AbortedCommand "); | ||
547 | if (err & MCR_ERR) printk("MediaChangeRequested "); | ||
548 | if (err & LFS_ERR) printk("LastFailedSense=0x%02x ", | ||
549 | (err & LFS_ERR) >> 4); | ||
539 | printk("}\n"); | 550 | printk("}\n"); |
540 | if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) { | ||
541 | err = hwif->INB(IDE_ERROR_REG); | ||
542 | printk("%s: %s: error=0x%02x { ", drive->name, msg, err); | ||
543 | if (err & ABRT_ERR) printk("DriveStatusError "); | ||
544 | if (err & ICRC_ERR) | ||
545 | printk((err & ABRT_ERR) ? "BadCRC " : "BadSector "); | ||
546 | if (err & ECC_ERR) printk("UncorrectableError "); | ||
547 | if (err & ID_ERR) printk("SectorIdNotFound "); | ||
548 | if (err & TRK0_ERR) printk("TrackZeroNotFound "); | ||
549 | if (err & MARK_ERR) printk("AddrMarkNotFound "); | ||
550 | printk("}"); | ||
551 | if ((err & (BBD_ERR | ABRT_ERR)) == BBD_ERR || | ||
552 | (err & (ECC_ERR|ID_ERR|MARK_ERR))) { | ||
553 | ide_dump_sector(drive); | ||
554 | if (HWGROUP(drive) && HWGROUP(drive)->rq) | ||
555 | printk(", sector=%llu", | ||
556 | (unsigned long long)HWGROUP(drive)->rq->sector); | ||
557 | } | ||
558 | printk("\n"); | ||
559 | } | ||
560 | ide_dump_opcode(drive); | ||
561 | local_irq_restore(flags); | ||
562 | return err; | ||
563 | } | 551 | } |
564 | 552 | ||
565 | /** | 553 | /** |
566 | * ide_dump_atapi_status - print human readable atapi status | 554 | * ide_dump_status - translate ATA/ATAPI error |
567 | * @drive: drive that status applies to | 555 | * @drive: drive that status applies to |
568 | * @msg: text message to print | 556 | * @msg: text message to print |
569 | * @stat: status byte to decode | 557 | * @stat: status byte to decode |
570 | * | 558 | * |
571 | * Error reporting, in human readable form (luxurious, but a memory hog). | 559 | * Error reporting, in human readable form (luxurious, but a memory hog). |
560 | * Combines the drive name, message and status byte to provide a | ||
561 | * user understandable explanation of the device error. | ||
572 | */ | 562 | */ |
573 | 563 | ||
574 | static u8 ide_dump_atapi_status(ide_drive_t *drive, const char *msg, u8 stat) | 564 | u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat) |
575 | { | 565 | { |
576 | unsigned long flags; | 566 | unsigned long flags; |
577 | u8 err = 0; | 567 | u8 err = 0; |
@@ -592,36 +582,15 @@ static u8 ide_dump_atapi_status(ide_drive_t *drive, const char *msg, u8 stat) | |||
592 | printk("}\n"); | 582 | printk("}\n"); |
593 | if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) { | 583 | if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) { |
594 | err = drive->hwif->INB(IDE_ERROR_REG); | 584 | err = drive->hwif->INB(IDE_ERROR_REG); |
595 | printk("%s: %s: error=0x%02x { ", drive->name, msg, err); | 585 | printk("%s: %s: error=0x%02x ", drive->name, msg, err); |
596 | if (err & ILI_ERR) printk("IllegalLengthIndication "); | 586 | if (drive->media == ide_disk) |
597 | if (err & EOM_ERR) printk("EndOfMedia "); | 587 | ide_dump_ata_error(drive, err); |
598 | if (err & ABRT_ERR) printk("AbortedCommand "); | 588 | else |
599 | if (err & MCR_ERR) printk("MediaChangeRequested "); | 589 | ide_dump_atapi_error(drive, err); |
600 | if (err & LFS_ERR) printk("LastFailedSense=0x%02x ", | ||
601 | (err & LFS_ERR) >> 4); | ||
602 | printk("}\n"); | ||
603 | } | 590 | } |
604 | ide_dump_opcode(drive); | 591 | ide_dump_opcode(drive); |
605 | local_irq_restore(flags); | 592 | local_irq_restore(flags); |
606 | return err; | 593 | return err; |
607 | } | 594 | } |
608 | 595 | ||
609 | /** | ||
610 | * ide_dump_status - translate ATA/ATAPI error | ||
611 | * @drive: drive the error occured on | ||
612 | * @msg: information string | ||
613 | * @stat: status byte | ||
614 | * | ||
615 | * Error reporting, in human readable form (luxurious, but a memory hog). | ||
616 | * Combines the drive name, message and status byte to provide a | ||
617 | * user understandable explanation of the device error. | ||
618 | */ | ||
619 | |||
620 | u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat) | ||
621 | { | ||
622 | if (drive->media == ide_disk) | ||
623 | return ide_dump_ata_status(drive, msg, stat); | ||
624 | return ide_dump_atapi_status(drive, msg, stat); | ||
625 | } | ||
626 | |||
627 | EXPORT_SYMBOL(ide_dump_status); | 596 | EXPORT_SYMBOL(ide_dump_status); |