ide: add ->fixup method to ide_hwif_t

* Add ->fixup method to ide_hwif_t.

* Set hwif->fixup in ide_pci_setup_ports() to d->fixup.

* Use hwif->fixup in probe_hwif().

* Use probe_hwif_init() instead of probe_hwif_init_with_fixup() in
  ide_setup_pci_device().

* Add 'fixup' argument to ide_register_hw() and use it to set hwif->fixup,
  update all ide_register_hw() users accordingly.

* Convert ide-cs/delkin_cb host drivers to use ide_register_hw().

* Restore hwif->fixup in ide_hwif_restore().

* Remove ide_register_hw_with_fixup(), probe_hwif_init_with_fixup()
  and 'fixup' argument from probe_hwif().
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 438c4702
...@@ -45,7 +45,7 @@ bastide_register(unsigned int base, unsigned int aux, int irq, ...@@ -45,7 +45,7 @@ bastide_register(unsigned int base, unsigned int aux, int irq,
hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20); hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20);
hw.irq = irq; hw.irq = irq;
ide_register_hw(&hw, 0, hwif); ide_register_hw(&hw, NULL, 0, hwif);
return 0; return 0;
} }
......
...@@ -31,5 +31,5 @@ void __init ide_arm_init(void) ...@@ -31,5 +31,5 @@ void __init ide_arm_init(void)
memset(&hw, 0, sizeof(hw)); memset(&hw, 0, sizeof(hw));
ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206); ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206);
hw.irq = IDE_ARM_IRQ; hw.irq = IDE_ARM_IRQ;
ide_register_hw(&hw, 1, NULL); ide_register_hw(&hw, NULL, 1, NULL);
} }
...@@ -782,7 +782,7 @@ init_e100_ide (void) ...@@ -782,7 +782,7 @@ init_e100_ide (void)
ide_offsets, ide_offsets,
0, 0, cris_ide_ack_intr, 0, 0, cris_ide_ack_intr,
ide_default_irq(0)); ide_default_irq(0));
ide_register_hw(&hw, 1, &hwif); ide_register_hw(&hw, NULL, 1, &hwif);
hwif->mmio = 1; hwif->mmio = 1;
hwif->chipset = ide_etrax100; hwif->chipset = ide_etrax100;
hwif->set_pio_mode = &cris_set_pio_mode; hwif->set_pio_mode = &cris_set_pio_mode;
......
...@@ -101,7 +101,7 @@ void __init h8300_ide_init(void) ...@@ -101,7 +101,7 @@ void __init h8300_ide_init(void)
hw_setup(&hw); hw_setup(&hw);
/* register if */ /* register if */
idx = ide_register_hw(&hw, 1, &hwif); idx = ide_register_hw(&hw, NULL, 1, &hwif);
if (idx == -1) { if (idx == -1) {
printk(KERN_ERR "ide-h8300: IDE I/F register failed\n"); printk(KERN_ERR "ide-h8300: IDE I/F register failed\n");
return; return;
......
...@@ -42,7 +42,7 @@ static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id ...@@ -42,7 +42,7 @@ static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id
hw.irq = pnp_irq(dev, 0); hw.irq = pnp_irq(dev, 0);
hw.dma = NO_DMA; hw.dma = NO_DMA;
index = ide_register_hw(&hw, 1, &hwif); index = ide_register_hw(&hw, NULL, 1, &hwif);
if (index != -1) { if (index != -1) {
printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index); printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index);
......
...@@ -717,7 +717,7 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave); ...@@ -717,7 +717,7 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave);
* This routine only knows how to look for drive units 0 and 1 * This routine only knows how to look for drive units 0 and 1
* on an interface, so any setting of MAX_DRIVES > 2 won't work here. * on an interface, so any setting of MAX_DRIVES > 2 won't work here.
*/ */
static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) static void probe_hwif(ide_hwif_t *hwif)
{ {
unsigned long flags; unsigned long flags;
unsigned int irqd; unsigned int irqd;
...@@ -819,8 +819,8 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) ...@@ -819,8 +819,8 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
return; return;
} }
if (fixup) if (hwif->fixup)
fixup(hwif); hwif->fixup(hwif);
for (unit = 0; unit < MAX_DRIVES; ++unit) { for (unit = 0; unit < MAX_DRIVES; ++unit) {
ide_drive_t *drive = &hwif->drives[unit]; ide_drive_t *drive = &hwif->drives[unit];
...@@ -861,9 +861,9 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) ...@@ -861,9 +861,9 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
static int hwif_init(ide_hwif_t *hwif); static int hwif_init(ide_hwif_t *hwif);
static void hwif_register_devices(ide_hwif_t *hwif); static void hwif_register_devices(ide_hwif_t *hwif);
int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) int probe_hwif_init(ide_hwif_t *hwif)
{ {
probe_hwif(hwif, fixup); probe_hwif(hwif);
if (!hwif_init(hwif)) { if (!hwif_init(hwif)) {
printk(KERN_INFO "%s: failed to initialize IDE interface\n", printk(KERN_INFO "%s: failed to initialize IDE interface\n",
...@@ -877,11 +877,6 @@ int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif) ...@@ -877,11 +877,6 @@ int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)
return 0; return 0;
} }
int probe_hwif_init(ide_hwif_t *hwif)
{
return probe_hwif_init_with_fixup(hwif, NULL);
}
EXPORT_SYMBOL(probe_hwif_init); EXPORT_SYMBOL(probe_hwif_init);
#if MAX_HWIFS > 1 #if MAX_HWIFS > 1
...@@ -1394,7 +1389,7 @@ int ideprobe_init (void) ...@@ -1394,7 +1389,7 @@ int ideprobe_init (void)
for (index = 0; index < MAX_HWIFS; ++index) for (index = 0; index < MAX_HWIFS; ++index)
if (probe[index]) if (probe[index])
probe_hwif(&ide_hwifs[index], NULL); probe_hwif(&ide_hwifs[index]);
for (index = 0; index < MAX_HWIFS; ++index) for (index = 0; index < MAX_HWIFS; ++index)
if (probe[index]) if (probe[index])
hwif_init(&ide_hwifs[index]); hwif_init(&ide_hwifs[index]);
......
...@@ -391,6 +391,8 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) ...@@ -391,6 +391,8 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
hwif->cds = tmp_hwif->cds; hwif->cds = tmp_hwif->cds;
#endif #endif
hwif->fixup = tmp_hwif->fixup;
hwif->set_pio_mode = tmp_hwif->set_pio_mode; hwif->set_pio_mode = tmp_hwif->set_pio_mode;
hwif->set_dma_mode = tmp_hwif->set_dma_mode; hwif->set_dma_mode = tmp_hwif->set_dma_mode;
hwif->mdma_filter = tmp_hwif->mdma_filter; hwif->mdma_filter = tmp_hwif->mdma_filter;
...@@ -660,11 +662,11 @@ void ide_setup_ports ( hw_regs_t *hw, ...@@ -660,11 +662,11 @@ void ide_setup_ports ( hw_regs_t *hw,
} }
/** /**
* ide_register_hw_with_fixup - register IDE interface * ide_register_hw - register IDE interface
* @hw: hardware registers * @hw: hardware registers
* @fixup: fixup function
* @initializing: set while initializing built-in drivers * @initializing: set while initializing built-in drivers
* @hwifp: pointer to returned hwif * @hwifp: pointer to returned hwif
* @fixup: fixup function
* *
* Register an IDE interface, specifying exactly the registers etc. * Register an IDE interface, specifying exactly the registers etc.
* Set init=1 iff calling before probes have taken place. * Set init=1 iff calling before probes have taken place.
...@@ -672,9 +674,8 @@ void ide_setup_ports ( hw_regs_t *hw, ...@@ -672,9 +674,8 @@ void ide_setup_ports ( hw_regs_t *hw,
* Returns -1 on error. * Returns -1 on error.
*/ */
int ide_register_hw_with_fixup(hw_regs_t *hw, int initializing, int ide_register_hw(hw_regs_t *hw, void (*fixup)(ide_hwif_t *),
ide_hwif_t **hwifp, int initializing, ide_hwif_t **hwifp)
void(*fixup)(ide_hwif_t *hwif))
{ {
int index, retry = 1; int index, retry = 1;
ide_hwif_t *hwif; ide_hwif_t *hwif;
...@@ -710,11 +711,12 @@ int ide_register_hw_with_fixup(hw_regs_t *hw, int initializing, ...@@ -710,11 +711,12 @@ int ide_register_hw_with_fixup(hw_regs_t *hw, int initializing,
memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports)); memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
hwif->irq = hw->irq; hwif->irq = hw->irq;
hwif->noprobe = 0; hwif->noprobe = 0;
hwif->fixup = fixup;
hwif->chipset = hw->chipset; hwif->chipset = hw->chipset;
hwif->gendev.parent = hw->dev; hwif->gendev.parent = hw->dev;
if (!initializing) { if (!initializing) {
probe_hwif_init_with_fixup(hwif, fixup); probe_hwif_init(hwif);
ide_proc_register_port(hwif); ide_proc_register_port(hwif);
} }
...@@ -724,13 +726,6 @@ int ide_register_hw_with_fixup(hw_regs_t *hw, int initializing, ...@@ -724,13 +726,6 @@ int ide_register_hw_with_fixup(hw_regs_t *hw, int initializing,
return (initializing || hwif->present) ? index : -1; return (initializing || hwif->present) ? index : -1;
} }
EXPORT_SYMBOL(ide_register_hw_with_fixup);
int ide_register_hw(hw_regs_t *hw, int initializing, ide_hwif_t **hwifp)
{
return ide_register_hw_with_fixup(hw, initializing, hwifp, NULL);
}
EXPORT_SYMBOL(ide_register_hw); EXPORT_SYMBOL(ide_register_hw);
/* /*
...@@ -1046,7 +1041,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device ...@@ -1046,7 +1041,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
ide_init_hwif_ports(&hw, (unsigned long) args[0], ide_init_hwif_ports(&hw, (unsigned long) args[0],
(unsigned long) args[1], NULL); (unsigned long) args[1], NULL);
hw.irq = args[2]; hw.irq = args[2];
if (ide_register_hw(&hw, 0, NULL) == -1) if (ide_register_hw(&hw, NULL, 0, NULL) == -1)
return -EIO; return -EIO;
return 0; return 0;
} }
......
...@@ -212,8 +212,8 @@ void __init buddha_init(void) ...@@ -212,8 +212,8 @@ void __init buddha_init(void)
// xsurf_iops, // xsurf_iops,
IRQ_AMIGA_PORTS); IRQ_AMIGA_PORTS);
} }
index = ide_register_hw(&hw, 1, &hwif); index = ide_register_hw(&hw, NULL, 1, &hwif);
if (index != -1) { if (index != -1) {
hwif->mmio = 1; hwif->mmio = 1;
printk("ide%d: ", index); printk("ide%d: ", index);
......
...@@ -72,7 +72,7 @@ void __init falconide_init(void) ...@@ -72,7 +72,7 @@ void __init falconide_init(void)
0, 0, NULL, 0, 0, NULL,
// falconide_iops, // falconide_iops,
IRQ_MFP_IDE); IRQ_MFP_IDE);
index = ide_register_hw(&hw, 1, NULL); index = ide_register_hw(&hw, NULL, 1, NULL);
if (index != -1) if (index != -1)
printk("ide%d: Falcon IDE interface\n", index); printk("ide%d: Falcon IDE interface\n", index);
......
...@@ -165,7 +165,7 @@ void __init gayle_init(void) ...@@ -165,7 +165,7 @@ void __init gayle_init(void)
// &gayle_iops, // &gayle_iops,
IRQ_AMIGA_PORTS); IRQ_AMIGA_PORTS);
index = ide_register_hw(&hw, 1, &hwif); index = ide_register_hw(&hw, NULL, 1, &hwif);
if (index != -1) { if (index != -1) {
hwif->mmio = 1; hwif->mmio = 1;
switch (i) { switch (i) {
......
...@@ -153,7 +153,7 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq ...@@ -153,7 +153,7 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq
hw.irq = irq; hw.irq = irq;
hw.chipset = ide_pci; hw.chipset = ide_pci;
hw.dev = &handle->dev; hw.dev = &handle->dev;
return ide_register_hw_with_fixup(&hw, 0, NULL, ide_undecoded_slave); return ide_register_hw(&hw, &ide_undecoded_slave, 0, NULL);
} }
/*====================================================================== /*======================================================================
......
...@@ -93,21 +93,21 @@ void macide_init(void) ...@@ -93,21 +93,21 @@ void macide_init(void)
0, 0, macide_ack_intr, 0, 0, macide_ack_intr,
// quadra_ide_iops, // quadra_ide_iops,
IRQ_NUBUS_F); IRQ_NUBUS_F);
index = ide_register_hw(&hw, 1, &hwif); index = ide_register_hw(&hw, NULL, 1, &hwif);
break; break;
case MAC_IDE_PB: case MAC_IDE_PB:
ide_setup_ports(&hw, IDE_BASE, macide_offsets, ide_setup_ports(&hw, IDE_BASE, macide_offsets,
0, 0, macide_ack_intr, 0, 0, macide_ack_intr,
// macide_pb_iops, // macide_pb_iops,
IRQ_NUBUS_C); IRQ_NUBUS_C);
index = ide_register_hw(&hw, 1, &hwif); index = ide_register_hw(&hw, NULL, 1, &hwif);
break; break;
case MAC_IDE_BABOON: case MAC_IDE_BABOON:
ide_setup_ports(&hw, BABOON_BASE, macide_offsets, ide_setup_ports(&hw, BABOON_BASE, macide_offsets,
0, 0, NULL, 0, 0, NULL,
// macide_baboon_iops, // macide_baboon_iops,
IRQ_BABOON_1); IRQ_BABOON_1);
index = ide_register_hw(&hw, 1, &hwif); index = ide_register_hw(&hw, NULL, 1, &hwif);
if (index == -1) break; if (index == -1) break;
if (macintosh_config->ident == MAC_MODEL_PB190) { if (macintosh_config->ident == MAC_MODEL_PB190) {
......
...@@ -142,7 +142,7 @@ void q40ide_init(void) ...@@ -142,7 +142,7 @@ void q40ide_init(void)
0, NULL, 0, NULL,
// m68kide_iops, // m68kide_iops,
q40ide_default_irq(pcide_bases[i])); q40ide_default_irq(pcide_bases[i]));
index = ide_register_hw(&hw, 1, &hwif); index = ide_register_hw(&hw, NULL, 1, &hwif);
// **FIXME** // **FIXME**
if (index != -1) if (index != -1)
hwif->mmio = 1; hwif->mmio = 1;
......
...@@ -80,7 +80,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -80,7 +80,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
hw.irq = dev->irq; hw.irq = dev->irq;
hw.chipset = ide_pci; /* this enables IRQ sharing */ hw.chipset = ide_pci; /* this enables IRQ sharing */
rc = ide_register_hw_with_fixup(&hw, 0, &hwif, ide_undecoded_slave); rc = ide_register_hw(&hw, &ide_undecoded_slave, 0, &hwif);
if (rc < 0) { if (rc < 0) {
printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc); printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc);
pci_disable_device(dev); pci_disable_device(dev);
......
...@@ -567,6 +567,8 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a ...@@ -567,6 +567,8 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a
(d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS))
hwif->irq = port ? 15 : 14; hwif->irq = port ? 15 : 14;
hwif->fixup = d->fixup;
hwif->host_flags = d->host_flags; hwif->host_flags = d->host_flags;
hwif->pio_mask = d->pio_mask; hwif->pio_mask = d->pio_mask;
...@@ -692,9 +694,9 @@ int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d) ...@@ -692,9 +694,9 @@ int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d)
mate = &ide_hwifs[index_list.b.high]; mate = &ide_hwifs[index_list.b.high];
if (hwif) if (hwif)
probe_hwif_init_with_fixup(hwif, d->fixup); probe_hwif_init(hwif);
if (mate) if (mate)
probe_hwif_init_with_fixup(mate, d->fixup); probe_hwif_init(mate);
if (hwif) if (hwif)
ide_proc_register_port(hwif); ide_proc_register_port(hwif);
......
...@@ -563,7 +563,7 @@ static void media_bay_step(int i) ...@@ -563,7 +563,7 @@ static void media_bay_step(int i)
ide_init_hwif_ports(&hw, (unsigned long) bay->cd_base, (unsigned long) 0, NULL); ide_init_hwif_ports(&hw, (unsigned long) bay->cd_base, (unsigned long) 0, NULL);
hw.irq = bay->cd_irq; hw.irq = bay->cd_irq;
hw.chipset = ide_pmac; hw.chipset = ide_pmac;
bay->cd_index = ide_register_hw(&hw, 0, NULL); bay->cd_index = ide_register_hw(&hw, NULL, 0, NULL);
pmu_resume(); pmu_resume();
} }
if (bay->cd_index == -1) { if (bay->cd_index == -1) {
......
...@@ -223,12 +223,8 @@ typedef struct hw_regs_s { ...@@ -223,12 +223,8 @@ typedef struct hw_regs_s {
struct device *dev; struct device *dev;
} hw_regs_t; } hw_regs_t;
/* int ide_register_hw(hw_regs_t *, void (*)(struct hwif_s *), int,
* Register new hardware with ide struct hwif_s **);
*/
int ide_register_hw(hw_regs_t *, int, struct hwif_s **);
int ide_register_hw_with_fixup(hw_regs_t *, int, struct hwif_s **,
void (*)(struct hwif_s *));
/* /*
* Set up hw_regs_t structure before calling ide_register_hw (optional) * Set up hw_regs_t structure before calling ide_register_hw (optional)
...@@ -727,6 +723,8 @@ typedef struct hwif_s { ...@@ -727,6 +723,8 @@ typedef struct hwif_s {
u8 (*mdma_filter)(ide_drive_t *); u8 (*mdma_filter)(ide_drive_t *);
u8 (*udma_filter)(ide_drive_t *); u8 (*udma_filter)(ide_drive_t *);
void (*fixup)(struct hwif_s *);
void (*ata_input_data)(ide_drive_t *, void *, u32); void (*ata_input_data)(ide_drive_t *, void *, u32);
void (*ata_output_data)(ide_drive_t *, void *, u32); void (*ata_output_data)(ide_drive_t *, void *, u32);
...@@ -1380,7 +1378,6 @@ void ide_unregister_region(struct gendisk *); ...@@ -1380,7 +1378,6 @@ void ide_unregister_region(struct gendisk *);
void ide_undecoded_slave(ide_hwif_t *); void ide_undecoded_slave(ide_hwif_t *);
int probe_hwif_init_with_fixup(ide_hwif_t *, void (*)(ide_hwif_t *));
extern int probe_hwif_init(ide_hwif_t *); extern int probe_hwif_init(ide_hwif_t *);
static inline void *ide_get_hwifdata (ide_hwif_t * hwif) static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment