Skip to content

Commit

Permalink
ide: use ATA_* defines instead of *_STAT and *_ERR ones
Browse files Browse the repository at this point in the history
* ERR_STAT   -> ATA_ERR
* INDEX_STAT -> ATA_IDX
* ECC_STAT   -> ATA_CORR
* DRQ_STAT   -> ATA_DRQ
* SEEK_STAT  -> ATA_DSC
* WRERR_STAT -> ATA_DF
* READY_STAT -> ATA_DRDY
* BUSY_STAT  -> ATA_BUSY

* MARK_ERR   -> ATA_AMNF
* TRK0_ERR   -> ATA_TRK0NF
* ABRT_ERR   -> ATA_ABORTED
* MCR_ERR    -> ATA_MCR
* ID_ERR     -> ATA_IDNF
* MC_ERR     -> ATA_MC
* ECC_ERR    -> ATA_UNC
* ICRC_ERR   -> ATA_ICRC

* BBD_ERR    -> ATA_BBK

Also:

* ILI_ERR    -> ATAPI_ILI
* EOM_ERR    -> ATAPI_EOM
* LFS_ERR    -> ATAPI_LFS

* CD         -> ATAPI_COD
* IO         -> ATAPI_IO

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
  • Loading branch information
Bartlomiej Zolnierkiewicz committed Oct 10, 2008
1 parent f26b3d7 commit 3a7d248
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 113 deletions.
32 changes: 17 additions & 15 deletions drivers/ide/ide-atapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,

if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
if (hwif->dma_ops->dma_end(drive) ||
(drive->media == ide_tape && !scsi && (stat & ERR_STAT))) {
(drive->media == ide_tape && !scsi && (stat & ATA_ERR))) {
if (drive->media == ide_floppy && !scsi)
printk(KERN_ERR "%s: DMA %s error\n",
drive->name, rq_data_dir(pc->rq)
Expand All @@ -56,7 +56,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
}

/* No more interrupts */
if ((stat & DRQ_STAT) == 0) {
if ((stat & ATA_DRQ) == 0) {
debug_log("Packet command completed, %d bytes transferred\n",
pc->xferred);

Expand All @@ -65,10 +65,10 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
local_irq_enable_in_hardirq();

if (drive->media == ide_tape && !scsi &&
(stat & ERR_STAT) && rq->cmd[0] == REQUEST_SENSE)
stat &= ~ERR_STAT;
(stat & ATA_ERR) && rq->cmd[0] == REQUEST_SENSE)
stat &= ~ATA_ERR;

if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) {
if ((stat & ATA_ERR) || (pc->flags & PC_FLAG_DMA_ERROR)) {
/* Error detected */
debug_log("%s: I/O error\n", drive->name);

Expand All @@ -95,7 +95,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
cmd_finished:
pc->error = 0;
if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) &&
(stat & SEEK_STAT) == 0) {
(stat & ATA_DSC) == 0) {
dsc_handle(drive);
return ide_stopped;
}
Expand All @@ -117,17 +117,18 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
/* Get the number of bytes to transfer on this interrupt. */
ide_read_bcount_and_ireason(drive, &bcount, &ireason);

if (ireason & CD) {
if (ireason & ATAPI_COD) {
printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__);
return ide_do_reset(drive);
}

if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
if (((ireason & ATAPI_IO) == ATAPI_IO) ==
!!(pc->flags & PC_FLAG_WRITING)) {
/* Hopefully, we will never get here */
printk(KERN_ERR "%s: We wanted to %s, but the device wants us "
"to %s!\n", drive->name,
(ireason & IO) ? "Write" : "Read",
(ireason & IO) ? "Read" : "Write");
(ireason & ATAPI_IO) ? "Write" : "Read",
(ireason & ATAPI_IO) ? "Read" : "Write");
return ide_do_reset(drive);
}

Expand Down Expand Up @@ -205,7 +206,8 @@ static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
{
int retries = 100;

while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) {
while (retries-- && ((ireason & ATAPI_COD) == 0 ||
(ireason & ATAPI_IO))) {
printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
"a packet command, retrying\n", drive->name);
udelay(100);
Expand All @@ -214,8 +216,8 @@ static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
"a packet command, ignoring\n",
drive->name);
ireason |= CD;
ireason &= ~IO;
ireason |= ATAPI_COD;
ireason &= ~ATAPI_IO;
}
}

Expand All @@ -231,7 +233,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
ide_startstop_t startstop;
u8 ireason;

if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) {
if (ide_wait_stat(&startstop, drive, ATA_DRQ, ATA_BUSY, WAIT_READY)) {
printk(KERN_ERR "%s: Strange, packet command initiated yet "
"DRQ isn't asserted\n", drive->name);
return startstop;
Expand All @@ -241,7 +243,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
if (drive->media == ide_tape && !drive->scsi)
ireason = ide_wait_ireason(drive, ireason);

if ((ireason & CD) == 0 || (ireason & IO)) {
if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) {
printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing "
"a packet command\n", drive->name);
return ide_do_reset(drive);
Expand Down
16 changes: 8 additions & 8 deletions drivers/ide/ide-cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
ide_dump_status_no_sense(drive, "media error (blank)",
stat);
do_end_request = 1;
} else if ((err & ~ABRT_ERR) != 0) {
} else if ((err & ~ATA_ABORTED) != 0) {
/* go to the default handler for other errors */
ide_error(drive, "cdrom_decode_status", stat);
return 1;
Expand All @@ -457,7 +457,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
* If we got a CHECK_CONDITION status, queue
* a request sense command.
*/
if (stat & ERR_STAT)
if (stat & ATA_ERR)
cdrom_queue_request_sense(drive, NULL, NULL);
} else {
blk_dump_rq_flags(rq, "ide-cd: bad rq");
Expand All @@ -468,7 +468,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
return 1;

end_request:
if (stat & ERR_STAT) {
if (stat & ATA_ERR) {
unsigned long flags;

spin_lock_irqsave(&ide_lock, flags);
Expand Down Expand Up @@ -574,16 +574,16 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
*/

/* check for errors */
if (cdrom_decode_status(drive, DRQ_STAT, NULL))
if (cdrom_decode_status(drive, ATA_DRQ, NULL))
return ide_stopped;

/* ok, next interrupt will be DMA interrupt */
if (info->dma)
drive->waiting_for_dma = 1;
} else {
/* otherwise, we must wait for DRQ to get set */
if (ide_wait_stat(&startstop, drive, DRQ_STAT,
BUSY_STAT, WAIT_READY))
if (ide_wait_stat(&startstop, drive, ATA_DRQ,
ATA_BUSY, WAIT_READY))
return startstop;
}

Expand Down Expand Up @@ -938,7 +938,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
thislen = len;

/* If DRQ is clear, the command has completed. */
if ((stat & DRQ_STAT) == 0) {
if ((stat & ATA_DRQ) == 0) {
if (blk_fs_request(rq)) {
/*
* If we're not done reading/writing, complain.
Expand Down Expand Up @@ -1206,7 +1206,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
unsigned long elapsed = jiffies - info->start_seek;
int stat = hwif->tp_ops->read_status(hwif);

if ((stat & SEEK_STAT) != SEEK_STAT) {
if ((stat & ATA_DSC) != ATA_DSC) {
if (elapsed < IDECD_SEEK_TIMEOUT) {
ide_stall_queue(drive,
IDECD_SEEK_TIMER);
Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/ide-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive)
dma_stat = hwif->dma_ops->dma_end(drive);
stat = hwif->tp_ops->read_status(hwif);

if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
if (OK_STAT(stat, DRIVE_READY, drive->bad_wstat | ATA_DRQ)) {
if (!dma_stat) {
struct request *rq = HWGROUP(drive)->rq;

Expand Down
2 changes: 1 addition & 1 deletion drivers/ide/ide-floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
stat = hwif->tp_ops->read_status(hwif);
local_irq_restore(flags);

progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000;
progress_indication = ((stat & ATA_DSC) == 0) ? 0 : 0x10000;
}
if (put_user(progress_indication, arg))
return (-EFAULT);
Expand Down
25 changes: 13 additions & 12 deletions drivers/ide/ide-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
ide_task_t *task = (ide_task_t *)rq->special;

if (rq->errors == 0)
rq->errors = !OK_STAT(stat, READY_STAT, BAD_STAT);
rq->errors = !OK_STAT(stat, ATA_DRDY, BAD_STAT);

if (task) {
struct ide_taskfile *tf = &task->tf;
Expand Down Expand Up @@ -373,29 +373,29 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
{
ide_hwif_t *hwif = drive->hwif;

if (stat & BUSY_STAT || ((stat & WRERR_STAT) && !drive->nowerr)) {
if ((stat & ATA_BUSY) || ((stat & ATA_DF) && !drive->nowerr)) {
/* other bits are useless when BUSY */
rq->errors |= ERROR_RESET;
} else if (stat & ERR_STAT) {
} else if (stat & ATA_ERR) {
/* err has different meaning on cdrom and tape */
if (err == ABRT_ERR) {
if (err == ATA_ABORTED) {
if (drive->select.b.lba &&
/* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */
hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS)
return ide_stopped;
} else if ((err & BAD_CRC) == BAD_CRC) {
/* UDMA crc error, just retry the operation */
drive->crc_count++;
} else if (err & (BBD_ERR | ECC_ERR)) {
} else if (err & (ATA_BBK | ATA_UNC)) {
/* retries won't help these */
rq->errors = ERROR_MAX;
} else if (err & TRK0_ERR) {
} else if (err & ATA_TRK0NF) {
/* help it find track zero */
rq->errors |= ERROR_RECAL;
}
}

if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ &&
if ((stat & ATA_DRQ) && rq_data_dir(rq) == READ &&
(hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) {
int nsect = drive->mult_count ? drive->mult_count : 1;

Expand All @@ -407,7 +407,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
return ide_stopped;
}

if (hwif->tp_ops->read_status(hwif) & (BUSY_STAT | DRQ_STAT))
if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ))
rq->errors |= ERROR_RESET;

if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
Expand All @@ -427,14 +427,14 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u
{
ide_hwif_t *hwif = drive->hwif;

if (stat & BUSY_STAT || ((stat & WRERR_STAT) && !drive->nowerr)) {
if ((stat & ATA_BUSY) || ((stat & ATA_DF) && !drive->nowerr)) {
/* other bits are useless when BUSY */
rq->errors |= ERROR_RESET;
} else {
/* add decoding error stuff */
}

if (hwif->tp_ops->read_status(hwif) & (BUSY_STAT | DRQ_STAT))
if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ))
/* force an abort */
hwif->tp_ops->exec_command(hwif, ATA_CMD_IDLEIMMEDIATE);

Expand Down Expand Up @@ -804,7 +804,8 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
ide_check_pm_state(drive, rq);

SELECT_DRIVE(drive);
if (ide_wait_stat(&startstop, drive, drive->ready_stat, BUSY_STAT|DRQ_STAT, WAIT_READY)) {
if (ide_wait_stat(&startstop, drive, drive->ready_stat,
ATA_BUSY | ATA_DRQ, WAIT_READY)) {
printk(KERN_ERR "%s: drive not ready for command\n", drive->name);
return startstop;
}
Expand Down Expand Up @@ -1324,7 +1325,7 @@ static void unexpected_intr (int irq, ide_hwgroup_t *hwgroup)
if (hwif->irq == irq) {
stat = hwif->tp_ops->read_status(hwif);

if (!OK_STAT(stat, READY_STAT, BAD_STAT)) {
if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) {
/* Try to not flood the console with msgs */
static unsigned long last_msgtime, count;
++count;
Expand Down
22 changes: 11 additions & 11 deletions drivers/ide/ide-iops.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ int drive_is_ready (ide_drive_t *drive)
/* Note: this may clear a pending IRQ!! */
stat = hwif->tp_ops->read_status(hwif);

if (stat & BUSY_STAT)
if (stat & ATA_BUSY)
/* drive busy: definitely not interrupting */
return 0;

Expand Down Expand Up @@ -505,18 +505,18 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
udelay(1); /* spec allows drive 400ns to assert "BUSY" */
stat = tp_ops->read_status(hwif);

if (stat & BUSY_STAT) {
if (stat & ATA_BUSY) {
local_irq_set(flags);
timeout += jiffies;
while ((stat = tp_ops->read_status(hwif)) & BUSY_STAT) {
while ((stat = tp_ops->read_status(hwif)) & ATA_BUSY) {
if (time_after(jiffies, timeout)) {
/*
* One last read after the timeout in case
* heavy interrupt load made us not make any
* progress during the timeout..
*/
stat = tp_ops->read_status(hwif);
if (!(stat & BUSY_STAT))
if ((stat & ATA_BUSY) == 0)
break;

local_irq_restore(flags);
Expand Down Expand Up @@ -685,12 +685,12 @@ int ide_driveid_update(ide_drive_t *drive)

msleep(50); /* give drive a breather */
stat = tp_ops->read_altstatus(hwif);
} while (stat & BUSY_STAT);
} while (stat & ATA_BUSY);

msleep(50); /* wait for IRQ and DRQ_STAT */
msleep(50); /* wait for IRQ and ATA_DRQ */
stat = tp_ops->read_status(hwif);

if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) {
if (!OK_STAT(stat, ATA_DRQ, BAD_R_STAT)) {
SELECT_MASK(drive, 0);
printk("%s: CHECK for good STATUS\n", drive->name);
return 0;
Expand Down Expand Up @@ -776,7 +776,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
tp_ops->set_irq(hwif, 1);

error = __ide_wait_stat(drive, drive->ready_stat,
BUSY_STAT|DRQ_STAT|ERR_STAT,
ATA_BUSY | ATA_DRQ | ATA_ERR,
WAIT_CMD, &stat);

SELECT_MASK(drive, 0);
Expand Down Expand Up @@ -923,7 +923,7 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
udelay (10);
stat = hwif->tp_ops->read_status(hwif);

if (OK_STAT(stat, 0, BUSY_STAT))
if (OK_STAT(stat, 0, ATA_BUSY))
printk("%s: ATAPI reset complete\n", drive->name);
else {
if (time_before(jiffies, hwgroup->poll_timeout)) {
Expand Down Expand Up @@ -969,7 +969,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)

tmp = hwif->tp_ops->read_status(hwif);

if (!OK_STAT(tmp, 0, BUSY_STAT)) {
if (!OK_STAT(tmp, 0, ATA_BUSY)) {
if (time_before(jiffies, hwgroup->poll_timeout)) {
ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL);
/* continue polling */
Expand Down Expand Up @@ -1183,7 +1183,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
*/
mdelay(1);
stat = hwif->tp_ops->read_status(hwif);
if ((stat & BUSY_STAT) == 0)
if ((stat & ATA_BUSY) == 0)
return 0;
/*
* Assume a value of 0xff means nothing is connected to
Expand Down
Loading

0 comments on commit 3a7d248

Please sign in to comment.