aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-lib.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-01-25 16:17:17 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-01-25 16:17:17 -0500
commitc2b57cdc1d2976444d451a2a2e43e11b61ed0638 (patch)
treef322e4d494d9688afd319fbe88afd6a526bb0154 /drivers/ide/ide-lib.c
parentd32444771b154c3ec37ebf6439004653560c2411 (diff)
ide: add ide_tf_read() helper
* Factor out code reading taskfile registers from ide_end_drive_cmd() to the new ide_tf_read() helper. * Add IDE_TFLAG_IN_* taskfile flags to indicate the need to load particular IDE taskfile register in ide_tf_read(). * Update ide_end_drive_cmd() to set respective IDE_TFLAG_IN_* taksfile flags. * Add ide_get_lba_addr() for getting LBA sector address from taskfile struct. * Factor out code getting sector address from ide_dump_ata_status() to the new ide_dump_sector() function. * Convert ide_dump_sector() to use ide_tf_read() and ide_get_lba_addr(). * Remove no longer needed ide_read_24(). The only change in functionality caused by this patch is that ide_dump_ata_status() no longer prints "high"/"low" parts of LBA48 sector address (of course LBA48 sector address is still printed). Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-lib.c')
-rw-r--r--drivers/ide/ide-lib.c69
1 files changed, 37 insertions, 32 deletions
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 001085845a79..15736d4ce9b4 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -479,6 +479,42 @@ static void ide_dump_opcode(ide_drive_t *drive)
479 printk("0x%02x\n", opcode); 479 printk("0x%02x\n", opcode);
480} 480}
481 481
482static u64 ide_get_lba_addr(struct ide_taskfile *tf, int lba48)
483{
484 u32 high, low;
485
486 if (lba48)
487 high = (tf->hob_lbah << 16) | (tf->hob_lbam << 8) |
488 tf->hob_lbal;
489 else
490 high = tf->device & 0xf;
491 low = (tf->lbah << 16) | (tf->lbam << 8) | tf->lbal;
492
493 return ((u64)high << 24) | low;
494}
495
496static void ide_dump_sector(ide_drive_t *drive)
497{
498 ide_task_t task;
499 struct ide_taskfile *tf = &task.tf;
500 int lba48 = (drive->addressing == 1) ? 1 : 0;
501
502 memset(&task, 0, sizeof(task));
503 if (lba48)
504 task.tf_flags = IDE_TFLAG_IN_LBA | IDE_TFLAG_IN_HOB_LBA |
505 IDE_TFLAG_LBA48;
506 else
507 task.tf_flags = IDE_TFLAG_IN_LBA | IDE_TFLAG_IN_DEVICE;
508
509 ide_tf_read(drive, &task);
510
511 if (lba48 || (tf->device & ATA_LBA))
512 printk(", LBAsect=%llu", ide_get_lba_addr(tf, lba48));
513 else
514 printk(", CHS=%d/%d/%d", (tf->lbah << 8) + tf->lbam,
515 tf->device & 0xf, tf->lbal);
516}
517
482static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat) 518static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat)
483{ 519{
484 ide_hwif_t *hwif = HWIF(drive); 520 ide_hwif_t *hwif = HWIF(drive);
@@ -512,38 +548,7 @@ static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat)
512 printk("}"); 548 printk("}");
513 if ((err & (BBD_ERR | ABRT_ERR)) == BBD_ERR || 549 if ((err & (BBD_ERR | ABRT_ERR)) == BBD_ERR ||
514 (err & (ECC_ERR|ID_ERR|MARK_ERR))) { 550 (err & (ECC_ERR|ID_ERR|MARK_ERR))) {
515 if (drive->addressing == 1) { 551 ide_dump_sector(drive);
516 __u64 sectors = 0;
517 u32 low = 0, high = 0;
518 hwif->OUTB(drive->ctl&~0x80, IDE_CONTROL_REG);
519 low = ide_read_24(drive);
520 hwif->OUTB(drive->ctl|0x80, IDE_CONTROL_REG);
521 high = ide_read_24(drive);
522 sectors = ((__u64)high << 24) | low;
523 printk(", LBAsect=%llu, high=%d, low=%d",
524 (unsigned long long) sectors,
525 high, low);
526 } else {
527 u8 sector, lcyl, hcyl, cur;
528
529 sector = hwif->INB(IDE_SECTOR_REG);
530 lcyl = hwif->INB(IDE_LCYL_REG);
531 hcyl = hwif->INB(IDE_HCYL_REG);
532 cur = hwif->INB(IDE_SELECT_REG);
533
534 if (cur & 0x40) { /* using LBA? */
535 printk(", LBAsect=%ld", (unsigned long)
536 ((cur & 0xf) << 24) |
537 (hcyl << 16) |
538 (lcyl << 8) |
539 sector);
540 } else {
541 printk(", CHS=%d/%d/%d",
542 (hcyl << 8) + lcyl,
543 cur & 0xf,
544 sector);
545 }
546 }
547 if (HWGROUP(drive) && HWGROUP(drive)->rq) 552 if (HWGROUP(drive) && HWGROUP(drive)->rq)
548 printk(", sector=%llu", 553 printk(", sector=%llu",
549 (unsigned long long)HWGROUP(drive)->rq->sector); 554 (unsigned long long)HWGROUP(drive)->rq->sector);