Skip to content

Commit

Permalink
ide: remove IDE_*_REG macros
Browse files Browse the repository at this point in the history
* Add IDE_{ALTSTATUS,IREASON,BCOUNTL,BCOUNTH}_OFFSET defines.

* Remove IDE_*_REG macros - this results in more readable
  and slightly smaller code.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
  • Loading branch information
Bartlomiej Zolnierkiewicz committed Apr 17, 2008
1 parent 7616c0a commit 23579a2
Show file tree
Hide file tree
Showing 15 changed files with 175 additions and 138 deletions.
18 changes: 14 additions & 4 deletions drivers/ide/cris/ide-cris.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ cris_ide_fill_descriptor(cris_dma_descr_type *d, void* buf, unsigned int len, in
static void
cris_ide_start_dma(ide_drive_t *drive, cris_dma_descr_type *d, int dir,int type,int len)
{
reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int, IDE_DATA_REG);
ide_hwif_t *hwif = drive->hwif;

reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int,
hwif->io_ports[IDE_DATA_OFFSET]);
reg_ata_rw_trf_cnt trf_cnt = {0};

mycontext.saved_data = (dma_descr_data*)virt_to_phys(d);
Expand Down Expand Up @@ -264,8 +267,12 @@ cris_ide_wait_dma(int dir)

static int cris_dma_test_irq(ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
int intr = REG_RD_INT(ata, regi_ata, r_intr);
reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int, IDE_DATA_REG);

reg_ata_rw_ctrl2 ctrl2 = REG_TYPE_CONV(reg_ata_rw_ctrl2, int,
hwif->io_ports[IDE_DATA_OFFSET]);

return intr & (1 << ctrl2.sel) ? 1 : 0;
}

Expand Down Expand Up @@ -523,7 +530,8 @@ static void cris_ide_start_dma(ide_drive_t *drive, cris_dma_descr_type *d, int d
IO_STATE(R_ATA_CTRL_DATA, handsh, dma);
*R_ATA_CTRL_DATA =
cmd |
IO_FIELD(R_ATA_CTRL_DATA, data, IDE_DATA_REG) |
IO_FIELD(R_ATA_CTRL_DATA, data,
drive->hwif->io_ports[IDE_DATA_OFFSET]) |
IO_STATE(R_ATA_CTRL_DATA, src_dst, dma) |
IO_STATE(R_ATA_CTRL_DATA, multi, on) |
IO_STATE(R_ATA_CTRL_DATA, dma_size, word);
Expand All @@ -541,7 +549,9 @@ cris_ide_wait_dma(int dir)
static int cris_dma_test_irq(ide_drive_t *drive)
{
int intr = *R_IRQ_MASK0_RD;
int bus = IO_EXTRACT(R_ATA_CTRL_DATA, sel, IDE_DATA_REG);
int bus = IO_EXTRACT(R_ATA_CTRL_DATA, sel,
drive->hwif->io_ports[IDE_DATA_OFFSET]);

return intr & (1 << (bus + IO_BITNR(R_IRQ_MASK0_RD, ata_irq0))) ? 1 : 0;
}

Expand Down
10 changes: 6 additions & 4 deletions drivers/ide/ide-cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,

/* packet command */
spin_lock_irqsave(&ide_lock, flags);
hwif->OUTBSYNC(drive, WIN_PACKETCMD, IDE_COMMAND_REG);
hwif->OUTBSYNC(drive, WIN_PACKETCMD,
hwif->io_ports[IDE_COMMAND_OFFSET]);
ndelay(400);
spin_unlock_irqrestore(&ide_lock, flags);

Expand Down Expand Up @@ -992,6 +993,7 @@ static int cdrom_newpc_intr_dummy_cb(struct request *rq)

static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
struct cdrom_info *info = drive->driver_data;
struct request *rq = HWGROUP(drive)->rq;
xfer_func_t *xferfunc;
Expand Down Expand Up @@ -1032,9 +1034,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
/*
* ok we fall to pio :/
*/
ireason = HWIF(drive)->INB(IDE_IREASON_REG) & 0x3;
lowcyl = HWIF(drive)->INB(IDE_BCOUNTL_REG);
highcyl = HWIF(drive)->INB(IDE_BCOUNTH_REG);
ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]) & 0x3;
lowcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
highcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]);

len = lowcyl + (256 * highcyl);

Expand Down
14 changes: 8 additions & 6 deletions drivers/ide/ide-floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,10 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
}

/* Get the number of bytes to transfer */
bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) |
hwif->INB(IDE_BCOUNTL_REG);
bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) |
hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
/* on this interrupt */
ireason = hwif->INB(IDE_IREASON_REG);
ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);

if (ireason & CD) {
printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__);
Expand Down Expand Up @@ -562,6 +562,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
*/
static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
ide_startstop_t startstop;
idefloppy_floppy_t *floppy = drive->driver_data;
u8 ireason;
Expand All @@ -571,7 +572,7 @@ static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive)
"initiated yet DRQ isn't asserted\n");
return startstop;
}
ireason = drive->hwif->INB(IDE_IREASON_REG);
ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
if ((ireason & CD) == 0 || (ireason & IO)) {
printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while "
"issuing a packet command\n");
Expand Down Expand Up @@ -608,6 +609,7 @@ static int idefloppy_transfer_pc2(ide_drive_t *drive)

static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
idefloppy_floppy_t *floppy = drive->driver_data;
ide_startstop_t startstop;
u8 ireason;
Expand All @@ -617,7 +619,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
"initiated yet DRQ isn't asserted\n");
return startstop;
}
ireason = drive->hwif->INB(IDE_IREASON_REG);
ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
if ((ireason & CD) == 0 || (ireason & IO)) {
printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) "
"while issuing a packet command\n");
Expand Down Expand Up @@ -723,7 +725,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
return ide_started;
} else {
/* Issue the packet command */
HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG);
hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]);
return (*pkt_xfer_routine) (drive);
}
}
Expand Down
38 changes: 23 additions & 15 deletions drivers/ide/ide-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,39 +301,45 @@ void ide_tf_read(ide_drive_t *drive, ide_task_t *task)
struct ide_taskfile *tf = &task->tf;

if (task->tf_flags & IDE_TFLAG_IN_DATA) {
u16 data = hwif->INW(IDE_DATA_REG);
u16 data = hwif->INW(hwif->io_ports[IDE_DATA_OFFSET]);

tf->data = data & 0xff;
tf->hob_data = (data >> 8) & 0xff;
}

/* be sure we're looking at the low order bits */
hwif->OUTB(drive->ctl & ~0x80, IDE_CONTROL_REG);
hwif->OUTB(drive->ctl & ~0x80, hwif->io_ports[IDE_CONTROL_OFFSET]);

if (task->tf_flags & IDE_TFLAG_IN_NSECT)
tf->nsect = hwif->INB(IDE_NSECTOR_REG);
tf->nsect = hwif->INB(hwif->io_ports[IDE_NSECTOR_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_LBAL)
tf->lbal = hwif->INB(IDE_SECTOR_REG);
tf->lbal = hwif->INB(hwif->io_ports[IDE_SECTOR_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_LBAM)
tf->lbam = hwif->INB(IDE_LCYL_REG);
tf->lbam = hwif->INB(hwif->io_ports[IDE_LCYL_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_LBAH)
tf->lbah = hwif->INB(IDE_HCYL_REG);
tf->lbah = hwif->INB(hwif->io_ports[IDE_HCYL_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_DEVICE)
tf->device = hwif->INB(IDE_SELECT_REG);
tf->device = hwif->INB(hwif->io_ports[IDE_SELECT_OFFSET]);

if (task->tf_flags & IDE_TFLAG_LBA48) {
hwif->OUTB(drive->ctl | 0x80, IDE_CONTROL_REG);
hwif->OUTB(drive->ctl | 0x80,
hwif->io_ports[IDE_CONTROL_OFFSET]);

if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
tf->hob_feature = hwif->INB(IDE_FEATURE_REG);
tf->hob_feature =
hwif->INB(hwif->io_ports[IDE_FEATURE_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
tf->hob_nsect = hwif->INB(IDE_NSECTOR_REG);
tf->hob_nsect =
hwif->INB(hwif->io_ports[IDE_NSECTOR_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
tf->hob_lbal = hwif->INB(IDE_SECTOR_REG);
tf->hob_lbal =
hwif->INB(hwif->io_ports[IDE_SECTOR_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
tf->hob_lbam = hwif->INB(IDE_LCYL_REG);
tf->hob_lbam =
hwif->INB(hwif->io_ports[IDE_LCYL_OFFSET]);
if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
tf->hob_lbah = hwif->INB(IDE_HCYL_REG);
tf->hob_lbah =
hwif->INB(hwif->io_ports[IDE_HCYL_OFFSET]);
}
}

Expand Down Expand Up @@ -448,7 +454,8 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
if (err == ABRT_ERR) {
if (drive->select.b.lba &&
/* some newer drives don't support WIN_SPECIFY */
hwif->INB(IDE_COMMAND_REG) == WIN_SPECIFY)
hwif->INB(hwif->io_ports[IDE_COMMAND_OFFSET]) ==
WIN_SPECIFY)
return ide_stopped;
} else if ((err & BAD_CRC) == BAD_CRC) {
/* UDMA crc error, just retry the operation */
Expand Down Expand Up @@ -500,7 +507,8 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u

if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
/* force an abort */
hwif->OUTB(WIN_IDLEIMMEDIATE, IDE_COMMAND_REG);
hwif->OUTB(WIN_IDLEIMMEDIATE,
hwif->io_ports[IDE_COMMAND_OFFSET]);

if (rq->errors >= ERROR_MAX) {
ide_kill_rq(drive, rq);
Expand Down
Loading

0 comments on commit 23579a2

Please sign in to comment.