Skip to content

Commit

Permalink
ide: move read_sff_dma_status() method to 'struct ide_dma_ops'
Browse files Browse the repository at this point in the history
Move apparently misplaced read_sff_dma_status() method from 'struct ide_tp_ops'
to 'struct ide_dma_ops', renaming it to dma_sff_read_status() and making only
required for SFF-8038i compatible IDE controller drivers (greatly cutting down
the number of initializers) as its only user (outside ide-dma-sff.c and such
drivers) appears to be ide_pci_check_simplex() which is only called for such
controllers...

Signed-off-by: Sergei Shtylyov <[email protected]>
Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]>
  • Loading branch information
Sergei Shtylyov authored and bzolnier committed Jan 6, 2009
1 parent 3f023b0 commit 592b531
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 42 deletions.
1 change: 1 addition & 0 deletions drivers/ide/alim15x3.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ static const struct ide_dma_ops ali_dma_ops = {
.dma_test_irq = ide_dma_test_irq,
.dma_lost_irq = ide_dma_lost_irq,
.dma_timeout = ide_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

static const struct ide_port_info ali15x3_chipset __devinitdata = {
Expand Down
1 change: 0 additions & 1 deletion drivers/ide/au1xxx-ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,6 @@ static const struct ide_tp_ops au1xxx_tp_ops = {
.exec_command = ide_exec_command,
.read_status = ide_read_status,
.read_altstatus = ide_read_altstatus,
.read_sff_dma_status = ide_read_sff_dma_status,

.set_irq = ide_set_irq,

Expand Down
3 changes: 3 additions & 0 deletions drivers/ide/cmd64x.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ static const struct ide_dma_ops cmd64x_dma_ops = {
.dma_test_irq = cmd64x_dma_test_irq,
.dma_lost_irq = ide_dma_lost_irq,
.dma_timeout = ide_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

static const struct ide_dma_ops cmd646_rev1_dma_ops = {
Expand All @@ -396,6 +397,7 @@ static const struct ide_dma_ops cmd646_rev1_dma_ops = {
.dma_test_irq = ide_dma_test_irq,
.dma_lost_irq = ide_dma_lost_irq,
.dma_timeout = ide_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

static const struct ide_dma_ops cmd648_dma_ops = {
Expand All @@ -407,6 +409,7 @@ static const struct ide_dma_ops cmd648_dma_ops = {
.dma_test_irq = cmd648_dma_test_irq,
.dma_lost_irq = ide_dma_lost_irq,
.dma_timeout = ide_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

static const struct ide_port_info cmd64x_chipsets[] __devinitdata = {
Expand Down
1 change: 0 additions & 1 deletion drivers/ide/falconide.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ static const struct ide_tp_ops falconide_tp_ops = {
.exec_command = ide_exec_command,
.read_status = ide_read_status,
.read_altstatus = ide_read_altstatus,
.read_sff_dma_status = ide_read_sff_dma_status,

.set_irq = ide_set_irq,

Expand Down
3 changes: 3 additions & 0 deletions drivers/ide/hpt366.c
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,7 @@ static const struct ide_dma_ops hpt37x_dma_ops = {
.dma_test_irq = hpt374_dma_test_irq,
.dma_lost_irq = ide_dma_lost_irq,
.dma_timeout = ide_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

static const struct ide_dma_ops hpt370_dma_ops = {
Expand All @@ -1435,6 +1436,7 @@ static const struct ide_dma_ops hpt370_dma_ops = {
.dma_test_irq = ide_dma_test_irq,
.dma_lost_irq = ide_dma_lost_irq,
.dma_timeout = hpt370_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

static const struct ide_dma_ops hpt36x_dma_ops = {
Expand All @@ -1446,6 +1448,7 @@ static const struct ide_dma_ops hpt36x_dma_ops = {
.dma_test_irq = ide_dma_test_irq,
.dma_lost_irq = hpt366_dma_lost_irq,
.dma_timeout = ide_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
Expand Down
22 changes: 17 additions & 5 deletions drivers/ide/ide-dma-sff.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ int config_drive_for_dma(ide_drive_t *drive)
return 0;
}

u8 ide_dma_sff_read_status(ide_hwif_t *hwif)
{
unsigned long addr = hwif->dma_base + ATA_DMA_STATUS;

if (hwif->host_flags & IDE_HFLAG_MMIO)
return readb((void __iomem *)addr);
else
return inb(addr);
}
EXPORT_SYMBOL_GPL(ide_dma_sff_read_status);

/**
* ide_dma_host_set - Enable/disable DMA on a host
* @drive: drive to control
Expand All @@ -62,7 +73,7 @@ void ide_dma_host_set(ide_drive_t *drive, int on)
{
ide_hwif_t *hwif = drive->hwif;
u8 unit = drive->dn & 1;
u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
u8 dma_stat = hwif->dma_ops->dma_sff_read_status(hwif);

if (on)
dma_stat |= (1 << (5 + unit));
Expand Down Expand Up @@ -200,7 +211,7 @@ int ide_dma_setup(ide_drive_t *drive)
outb(reading, hwif->dma_base + ATA_DMA_CMD);

/* read DMA status for INTR & ERROR flags */
dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
dma_stat = hwif->dma_ops->dma_sff_read_status(hwif);

/* clear INTR & ERROR flags */
if (mmio)
Expand Down Expand Up @@ -232,7 +243,7 @@ EXPORT_SYMBOL_GPL(ide_dma_setup);
static int dma_timer_expiry(ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
u8 dma_stat = hwif->dma_ops->dma_sff_read_status(hwif);

printk(KERN_WARNING "%s: %s: DMA status (0x%02x)\n",
drive->name, __func__, dma_stat);
Expand Down Expand Up @@ -305,7 +316,7 @@ int ide_dma_end(ide_drive_t *drive)
}

/* get DMA status */
dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
dma_stat = hwif->dma_ops->dma_sff_read_status(hwif);

if (mmio)
/* clear the INTR & ERROR bits */
Expand All @@ -331,7 +342,7 @@ EXPORT_SYMBOL_GPL(ide_dma_end);
int ide_dma_test_irq(ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
u8 dma_stat = hwif->dma_ops->dma_sff_read_status(hwif);

return (dma_stat & ATA_DMA_INTR) ? 1 : 0;
}
Expand All @@ -346,5 +357,6 @@ const struct ide_dma_ops sff_dma_ops = {
.dma_test_irq = ide_dma_test_irq,
.dma_timeout = ide_dma_timeout,
.dma_lost_irq = ide_dma_lost_irq,
.dma_sff_read_status = ide_dma_sff_read_status,
};
EXPORT_SYMBOL_GPL(sff_dma_ops);
1 change: 0 additions & 1 deletion drivers/ide/ide-h8300.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ static const struct ide_tp_ops h8300_tp_ops = {
.exec_command = ide_exec_command,
.read_status = ide_read_status,
.read_altstatus = ide_read_altstatus,
.read_sff_dma_status = ide_read_sff_dma_status,

.set_irq = ide_set_irq,

Expand Down
10 changes: 0 additions & 10 deletions drivers/ide/ide-iops.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,6 @@ u8 ide_read_altstatus(ide_hwif_t *hwif)
}
EXPORT_SYMBOL_GPL(ide_read_altstatus);

u8 ide_read_sff_dma_status(ide_hwif_t *hwif)
{
if (hwif->host_flags & IDE_HFLAG_MMIO)
return readb((void __iomem *)(hwif->dma_base + ATA_DMA_STATUS));
else
return inb(hwif->dma_base + ATA_DMA_STATUS);
}
EXPORT_SYMBOL_GPL(ide_read_sff_dma_status);

void ide_set_irq(ide_hwif_t *hwif, int on)
{
u8 ctl = ATA_DEVCTL_OBS;
Expand Down Expand Up @@ -388,7 +379,6 @@ const struct ide_tp_ops default_tp_ops = {
.exec_command = ide_exec_command,
.read_status = ide_read_status,
.read_altstatus = ide_read_altstatus,
.read_sff_dma_status = ide_read_sff_dma_status,

.set_irq = ide_set_irq,

Expand Down
7 changes: 5 additions & 2 deletions drivers/ide/ide-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1229,19 +1229,22 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) {
int rc;

hwif->dma_ops = d->dma_ops;

if (d->init_dma)
rc = d->init_dma(hwif, d);
else
rc = ide_hwif_setup_dma(hwif, d);

if (rc < 0) {
printk(KERN_INFO "%s: DMA disabled\n", hwif->name);

hwif->dma_ops = NULL;
hwif->dma_base = 0;
hwif->swdma_mask = 0;
hwif->mwdma_mask = 0;
hwif->ultra_mask = 0;
} else if (d->dma_ops)
hwif->dma_ops = d->dma_ops;
}
}

if ((d->host_flags & IDE_HFLAG_SERIALIZE) ||
Expand Down
1 change: 1 addition & 0 deletions drivers/ide/it821x.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ static struct ide_dma_ops it821x_pass_through_dma_ops = {
.dma_test_irq = ide_dma_test_irq,
.dma_timeout = ide_dma_timeout,
.dma_lost_irq = ide_dma_lost_irq,
.dma_sff_read_status = ide_dma_sff_read_status,
};

/**
Expand Down
8 changes: 5 additions & 3 deletions drivers/ide/ns87415.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static u8 superio_read_status(ide_hwif_t *hwif)
return superio_ide_inb(hwif->io_ports.status_addr);
}

static u8 superio_read_sff_dma_status(ide_hwif_t *hwif)
static u8 superio_dma_sff_read_status(ide_hwif_t *hwif)
{
return superio_ide_inb(hwif->dma_base + ATA_DMA_STATUS);
}
Expand Down Expand Up @@ -109,7 +109,6 @@ static const struct ide_tp_ops superio_tp_ops = {
.exec_command = ide_exec_command,
.read_status = superio_read_status,
.read_altstatus = ide_read_altstatus,
.read_sff_dma_status = superio_read_sff_dma_status,

.set_irq = ide_set_irq,

Expand All @@ -132,6 +131,8 @@ static void __devinit superio_init_iops(struct hwif_s *hwif)
tmp = superio_ide_inb(dma_stat);
outb(tmp | 0x66, dma_stat);
}
#else
#define superio_dma_sff_read_status ide_dma_sff_read_status
#endif

static unsigned int ns87415_count = 0, ns87415_control[MAX_HWIFS] = { 0 };
Expand Down Expand Up @@ -201,7 +202,7 @@ static int ns87415_dma_end(ide_drive_t *drive)
u8 dma_stat = 0, dma_cmd = 0;

drive->waiting_for_dma = 0;
dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
dma_stat = hwif->dma_ops->dma_sff_read_status(hwif);
/* get DMA command mode */
dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD);
/* stop DMA */
Expand Down Expand Up @@ -308,6 +309,7 @@ static const struct ide_dma_ops ns87415_dma_ops = {
.dma_test_irq = ide_dma_test_irq,
.dma_lost_irq = ide_dma_lost_irq,
.dma_timeout = ide_dma_timeout,
.dma_sff_read_status = superio_dma_sff_read_status,
};

static const struct ide_port_info ns87415_chipset __devinitdata = {
Expand Down
2 changes: 2 additions & 0 deletions drivers/ide/pdc202xx_old.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ static const struct ide_dma_ops pdc20246_dma_ops = {
.dma_test_irq = pdc202xx_dma_test_irq,
.dma_lost_irq = pdc202xx_dma_lost_irq,
.dma_timeout = pdc202xx_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

static const struct ide_dma_ops pdc2026x_dma_ops = {
Expand All @@ -348,6 +349,7 @@ static const struct ide_dma_ops pdc2026x_dma_ops = {
.dma_test_irq = pdc202xx_dma_test_irq,
.dma_lost_irq = pdc202xx_dma_lost_irq,
.dma_timeout = pdc202xx_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

#define DECLARE_PDC2026X_DEV(udma, sectors) \
Expand Down
1 change: 0 additions & 1 deletion drivers/ide/pmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,6 @@ static const struct ide_tp_ops pmac_tp_ops = {
.exec_command = pmac_exec_command,
.read_status = ide_read_status,
.read_altstatus = ide_read_altstatus,
.read_sff_dma_status = ide_read_sff_dma_status,

.set_irq = pmac_set_irq,

Expand Down
1 change: 0 additions & 1 deletion drivers/ide/q40ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ static const struct ide_tp_ops q40ide_tp_ops = {
.exec_command = ide_exec_command,
.read_status = ide_read_status,
.read_altstatus = ide_read_altstatus,
.read_sff_dma_status = ide_read_sff_dma_status,

.set_irq = ide_set_irq,

Expand Down
1 change: 1 addition & 0 deletions drivers/ide/sc1200.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ static const struct ide_dma_ops sc1200_dma_ops = {
.dma_test_irq = ide_dma_test_irq,
.dma_lost_irq = ide_dma_lost_irq,
.dma_timeout = ide_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

static const struct ide_port_info sc1200_chipset __devinitdata = {
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/scc_pata.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static u8 scc_read_altstatus(ide_hwif_t *hwif)
return (u8)in_be32((void *)hwif->io_ports.ctl_addr);
}

static u8 scc_read_sff_dma_status(ide_hwif_t *hwif)
static u8 scc_dma_sff_read_status(ide_hwif_t *hwif)
{
return (u8)in_be32((void *)(hwif->dma_base + 4));
}
Expand Down Expand Up @@ -853,7 +853,6 @@ static const struct ide_tp_ops scc_tp_ops = {
.exec_command = scc_exec_command,
.read_status = scc_read_status,
.read_altstatus = scc_read_altstatus,
.read_sff_dma_status = scc_read_sff_dma_status,

.set_irq = scc_set_irq,

Expand All @@ -880,6 +879,7 @@ static const struct ide_dma_ops scc_dma_ops = {
.dma_test_irq = scc_dma_test_irq,
.dma_lost_irq = ide_dma_lost_irq,
.dma_timeout = ide_dma_timeout,
.dma_sff_read_status = scc_dma_sff_read_status,
};

#define DECLARE_SCC_DEV(name_str) \
Expand Down
7 changes: 4 additions & 3 deletions drivers/ide/setup-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ int ide_pci_check_simplex(ide_hwif_t *hwif, const struct ide_port_info *d)
* we tune the drive then try to grab DMA ownership if we want to be
* the DMA end. This has to be become dynamic to handle hot-plug.
*/
dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
dma_stat = hwif->dma_ops->dma_sff_read_status(hwif);
if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) {
printk(KERN_INFO "%s %s: simplex device: DMA disabled\n",
d->name, pci_name(dev));
Expand Down Expand Up @@ -377,6 +377,9 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d)

hwif->dma_base = base;

if (hwif->dma_ops == NULL)
hwif->dma_ops = &sff_dma_ops;

if (ide_pci_check_simplex(hwif, d) < 0)
return -1;

Expand All @@ -393,8 +396,6 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d)

if (ide_allocate_dma_engine(hwif))
return -1;

hwif->dma_ops = &sff_dma_ops;
}

return 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/ide/sgiioc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ static const struct ide_tp_ops sgiioc4_tp_ops = {
.exec_command = ide_exec_command,
.read_status = sgiioc4_read_status,
.read_altstatus = ide_read_altstatus,
.read_sff_dma_status = ide_read_sff_dma_status,

.set_irq = ide_set_irq,

Expand Down
1 change: 1 addition & 0 deletions drivers/ide/siimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ static const struct ide_dma_ops sil_dma_ops = {
.dma_test_irq = siimage_dma_test_irq,
.dma_timeout = ide_dma_timeout,
.dma_lost_irq = ide_dma_lost_irq,
.dma_sff_read_status = ide_dma_sff_read_status,
};

#define DECLARE_SII_DEV(p_ops) \
Expand Down
1 change: 1 addition & 0 deletions drivers/ide/sl82c105.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ static const struct ide_dma_ops sl82c105_dma_ops = {
.dma_test_irq = ide_dma_test_irq,
.dma_lost_irq = sl82c105_dma_lost_irq,
.dma_timeout = sl82c105_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

static const struct ide_port_info sl82c105_chipset __devinitdata = {
Expand Down
1 change: 1 addition & 0 deletions drivers/ide/tc86c001.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ static const struct ide_dma_ops tc86c001_dma_ops = {
.dma_test_irq = ide_dma_test_irq,
.dma_lost_irq = ide_dma_lost_irq,
.dma_timeout = ide_dma_timeout,
.dma_sff_read_status = ide_dma_sff_read_status,
};

static const struct ide_port_info tc86c001_chipset __devinitdata = {
Expand Down
Loading

0 comments on commit 592b531

Please sign in to comment.