ide: kill duplicate code in ide_dump_{ata,atapi}_status()
* Move the common code from ide_dump_{ata,atapi}_status() to ide_dump_status(). * ide_dump_{ata,atapi}_status() -> ide_dump_{ata,atapi}_error(). There should be no functionality changes caused by this patch. Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
@@ -517,29 +517,9 @@ static void ide_dump_sector(ide_drive_t *drive)
|
|||||||
tf->device & 0xf, tf->lbal);
|
tf->device & 0xf, tf->lbal);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat)
|
static void ide_dump_ata_error(ide_drive_t *drive, u8 err)
|
||||||
{
|
{
|
||||||
ide_hwif_t *hwif = HWIF(drive);
|
printk("{ ");
|
||||||
unsigned long flags;
|
|
||||||
u8 err = 0;
|
|
||||||
|
|
||||||
local_irq_save(flags);
|
|
||||||
printk("%s: %s: status=0x%02x { ", drive->name, msg, stat);
|
|
||||||
if (stat & BUSY_STAT)
|
|
||||||
printk("Busy ");
|
|
||||||
else {
|
|
||||||
if (stat & READY_STAT) printk("DriveReady ");
|
|
||||||
if (stat & WRERR_STAT) printk("DeviceFault ");
|
|
||||||
if (stat & SEEK_STAT) printk("SeekComplete ");
|
|
||||||
if (stat & DRQ_STAT) printk("DataRequest ");
|
|
||||||
if (stat & ECC_STAT) printk("CorrectedError ");
|
|
||||||
if (stat & INDEX_STAT) printk("Index ");
|
|
||||||
if (stat & ERR_STAT) printk("Error ");
|
|
||||||
}
|
|
||||||
printk("}\n");
|
|
||||||
if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) {
|
|
||||||
err = hwif->INB(IDE_ERROR_REG);
|
|
||||||
printk("%s: %s: error=0x%02x { ", drive->name, msg, err);
|
|
||||||
if (err & ABRT_ERR) printk("DriveStatusError ");
|
if (err & ABRT_ERR) printk("DriveStatusError ");
|
||||||
if (err & ICRC_ERR)
|
if (err & ICRC_ERR)
|
||||||
printk((err & ABRT_ERR) ? "BadCRC " : "BadSector ");
|
printk((err & ABRT_ERR) ? "BadCRC " : "BadSector ");
|
||||||
@@ -556,22 +536,32 @@ static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat)
|
|||||||
(unsigned long long)HWGROUP(drive)->rq->sector);
|
(unsigned long long)HWGROUP(drive)->rq->sector);
|
||||||
}
|
}
|
||||||
printk("\n");
|
printk("\n");
|
||||||
}
|
}
|
||||||
ide_dump_opcode(drive);
|
|
||||||
local_irq_restore(flags);
|
static void ide_dump_atapi_error(ide_drive_t *drive, u8 err)
|
||||||
return err;
|
{
|
||||||
|
printk("{ ");
|
||||||
|
if (err & ILI_ERR) printk("IllegalLengthIndication ");
|
||||||
|
if (err & EOM_ERR) printk("EndOfMedia ");
|
||||||
|
if (err & ABRT_ERR) printk("AbortedCommand ");
|
||||||
|
if (err & MCR_ERR) printk("MediaChangeRequested ");
|
||||||
|
if (err & LFS_ERR) printk("LastFailedSense=0x%02x ",
|
||||||
|
(err & LFS_ERR) >> 4);
|
||||||
|
printk("}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ide_dump_atapi_status - print human readable atapi status
|
* ide_dump_status - translate ATA/ATAPI error
|
||||||
* @drive: drive that status applies to
|
* @drive: drive that status applies to
|
||||||
* @msg: text message to print
|
* @msg: text message to print
|
||||||
* @stat: status byte to decode
|
* @stat: status byte to decode
|
||||||
*
|
*
|
||||||
* Error reporting, in human readable form (luxurious, but a memory hog).
|
* Error reporting, in human readable form (luxurious, but a memory hog).
|
||||||
|
* Combines the drive name, message and status byte to provide a
|
||||||
|
* user understandable explanation of the device error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static u8 ide_dump_atapi_status(ide_drive_t *drive, const char *msg, u8 stat)
|
u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
u8 err = 0;
|
u8 err = 0;
|
||||||
@@ -592,36 +582,15 @@ static u8 ide_dump_atapi_status(ide_drive_t *drive, const char *msg, u8 stat)
|
|||||||
printk("}\n");
|
printk("}\n");
|
||||||
if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) {
|
if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) {
|
||||||
err = drive->hwif->INB(IDE_ERROR_REG);
|
err = drive->hwif->INB(IDE_ERROR_REG);
|
||||||
printk("%s: %s: error=0x%02x { ", drive->name, msg, err);
|
printk("%s: %s: error=0x%02x ", drive->name, msg, err);
|
||||||
if (err & ILI_ERR) printk("IllegalLengthIndication ");
|
if (drive->media == ide_disk)
|
||||||
if (err & EOM_ERR) printk("EndOfMedia ");
|
ide_dump_ata_error(drive, err);
|
||||||
if (err & ABRT_ERR) printk("AbortedCommand ");
|
else
|
||||||
if (err & MCR_ERR) printk("MediaChangeRequested ");
|
ide_dump_atapi_error(drive, err);
|
||||||
if (err & LFS_ERR) printk("LastFailedSense=0x%02x ",
|
|
||||||
(err & LFS_ERR) >> 4);
|
|
||||||
printk("}\n");
|
|
||||||
}
|
}
|
||||||
ide_dump_opcode(drive);
|
ide_dump_opcode(drive);
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* ide_dump_status - translate ATA/ATAPI error
|
|
||||||
* @drive: drive the error occured on
|
|
||||||
* @msg: information string
|
|
||||||
* @stat: status byte
|
|
||||||
*
|
|
||||||
* Error reporting, in human readable form (luxurious, but a memory hog).
|
|
||||||
* Combines the drive name, message and status byte to provide a
|
|
||||||
* user understandable explanation of the device error.
|
|
||||||
*/
|
|
||||||
|
|
||||||
u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat)
|
|
||||||
{
|
|
||||||
if (drive->media == ide_disk)
|
|
||||||
return ide_dump_ata_status(drive, msg, stat);
|
|
||||||
return ide_dump_atapi_status(drive, msg, stat);
|
|
||||||
}
|
|
||||||
|
|
||||||
EXPORT_SYMBOL(ide_dump_status);
|
EXPORT_SYMBOL(ide_dump_status);
|
||||||
|
Reference in New Issue
Block a user