ide: add ide_device_add()

* Add ide_device_add() helper and convert host drivers to use it
  instead of open-coded variants.

* Make ide_pci_setup_ports() and do_ide_setup_pci_device()
  take 'u8 *idx' argument instead of 'ata_index_t *index'.

* Remove no longer needed ata_index_t.

* Unexport probe_hwif_init() and make it static.

* Unexport ide_proc_register_port().

There should be no functionality changes caused by this patch
(sgiioc4.c: ide_proc_register_port() requires hwif->present
 to be set and it won't be set if probe_hwif_init() fails).
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent fd9bb539
...@@ -500,6 +500,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) ...@@ -500,6 +500,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
{ {
ide_hwif_t *hwif; ide_hwif_t *hwif;
void __iomem *base; void __iomem *base;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
if (!base) if (!base)
...@@ -523,9 +524,9 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) ...@@ -523,9 +524,9 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
state->hwif[0] = hwif; state->hwif[0] = hwif;
probe_hwif_init(hwif); idx[0] = hwif->index;
ide_proc_register_port(hwif); ide_device_add(idx);
return 0; return 0;
} }
...@@ -537,6 +538,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) ...@@ -537,6 +538,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
void __iomem *ioc_base, *easi_base; void __iomem *ioc_base, *easi_base;
unsigned int sel = 0; unsigned int sel = 0;
int ret; int ret;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
if (!ioc_base) { if (!ioc_base) {
...@@ -608,11 +610,10 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec) ...@@ -608,11 +610,10 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
icside_dma_init(mate); icside_dma_init(mate);
} }
probe_hwif_init(hwif); idx[0] = hwif->index;
probe_hwif_init(mate); idx[1] = mate->index;
ide_proc_register_port(hwif); ide_device_add(idx);
ide_proc_register_port(mate);
return 0; return 0;
......
...@@ -58,6 +58,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -58,6 +58,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
ide_hwif_t *hwif; ide_hwif_t *hwif;
void __iomem *base; void __iomem *base;
int ret; int ret;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
ret = ecard_request_resources(ec); ret = ecard_request_resources(ec);
if (ret) if (ret)
...@@ -74,8 +75,11 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -74,8 +75,11 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
hwif->hwif_data = base; hwif->hwif_data = base;
hwif->gendev.parent = &ec->dev; hwif->gendev.parent = &ec->dev;
hwif->noprobe = 0; hwif->noprobe = 0;
probe_hwif_init(hwif);
ide_proc_register_port(hwif); idx[0] = hwif->index;
ide_device_add(idx);
ecard_set_drvdata(ec, hwif); ecard_set_drvdata(ec, hwif);
goto out; goto out;
} }
......
...@@ -861,7 +861,7 @@ static void probe_hwif(ide_hwif_t *hwif) ...@@ -861,7 +861,7 @@ static void probe_hwif(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(ide_hwif_t *hwif) static int probe_hwif_init(ide_hwif_t *hwif)
{ {
probe_hwif(hwif); probe_hwif(hwif);
...@@ -877,8 +877,6 @@ int probe_hwif_init(ide_hwif_t *hwif) ...@@ -877,8 +877,6 @@ int probe_hwif_init(ide_hwif_t *hwif)
return 0; return 0;
} }
EXPORT_SYMBOL(probe_hwif_init);
#if MAX_HWIFS > 1 #if MAX_HWIFS > 1
/* /*
* save_match() is used to simplify logic in init_irq() below. * save_match() is used to simplify logic in init_irq() below.
...@@ -1410,3 +1408,22 @@ int ideprobe_init (void) ...@@ -1410,3 +1408,22 @@ int ideprobe_init (void)
} }
EXPORT_SYMBOL_GPL(ideprobe_init); EXPORT_SYMBOL_GPL(ideprobe_init);
int ide_device_add(u8 idx[4])
{
int i, rc = 0;
for (i = 0; i < 4; i++) {
if (idx[i] != 0xff)
rc |= probe_hwif_init(&ide_hwifs[idx[i]]);
}
for (i = 0; i < 4; i++) {
if (idx[i] != 0xff)
ide_proc_register_port(&ide_hwifs[idx[i]]);
}
return rc;
}
EXPORT_SYMBOL_GPL(ide_device_add);
...@@ -804,8 +804,6 @@ void ide_proc_register_port(ide_hwif_t *hwif) ...@@ -804,8 +804,6 @@ void ide_proc_register_port(ide_hwif_t *hwif)
create_proc_ide_drives(hwif); create_proc_ide_drives(hwif);
} }
EXPORT_SYMBOL_GPL(ide_proc_register_port);
#ifdef CONFIG_BLK_DEV_IDEPCI #ifdef CONFIG_BLK_DEV_IDEPCI
void ide_pci_create_host_proc(const char *name, get_info_t *get_info) void ide_pci_create_host_proc(const char *name, get_info_t *get_info)
{ {
......
...@@ -715,9 +715,10 @@ int ide_register_hw(hw_regs_t *hw, void (*fixup)(ide_hwif_t *), ...@@ -715,9 +715,10 @@ int ide_register_hw(hw_regs_t *hw, void (*fixup)(ide_hwif_t *),
hwif->chipset = hw->chipset; hwif->chipset = hw->chipset;
hwif->gendev.parent = hw->dev; hwif->gendev.parent = hw->dev;
if (!initializing) { if (initializing == 0) {
probe_hwif_init(hwif); u8 idx[4] = { index, 0xff, 0xff, 0xff };
ide_proc_register_port(hwif);
ide_device_add(idx);
} }
if (hwifp) if (hwifp)
......
...@@ -193,6 +193,7 @@ static int __init initRegisters (void) { ...@@ -193,6 +193,7 @@ static int __init initRegisters (void) {
static int __init ali14xx_probe(void) static int __init ali14xx_probe(void)
{ {
ide_hwif_t *hwif, *mate; ide_hwif_t *hwif, *mate;
static u8 idx[4] = { 0, 1, 0xff, 0xff };
printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n",
basePort, regOn); basePort, regOn);
...@@ -217,11 +218,7 @@ static int __init ali14xx_probe(void) ...@@ -217,11 +218,7 @@ static int __init ali14xx_probe(void)
mate->mate = hwif; mate->mate = hwif;
mate->channel = 1; mate->channel = 1;
probe_hwif_init(hwif); ide_device_add(idx);
probe_hwif_init(mate);
ide_proc_register_port(hwif);
ide_proc_register_port(mate);
return 0; return 0;
} }
......
...@@ -94,6 +94,7 @@ static int __init dtc2278_probe(void) ...@@ -94,6 +94,7 @@ static int __init dtc2278_probe(void)
{ {
unsigned long flags; unsigned long flags;
ide_hwif_t *hwif, *mate; ide_hwif_t *hwif, *mate;
static u8 idx[4] = { 0, 1, 0xff, 0xff };
hwif = &ide_hwifs[0]; hwif = &ide_hwifs[0];
mate = &ide_hwifs[1]; mate = &ide_hwifs[1];
...@@ -134,11 +135,7 @@ static int __init dtc2278_probe(void) ...@@ -134,11 +135,7 @@ static int __init dtc2278_probe(void)
mate->mate = hwif; mate->mate = hwif;
mate->channel = 1; mate->channel = 1;
probe_hwif_init(hwif); ide_device_add(idx);
probe_hwif_init(mate);
ide_proc_register_port(hwif);
ide_proc_register_port(mate);
return 0; return 0;
} }
......
...@@ -311,6 +311,7 @@ MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); ...@@ -311,6 +311,7 @@ MODULE_PARM_DESC(probe, "probe for HT6560B chipset");
int __init ht6560b_init(void) int __init ht6560b_init(void)
{ {
ide_hwif_t *hwif, *mate; ide_hwif_t *hwif, *mate;
static u8 idx[4] = { 0, 1, 0xff, 0xff };
int t; int t;
if (probe_ht6560b == 0) if (probe_ht6560b == 0)
...@@ -359,11 +360,7 @@ int __init ht6560b_init(void) ...@@ -359,11 +360,7 @@ int __init ht6560b_init(void)
mate->drives[0].drive_data = t; mate->drives[0].drive_data = t;
mate->drives[1].drive_data = t; mate->drives[1].drive_data = t;
probe_hwif_init(hwif); ide_device_add(idx);
probe_hwif_init(mate);
ide_proc_register_port(hwif);
ide_proc_register_port(mate);
return 0; return 0;
......
...@@ -83,6 +83,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) ...@@ -83,6 +83,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
struct resource *res_base, *res_alt, *res_irq; struct resource *res_base, *res_alt, *res_irq;
ide_hwif_t *hwif; ide_hwif_t *hwif;
struct pata_platform_info *pdata; struct pata_platform_info *pdata;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
int ret = 0; int ret = 0;
int mmio = 0; int mmio = 0;
...@@ -130,10 +131,11 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) ...@@ -130,10 +131,11 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
hwif->gendev.parent = &pdev->dev; hwif->gendev.parent = &pdev->dev;
hwif->noprobe = 0; hwif->noprobe = 0;
probe_hwif_init(hwif); idx[0] = hwif->index;
ide_device_add(idx);
platform_set_drvdata(pdev, hwif); platform_set_drvdata(pdev, hwif);
ide_proc_register_port(hwif);
return 0; return 0;
......
...@@ -389,6 +389,7 @@ static void __exit qd_unsetup(ide_hwif_t *hwif) ...@@ -389,6 +389,7 @@ static void __exit qd_unsetup(ide_hwif_t *hwif)
static int __init qd_probe(int base) static int __init qd_probe(int base)
{ {
ide_hwif_t *hwif; ide_hwif_t *hwif;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
u8 config; u8 config;
u8 unit; u8 unit;
...@@ -419,9 +420,9 @@ static int __init qd_probe(int base) ...@@ -419,9 +420,9 @@ static int __init qd_probe(int base)
hwif->set_pio_mode = &qd6500_set_pio_mode; hwif->set_pio_mode = &qd6500_set_pio_mode;
probe_hwif_init(hwif); idx[0] = unit;
ide_proc_register_port(hwif); ide_device_add(idx);
return 1; return 1;
} }
...@@ -453,11 +454,11 @@ static int __init qd_probe(int base) ...@@ -453,11 +454,11 @@ static int __init qd_probe(int base)
hwif->set_pio_mode = &qd6580_set_pio_mode; hwif->set_pio_mode = &qd6580_set_pio_mode;
probe_hwif_init(hwif); idx[0] = unit;
qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); ide_device_add(idx);
ide_proc_register_port(hwif); qd_write_reg(QD_DEF_CONTR, QD_CONTROL_PORT);
return 1; return 1;
} else { } else {
...@@ -474,19 +475,17 @@ static int __init qd_probe(int base) ...@@ -474,19 +475,17 @@ static int __init qd_probe(int base)
hwif->set_pio_mode = &qd6580_set_pio_mode; hwif->set_pio_mode = &qd6580_set_pio_mode;
probe_hwif_init(hwif);
qd_setup(mate, base, config | (control << 8), qd_setup(mate, base, config | (control << 8),
QD6580_DEF_DATA2, QD6580_DEF_DATA2); QD6580_DEF_DATA2, QD6580_DEF_DATA2);
mate->set_pio_mode = &qd6580_set_pio_mode; mate->set_pio_mode = &qd6580_set_pio_mode;
probe_hwif_init(mate); idx[0] = 0;
idx[1] = 1;
qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); ide_device_add(idx);
ide_proc_register_port(hwif); qd_write_reg(QD_DEF_CONTR, QD_CONTROL_PORT);
ide_proc_register_port(mate);
return 0; /* no other qd65xx possible */ return 0; /* no other qd65xx possible */
} }
......
...@@ -124,8 +124,9 @@ static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) ...@@ -124,8 +124,9 @@ static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio)
static int __init umc8672_probe(void) static int __init umc8672_probe(void)
{ {
unsigned long flags;
ide_hwif_t *hwif, *mate; ide_hwif_t *hwif, *mate;
unsigned long flags;
static u8 idx[4] = { 0, 1, 0xff, 0xff };
if (!request_region(0x108, 2, "umc8672")) { if (!request_region(0x108, 2, "umc8672")) {
printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n"); printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n");
...@@ -158,11 +159,7 @@ static int __init umc8672_probe(void) ...@@ -158,11 +159,7 @@ static int __init umc8672_probe(void)
mate->mate = hwif; mate->mate = hwif;
mate->channel = 1; mate->channel = 1;
probe_hwif_init(hwif); ide_device_add(idx);
probe_hwif_init(mate);
ide_proc_register_port(hwif);
ide_proc_register_port(mate);
return 0; return 0;
} }
......
...@@ -603,6 +603,7 @@ static int au_ide_probe(struct device *dev) ...@@ -603,6 +603,7 @@ static int au_ide_probe(struct device *dev)
struct resource *res; struct resource *res;
hw_regs_t *hw; hw_regs_t *hw;
int ret = 0; int ret = 0;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
char *mode = "MWDMA2"; char *mode = "MWDMA2";
...@@ -717,9 +718,9 @@ static int au_ide_probe(struct device *dev) ...@@ -717,9 +718,9 @@ static int au_ide_probe(struct device *dev)
dbdma_init_done = 1; dbdma_init_done = 1;
#endif #endif
probe_hwif_init(hwif); idx[0] = hwif->index;
ide_proc_register_port(hwif); ide_device_add(idx);
dev_set_drvdata(dev, hwif); dev_set_drvdata(dev, hwif);
......
...@@ -71,6 +71,7 @@ static int __devinit swarm_ide_probe(struct device *dev) ...@@ -71,6 +71,7 @@ static int __devinit swarm_ide_probe(struct device *dev)
u8 __iomem *base; u8 __iomem *base;
phys_t offset, size; phys_t offset, size;
int i; int i;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
if (!SIBYTE_HAVE_IDE) if (!SIBYTE_HAVE_IDE)
return -ENODEV; return -ENODEV;
...@@ -128,9 +129,9 @@ static int __devinit swarm_ide_probe(struct device *dev) ...@@ -128,9 +129,9 @@ static int __devinit swarm_ide_probe(struct device *dev)
memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports)); memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
hwif->irq = hwif->hw.irq; hwif->irq = hwif->hw.irq;
probe_hwif_init(hwif); idx[0] = hwif->index;
ide_proc_register_port(hwif); ide_device_add(idx);
dev_set_drvdata(dev, hwif); dev_set_drvdata(dev, hwif);
......
...@@ -154,9 +154,8 @@ static ide_pci_device_t cyrix_chipsets[] __devinitdata = { ...@@ -154,9 +154,8 @@ static ide_pci_device_t cyrix_chipsets[] __devinitdata = {
static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{ {
ide_hwif_t *hwif = NULL, *mate = NULL;
ata_index_t index;
ide_pci_device_t *d = &cyrix_chipsets[id->driver_data]; ide_pci_device_t *d = &cyrix_chipsets[id->driver_data];
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
ide_setup_pci_noise(dev, d); ide_setup_pci_noise(dev, d);
...@@ -172,29 +171,14 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic ...@@ -172,29 +171,14 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
return -ENODEV; return -ENODEV;
} }
index.all = 0xf0f0;
/* /*
* Now the chipset is configured we can let the core * Now the chipset is configured we can let the core
* do all the device setup for us * do all the device setup for us
*/ */
ide_pci_setup_ports(dev, d, 14, &index); ide_pci_setup_ports(dev, d, 14, &idx[0]);
if ((index.b.low & 0xf0) != 0xf0)
hwif = &ide_hwifs[index.b.low];
if ((index.b.high & 0xf0) != 0xf0)
mate = &ide_hwifs[index.b.high];
if (hwif)
probe_hwif_init(hwif);
if (mate)
probe_hwif_init(mate);
if (hwif) ide_device_add(idx);
ide_proc_register_port(hwif);
if (mate)
ide_proc_register_port(mate);
return 0; return 0;
} }
......
...@@ -614,6 +614,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) ...@@ -614,6 +614,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
void __iomem *virt_base; void __iomem *virt_base;
ide_hwif_t *hwif; ide_hwif_t *hwif;
int h; int h;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
/* /*
* Find an empty HWIF; if none available, return -ENOMEM. * Find an empty HWIF; if none available, return -ENOMEM.
...@@ -679,11 +680,10 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) ...@@ -679,11 +680,10 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
ide_init_sgiioc4(hwif); ide_init_sgiioc4(hwif);
if (probe_hwif_init(hwif)) idx[0] = hwif->index;
return -EIO;
/* Create /proc/ide entries */ if (ide_device_add(idx))
ide_proc_register_port(hwif); return -EIO;
return 0; return 0;
} }
......
...@@ -1039,6 +1039,7 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) ...@@ -1039,6 +1039,7 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
{ {
struct device_node *np = pmif->node; struct device_node *np = pmif->node;
const int *bidp; const int *bidp;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
pmif->cable_80 = 0; pmif->cable_80 = 0;
pmif->broken_dma = pmif->broken_dma_warn = 0; pmif->broken_dma = pmif->broken_dma_warn = 0;
...@@ -1163,10 +1164,9 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) ...@@ -1163,10 +1164,9 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
pmac_ide_setup_dma(pmif, hwif); pmac_ide_setup_dma(pmif, hwif);
#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
/* We probe the hwif now */ idx[0] = hwif->index;
probe_hwif_init(hwif);
ide_proc_register_port(hwif); ide_device_add(idx);
return 0; return 0;
} }
......
...@@ -512,7 +512,7 @@ static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, in ...@@ -512,7 +512,7 @@ static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, in
* @dev: PCI device * @dev: PCI device
* @d: IDE pci device info * @d: IDE pci device info
* @pciirq: IRQ line * @pciirq: IRQ line
* @index: ata index to update * @idx: ATA index table to update
* *
* Scan the interfaces attached to this device and do any * Scan the interfaces attached to this device and do any
* necessary per port setup. Attach the devices and ask the * necessary per port setup. Attach the devices and ask the
...@@ -522,15 +522,13 @@ static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, in ...@@ -522,15 +522,13 @@ static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, in
* but is also used directly as a helper function by some controllers * but is also used directly as a helper function by some controllers
* where the chipset setup is not the default PCI IDE one. * where the chipset setup is not the default PCI IDE one.
*/ */
void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, ata_index_t *index) void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, u8 *idx)
{ {
int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port;
ide_hwif_t *hwif, *mate = NULL; ide_hwif_t *hwif, *mate = NULL;
u8 tmp; u8 tmp;
index->all = 0xf0f0;
/* /*
* Set up the IDE ports * Set up the IDE ports
*/ */
...@@ -550,11 +548,7 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a ...@@ -550,11 +548,7 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a
/* setup proper ancestral information */ /* setup proper ancestral information */
hwif->gendev.parent = &dev->dev; hwif->gendev.parent = &dev->dev;
if (hwif->channel) { *(idx + port) = hwif->index;
index->b.high = hwif->index;
} else {
index->b.low = hwif->index;
}
if (d->init_iops) if (d->init_iops)
...@@ -620,9 +614,8 @@ EXPORT_SYMBOL_GPL(ide_pci_setup_ports); ...@@ -620,9 +614,8 @@ EXPORT_SYMBOL_GPL(ide_pci_setup_ports);
* for all other chipsets, we just assume both interfaces are enabled. * for all other chipsets, we just assume both interfaces are enabled.
*/ */
static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d, static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d,
ata_index_t *index, u8 noisy) u8 *idx, u8 noisy)
{ {
static ata_index_t ata_index = { .b = { .low = 0xff, .high = 0xff } };
int tried_config = 0; int tried_config = 0;
int pciirq, ret; int pciirq, ret;
...@@ -672,37 +665,21 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d, ...@@ -672,37 +665,21 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d,
/* FIXME: silent failure can happen */ /* FIXME: silent failure can happen */
*index = ata_index; ide_pci_setup_ports(dev, d, pciirq, idx);
ide_pci_setup_ports(dev, d, pciirq, index);
out: out:
return ret; return ret;
} }
int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d) int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d)
{ {
ide_hwif_t *hwif = NULL, *mate = NULL; u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
ata_index_t index_list;
int ret; int ret;
ret = do_ide_setup_pci_device(dev, d, &index_list, 1); ret = do_ide_setup_pci_device(dev, d, &idx[0], 1);
if (ret < 0)
goto out;
if ((index_list.b.low & 0xf0) != 0xf0) if (ret >= 0)
hwif = &ide_hwifs[index_list.b.low]; ide_device_add(idx);
if ((index_list.b.high & 0xf0) != 0xf0)
mate = &ide_hwifs[index_list.b.high];
if (hwif)
probe_hwif_init(hwif);
if (mate)
probe_hwif_init(mate);
if (hwif)
ide_proc_register_port(hwif);
if (mate)
ide_proc_register_port(mate);
out:
return ret; return ret;
} }
...@@ -712,11 +689,11 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, ...@@ -712,11 +689,11 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
ide_pci_device_t *d) ide_pci_device_t *d)
{ {
struct pci_dev *pdev[] = { dev1, dev2 }; struct pci_dev *pdev[] = { dev1, dev2 };
ata_index_t index_list[2];
int ret, i; int ret, i;
u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
ret = do_ide_setup_pci_device(pdev[i], d, index_list + i, !i); ret = do_ide_setup_pci_device(pdev[i], d, &idx[i*2], !i);
/* /*
* FIXME: Mom, mom, they stole me the helper function to undo * FIXME: Mom, mom, they stole me the helper function to undo
* do_ide_setup_pci_device() on the first device! * do_ide_setup_pci_device() on the first device!
...@@ -725,25 +702,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, ...@@ -725,25 +702,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
goto out; goto out;
} }
for (i = 0; i < 2; i++) { ide_device_add(idx);
u8 idx[2] = { index_list[i].b.low, index_list[i].b.high };
int j;
for (j = 0; j < 2; j++) {
if ((idx[j] & 0xf0) != 0xf0)
probe_hwif_init(ide_hwifs + idx[j]);
}
}
for (i = 0; i < 2; i++) {
u8 idx[2] = { index_list[i].b.low, index_list[i].b.high };
int j;
for (j = 0; j < 2; j++) {
if ((idx[j] & 0xf0) != 0xf0)
ide_proc_register_port(ide_hwifs + idx[j]);
}
}
out: out:
return ret; return ret;
} }
......
...@@ -361,7 +361,6 @@ typedef union { ...@@ -361,7 +361,6 @@ typedef union {
* ATA DATA Register Special. * ATA DATA Register Special.
* ATA NSECTOR Count Register(). * ATA NSECTOR Count Register().
* ATAPI Byte Count Register. * ATAPI Byte Count Register.
* Channel index ordering pairs.
*/ */
typedef union { typedef union {
unsigned all :16; unsigned all :16;
...@@ -376,7 +375,7 @@ typedef union { ...@@ -376,7 +375,7 @@ typedef union {
#error "Please fix <asm/byteorder.h>" #error "Please fix <asm/byteorder.h>"
#endif #endif
} b; } b;
} ata_nsector_t, ata_data_t, atapi_bcount_t, ata_index_t; } ata_nsector_t, ata_data_t, atapi_bcount_t;
/* /*
* ATA-IDE Select Register, aka Device-Head * ATA-IDE Select Register, aka Device-Head
...@@ -1200,7 +1199,7 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o ...@@ -1200,7 +1199,7 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o
#define ide_pci_register_driver(d) pci_register_driver(d) #define ide_pci_register_driver(d) pci_register_driver(d)
#endif #endif
void ide_pci_setup_ports(struct pci_dev *, struct ide_pci_device_s *, int, ata_index_t *); void ide_pci_setup_ports(struct pci_dev *, struct ide_pci_device_s *, int, u8 *);
extern void ide_setup_pci_noise (struct pci_dev *dev, struct ide_pci_device_s *d); extern void ide_setup_pci_noise (struct pci_dev *dev, struct ide_pci_device_s *d);
extern void default_hwif_iops(ide_hwif_t *); extern void default_hwif_iops(ide_hwif_t *);
...@@ -1378,7 +1377,7 @@ void ide_unregister_region(struct gendisk *); ...@@ -1378,7 +1377,7 @@ void ide_unregister_region(struct gendisk *);
void ide_undecoded_slave(ide_hwif_t *); void ide_undecoded_slave(ide_hwif_t *);
extern int probe_hwif_init(ide_hwif_t *); int ide_device_add(u8 idx[4]);
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