ide: add ide_host_add() helper

Add ide_host_add() helper which does ide_host_alloc()+ide_host_register(),
then convert ide_setup_pci_device[s](), ide_legacy_device_add() and some
host drivers to use it.

While at it:

* Fix ide_setup_pci_device[s](), ide_arm.c, gayle.c, ide-4drives.c,
  macide.c, q40ide.c, cmd640.c and cs5520.c to return correct error value.

* -ENOENT -> -ENOMEM in rapide.c, ide-h8300.c, ide-generic.c, au1xxx-ide.c
  and pmac.c

* -ENODEV -> -ENOMEM in palm_bk3710.c, ide_platform.c and delkin_cb.c

* -1 -> -ENOMEM in ide-pnp.c
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 48c3c107
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
static int __init ide_arm_init(void) static int __init ide_arm_init(void)
{ {
struct ide_host *host;
unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206; unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
...@@ -50,11 +49,7 @@ static int __init ide_arm_init(void) ...@@ -50,11 +49,7 @@ static int __init ide_arm_init(void)
hw.irq = IDE_ARM_IRQ; hw.irq = IDE_ARM_IRQ;
hw.chipset = ide_generic; hw.chipset = ide_generic;
host = ide_host_alloc(NULL, hws); return ide_host_add(NULL, hws, NULL);
if (host)
ide_host_register(host, NULL, hws);
return 0;
} }
module_init(ide_arm_init); module_init(ide_arm_init);
......
...@@ -349,7 +349,7 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) ...@@ -349,7 +349,7 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
struct resource *mem, *irq; struct resource *mem, *irq;
struct ide_host *host; struct ide_host *host;
unsigned long base, rate; unsigned long base, rate;
int i; int i, rc;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
clk = clk_get(NULL, "IDECLK"); clk = clk_get(NULL, "IDECLK");
...@@ -392,16 +392,14 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) ...@@ -392,16 +392,14 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
hw.irq = irq->start; hw.irq = irq->start;
hw.chipset = ide_palm3710; hw.chipset = ide_palm3710;
host = ide_host_alloc(&palm_bk3710_port_info, hws); rc = ide_host_add(&palm_bk3710_port_info, hws, NULL);
if (host == NULL) if (rc)
goto out; goto out;
ide_host_register(host, &palm_bk3710_port_info, hws);
return 0; return 0;
out: out:
printk(KERN_WARNING "Palm Chip BK3710 IDE Register Fail\n"); printk(KERN_WARNING "Palm Chip BK3710 IDE Register Fail\n");
return -ENODEV; return rc;
} }
/* work with hotplug and coldplug */ /* work with hotplug and coldplug */
......
...@@ -52,13 +52,9 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -52,13 +52,9 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
hw.chipset = ide_generic; hw.chipset = ide_generic;
hw.dev = &ec->dev; hw.dev = &ec->dev;
host = ide_host_alloc(&rapide_port_info, hws); ret = ide_host_add(&rapide_port_info, hws, &host);
if (host == NULL) { if (ret)
ret = -ENOENT;
goto release; goto release;
}
ide_host_register(host, &rapide_port_info, hws);
ecard_set_drvdata(ec, host); ecard_set_drvdata(ec, host);
goto out; goto out;
......
...@@ -191,7 +191,6 @@ static const struct ide_port_info h8300_port_info = { ...@@ -191,7 +191,6 @@ static const struct ide_port_info h8300_port_info = {
static int __init h8300_ide_init(void) static int __init h8300_ide_init(void)
{ {
struct ide_host *host;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n"); printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n");
...@@ -205,13 +204,7 @@ static int __init h8300_ide_init(void) ...@@ -205,13 +204,7 @@ static int __init h8300_ide_init(void)
hw_setup(&hw); hw_setup(&hw);
host = ide_host_alloc(&h8300_port_info, hws); return ide_host_add(&h8300_port_info, hws, NULL);
if (host == NULL)
return -ENOENT;
ide_host_register(host, &h8300_port_info, hws);
return 0;
out_busy: out_busy:
printk(KERN_ERR "ide-h8300: IDE I/F resource already used.\n"); printk(KERN_ERR "ide-h8300: IDE I/F resource already used.\n");
......
...@@ -28,9 +28,8 @@ MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports"); ...@@ -28,9 +28,8 @@ MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports");
static ssize_t store_add(struct class *cls, const char *buf, size_t n) static ssize_t store_add(struct class *cls, const char *buf, size_t n)
{ {
struct ide_host *host;
unsigned int base, ctl; unsigned int base, ctl;
int irq; int irq, rc;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3) if (sscanf(buf, "%x:%x:%d", &base, &ctl, &irq) != 3)
...@@ -41,11 +40,9 @@ static ssize_t store_add(struct class *cls, const char *buf, size_t n) ...@@ -41,11 +40,9 @@ static ssize_t store_add(struct class *cls, const char *buf, size_t n)
hw.irq = irq; hw.irq = irq;
hw.chipset = ide_generic; hw.chipset = ide_generic;
host = ide_host_alloc(NULL, hws); rc = ide_host_add(NULL, hws, NULL);
if (host == NULL) if (rc)
return -ENOENT; return rc;
ide_host_register(host, NULL, hws);
return n; return n;
}; };
......
...@@ -31,6 +31,7 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) ...@@ -31,6 +31,7 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
{ {
struct ide_host *host; struct ide_host *host;
unsigned long base, ctl; unsigned long base, ctl;
int rc;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n"); printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n");
...@@ -59,19 +60,18 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) ...@@ -59,19 +60,18 @@ 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.chipset = ide_generic; hw.chipset = ide_generic;
host = ide_host_alloc(NULL, hws); rc = ide_host_add(NULL, hws, &host);
if (host) { if (rc)
pnp_set_drvdata(dev, host); goto out;
ide_host_register(host, NULL, hws); pnp_set_drvdata(dev, host);
return 0;
}
return 0;
out:
release_region(ctl, 1); release_region(ctl, 1);
release_region(base, 8); release_region(base, 8);
return -1; return rc;
} }
static void idepnp_remove(struct pnp_dev *dev) static void idepnp_remove(struct pnp_dev *dev)
......
...@@ -1677,6 +1677,24 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1677,6 +1677,24 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
} }
EXPORT_SYMBOL_GPL(ide_host_register); EXPORT_SYMBOL_GPL(ide_host_register);
int ide_host_add(const struct ide_port_info *d, hw_regs_t **hws,
struct ide_host **hostp)
{
struct ide_host *host;
host = ide_host_alloc(d, hws);
if (host == NULL)
return -ENOMEM;
ide_host_register(host, d, hws);
if (hostp)
*hostp = host;
return 0;
}
EXPORT_SYMBOL_GPL(ide_host_add);
void ide_host_remove(struct ide_host *host) void ide_host_remove(struct ide_host *host)
{ {
int i; int i;
...@@ -1749,7 +1767,6 @@ static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw, ...@@ -1749,7 +1767,6 @@ static void ide_legacy_init_one(hw_regs_t **hws, hw_regs_t *hw,
int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
{ {
struct ide_host *host;
hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL }; hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
memset(&hw, 0, sizeof(hw)); memset(&hw, 0, sizeof(hw));
...@@ -1762,12 +1779,6 @@ int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) ...@@ -1762,12 +1779,6 @@ int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config)
(d->host_flags & IDE_HFLAG_SINGLE)) (d->host_flags & IDE_HFLAG_SINGLE))
return -ENOENT; return -ENOENT;
host = ide_host_alloc(d, hws); return ide_host_add(d, hws, NULL);
if (host == NULL)
return -ENOMEM;
ide_host_register(host, d, hws);
return 0;
} }
EXPORT_SYMBOL_GPL(ide_legacy_device_add); EXPORT_SYMBOL_GPL(ide_legacy_device_add);
...@@ -151,7 +151,6 @@ static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base, ...@@ -151,7 +151,6 @@ static void __init buddha_setup_ports(hw_regs_t *hw, unsigned long base,
static int __init buddha_init(void) static int __init buddha_init(void)
{ {
struct zorro_dev *z = NULL; struct zorro_dev *z = NULL;
struct ide_host *host;
u_long buddha_board = 0; u_long buddha_board = 0;
BuddhaType type; BuddhaType type;
int buddha_num_hwifs, i; int buddha_num_hwifs, i;
...@@ -226,9 +225,7 @@ static int __init buddha_init(void) ...@@ -226,9 +225,7 @@ static int __init buddha_init(void)
hws[i] = &hw[i]; hws[i] = &hw[i];
} }
host = ide_host_alloc(NULL, hws); ide_host_add(NULL, hws, NULL);
if (host)
ide_host_register(host, NULL, hws);
} }
return 0; return 0;
......
...@@ -127,7 +127,6 @@ static int __init gayle_init(void) ...@@ -127,7 +127,6 @@ static int __init gayle_init(void)
unsigned long phys_base, res_start, res_n; unsigned long phys_base, res_start, res_n;
unsigned long base, ctrlport, irqport; unsigned long base, ctrlport, irqport;
ide_ack_intr_t *ack_intr; ide_ack_intr_t *ack_intr;
struct ide_host *host;
int a4000, i; int a4000, i;
hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
...@@ -180,11 +179,7 @@ static int __init gayle_init(void) ...@@ -180,11 +179,7 @@ static int __init gayle_init(void)
hws[i] = &hw[i]; hws[i] = &hw[i];
} }
host = ide_host_alloc(NULL, hws); return ide_host_add(NULL, hws, NULL);
if (host)
ide_host_register(host, NULL, hws);
return 0;
} }
module_init(gayle_init); module_init(gayle_init);
......
...@@ -28,7 +28,6 @@ static const struct ide_port_info ide_4drives_port_info = { ...@@ -28,7 +28,6 @@ static const struct ide_port_info ide_4drives_port_info = {
static int __init ide_4drives_init(void) static int __init ide_4drives_init(void)
{ {
struct ide_host *host;
unsigned long base = 0x1f0, ctl = 0x3f6; unsigned long base = 0x1f0, ctl = 0x3f6;
hw_regs_t hw, *hws[] = { &hw, &hw, NULL, NULL }; hw_regs_t hw, *hws[] = { &hw, &hw, NULL, NULL };
...@@ -54,11 +53,7 @@ static int __init ide_4drives_init(void) ...@@ -54,11 +53,7 @@ static int __init ide_4drives_init(void)
hw.irq = 14; hw.irq = 14;
hw.chipset = ide_4drives; hw.chipset = ide_4drives;
host = ide_host_alloc(&ide_4drives_port_info, hws); return ide_host_add(&ide_4drives_port_info, hws, NULL);
if (host)
ide_host_register(host, &ide_4drives_port_info, hws);
return 0;
} }
module_init(ide_4drives_init); module_init(ide_4drives_init);
......
...@@ -162,7 +162,7 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl, ...@@ -162,7 +162,7 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl,
{ {
struct ide_host *host; struct ide_host *host;
ide_hwif_t *hwif; ide_hwif_t *hwif;
int i; int i, rc;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
if (!request_region(io, 8, DRV_NAME)) { if (!request_region(io, 8, DRV_NAME)) {
...@@ -184,12 +184,10 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl, ...@@ -184,12 +184,10 @@ static struct ide_host *idecs_register(unsigned long io, unsigned long ctl,
hw.chipset = ide_pci; hw.chipset = ide_pci;
hw.dev = &handle->dev; hw.dev = &handle->dev;
host = ide_host_alloc(&idecs_port_info, hws); rc = ide_host_add(&idecs_port_info, hws, &host);
if (host == NULL) if (rc)
goto out_release; goto out_release;
ide_host_register(host, &idecs_port_info, hws);
hwif = host->ports[0]; hwif = host->ports[0];
if (hwif->present) if (hwif->present)
......
...@@ -99,13 +99,9 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) ...@@ -99,13 +99,9 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
if (mmio) if (mmio)
d.host_flags |= IDE_HFLAG_MMIO; d.host_flags |= IDE_HFLAG_MMIO;
host = ide_host_alloc(&d, hws); ret = ide_host_add(&d, hws, &host);
if (host == NULL) { if (ret)
ret = -ENODEV;
goto out; goto out;
}
ide_host_register(host, &d, hws);
platform_set_drvdata(pdev, host); platform_set_drvdata(pdev, host);
......
...@@ -92,7 +92,6 @@ static const char *mac_ide_name[] = ...@@ -92,7 +92,6 @@ static const char *mac_ide_name[] =
static int __init macide_init(void) static int __init macide_init(void)
{ {
ide_ack_intr_t *ack_intr; ide_ack_intr_t *ack_intr;
struct ide_host *host;
unsigned long base; unsigned long base;
int irq; int irq;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
...@@ -125,11 +124,7 @@ static int __init macide_init(void) ...@@ -125,11 +124,7 @@ static int __init macide_init(void)
macide_setup_ports(&hw, base, irq, ack_intr); macide_setup_ports(&hw, base, irq, ack_intr);
host = ide_host_alloc(NULL, hws); return ide_host_add(NULL, hws, NULL);
if (host)
ide_host_register(host, NULL, hws);
return 0;
} }
module_init(macide_init); module_init(macide_init);
......
...@@ -131,7 +131,6 @@ static const char *q40_ide_names[Q40IDE_NUM_HWIFS]={ ...@@ -131,7 +131,6 @@ static const char *q40_ide_names[Q40IDE_NUM_HWIFS]={
static int __init q40ide_init(void) static int __init q40ide_init(void)
{ {
struct ide_host *host;
int i; int i;
hw_regs_t hw[Q40IDE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; hw_regs_t hw[Q40IDE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
...@@ -160,11 +159,7 @@ static int __init q40ide_init(void) ...@@ -160,11 +159,7 @@ static int __init q40ide_init(void)
hws[i] = &hw[i]; hws[i] = &hw[i];
} }
host = ide_host_alloc(&q40ide_port_info, hws); return ide_host_add(&q40ide_port_info, hws, NULL);
if (host)
ide_host_register(host, &q40ide_port_info, hws);
return 0;
} }
module_init(q40ide_init); module_init(q40ide_init);
......
...@@ -609,13 +609,9 @@ static int au_ide_probe(struct device *dev) ...@@ -609,13 +609,9 @@ static int au_ide_probe(struct device *dev)
hw.dev = dev; hw.dev = dev;
hw.chipset = ide_au1xxx; hw.chipset = ide_au1xxx;
host = ide_host_alloc(&au1xxx_port_info, hws); ret = ide_host_add(&au1xxx_port_info, hws, &host);
if (host == NULL) { if (ret)
ret = -ENOENT;
goto out; goto out;
}
ide_host_register(host, &au1xxx_port_info, hws);
auide_hwif.hwif = host->ports[0]; auide_hwif.hwif = host->ports[0];
......
...@@ -75,7 +75,7 @@ static int __devinit swarm_ide_probe(struct device *dev) ...@@ -75,7 +75,7 @@ static int __devinit swarm_ide_probe(struct device *dev)
u8 __iomem *base; u8 __iomem *base;
struct ide_host *host; struct ide_host *host;
phys_t offset, size; phys_t offset, size;
int i; int i, rc;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
if (!SIBYTE_HAVE_IDE) if (!SIBYTE_HAVE_IDE)
...@@ -115,19 +115,17 @@ static int __devinit swarm_ide_probe(struct device *dev) ...@@ -115,19 +115,17 @@ static int __devinit swarm_ide_probe(struct device *dev)
hw.irq = K_INT_GB_IDE; hw.irq = K_INT_GB_IDE;
hw.chipset = ide_generic; hw.chipset = ide_generic;
host = ide_host_alloc(&swarm_port_info, hws); rc = ide_host_add(&swarm_port_info, hws, &host);
if (host == NULL) if (rc)
goto err; goto err;
ide_host_register(host, &swarm_port_info, hws);
dev_set_drvdata(dev, host); dev_set_drvdata(dev, host);
return 0; return 0;
err: err:
release_resource(&swarm_ide_resource); release_resource(&swarm_ide_resource);
iounmap(base); iounmap(base);
return -ENOMEM; return rc;
} }
static struct device_driver swarm_ide_driver = { static struct device_driver swarm_ide_driver = {
......
...@@ -709,7 +709,6 @@ static int cmd640x_init_one(unsigned long base, unsigned long ctl) ...@@ -709,7 +709,6 @@ static int cmd640x_init_one(unsigned long base, unsigned long ctl)
*/ */
static int __init cmd640x_init(void) static int __init cmd640x_init(void)
{ {
struct ide_host *host;
int second_port_cmd640 = 0, rc; int second_port_cmd640 = 0, rc;
const char *bus_type, *port2; const char *bus_type, *port2;
u8 b, cfr; u8 b, cfr;
...@@ -829,11 +828,7 @@ static int __init cmd640x_init(void) ...@@ -829,11 +828,7 @@ static int __init cmd640x_init(void)
cmd640_dump_regs(); cmd640_dump_regs();
#endif #endif
host = ide_host_alloc(&cmd640_port_info, hws); return ide_host_add(&cmd640_port_info, hws, NULL);
if (host)
ide_host_register(host, &cmd640_port_info, hws);
return 1;
} }
module_param_named(probe_vlb, cmd640_vlb, bool, 0); module_param_named(probe_vlb, cmd640_vlb, bool, 0);
......
...@@ -114,7 +114,6 @@ static const struct ide_port_info cyrix_chipsets[] __devinitdata = { ...@@ -114,7 +114,6 @@ static const struct ide_port_info 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)
{ {
struct ide_host *host;
const struct ide_port_info *d = &cyrix_chipsets[id->driver_data]; const struct ide_port_info *d = &cyrix_chipsets[id->driver_data];
hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
...@@ -140,11 +139,7 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic ...@@ -140,11 +139,7 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
ide_pci_setup_ports(dev, d, 14, &hw[0], &hws[0]); ide_pci_setup_ports(dev, d, 14, &hw[0], &hws[0]);
host = ide_host_alloc(d, hws); return ide_host_add(d, hws, NULL);
if (host)
ide_host_register(host, d, hws);
return 0;
} }
static const struct pci_device_id cs5520_pci_tbl[] = { static const struct pci_device_id cs5520_pci_tbl[] = {
......
...@@ -86,12 +86,10 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -86,12 +86,10 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
hw.dev = &dev->dev; hw.dev = &dev->dev;
hw.chipset = ide_pci; /* this enables IRQ sharing */ hw.chipset = ide_pci; /* this enables IRQ sharing */
host = ide_host_alloc(&delkin_cb_port_info, hws); rc = ide_host_add(&delkin_cb_port_info, hws, &host);
if (host == NULL) if (rc)
goto out_disable; goto out_disable;
ide_host_register(host, &delkin_cb_port_info, hws);
pci_set_drvdata(dev, host); pci_set_drvdata(dev, host);
return 0; return 0;
...@@ -99,7 +97,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -99,7 +97,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
out_disable: out_disable:
pci_release_regions(dev); pci_release_regions(dev);
pci_disable_device(dev); pci_disable_device(dev);
return -ENODEV; return rc;
} }
static void static void
......
...@@ -588,7 +588,7 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev, ...@@ -588,7 +588,7 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
struct scc_ports *ports = pci_get_drvdata(dev); struct scc_ports *ports = pci_get_drvdata(dev);
struct ide_host *host; struct ide_host *host;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
int i; int i, rc;
memset(&hw, 0, sizeof(hw)); memset(&hw, 0, sizeof(hw));
for (i = 0; i <= 8; i++) for (i = 0; i <= 8; i++)
...@@ -597,11 +597,9 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev, ...@@ -597,11 +597,9 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
hw.dev = &dev->dev; hw.dev = &dev->dev;
hw.chipset = ide_pci; hw.chipset = ide_pci;
host = ide_host_alloc(d, hws); rc = ide_host_add(d, hws, &host);
if (host == NULL) if (rc)
return -ENOMEM; return rc;
ide_host_register(host, d, hws);
ports->host = host; ports->host = host;
......
...@@ -1043,6 +1043,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw) ...@@ -1043,6 +1043,7 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
ide_hwif_t *hwif; ide_hwif_t *hwif;
hw_regs_t *hws[] = { hw, NULL, NULL, NULL }; hw_regs_t *hws[] = { hw, NULL, NULL, NULL };
struct ide_port_info d = pmac_port_info; struct ide_port_info d = pmac_port_info;
int rc;
pmif->broken_dma = pmif->broken_dma_warn = 0; pmif->broken_dma = pmif->broken_dma_warn = 0;
if (of_device_is_compatible(np, "shasta-ata")) { if (of_device_is_compatible(np, "shasta-ata")) {
...@@ -1118,11 +1119,9 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw) ...@@ -1118,11 +1119,9 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id, pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id,
pmif->mediabay ? " (mediabay)" : "", hw->irq); pmif->mediabay ? " (mediabay)" : "", hw->irq);
host = ide_host_alloc(&d, hws); rc = ide_host_add(&d, hws, &host);
if (host == NULL) if (rc)
return -ENOENT; return rc;
ide_host_register(host, &d, hws);
hwif = host->ports[0]; hwif = host->ports[0];
......
...@@ -541,7 +541,6 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ...@@ -541,7 +541,6 @@ static int do_ide_setup_pci_device(struct pci_dev *dev,
int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d)
{ {
struct ide_host *host;
hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
int ret; int ret;
...@@ -551,9 +550,7 @@ int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) ...@@ -551,9 +550,7 @@ int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d)
/* FIXME: silent failure can happen */ /* FIXME: silent failure can happen */
ide_pci_setup_ports(dev, d, ret, &hw[0], &hws[0]); ide_pci_setup_ports(dev, d, ret, &hw[0], &hws[0]);
host = ide_host_alloc(d, hws); ret = ide_host_add(d, hws, NULL);
if (host)
ide_host_register(host, d, hws);
} }
return ret; return ret;
...@@ -564,7 +561,6 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, ...@@ -564,7 +561,6 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
const struct ide_port_info *d) const struct ide_port_info *d)
{ {
struct pci_dev *pdev[] = { dev1, dev2 }; struct pci_dev *pdev[] = { dev1, dev2 };
struct ide_host *host;
int ret, i; int ret, i;
hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
...@@ -582,9 +578,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, ...@@ -582,9 +578,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
ide_pci_setup_ports(pdev[i], d, ret, &hw[i*2], &hws[i*2]); ide_pci_setup_ports(pdev[i], d, ret, &hw[i*2], &hws[i*2]);
} }
host = ide_host_alloc(d, hws); ret = ide_host_add(d, hws, NULL);
if (host)
ide_host_register(host, d, hws);
out: out:
return ret; return ret;
} }
......
...@@ -1238,6 +1238,8 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *, hw_regs_t **); ...@@ -1238,6 +1238,8 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *, hw_regs_t **);
struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **);
int ide_host_register(struct ide_host *, const struct ide_port_info *, int ide_host_register(struct ide_host *, const struct ide_port_info *,
hw_regs_t **); hw_regs_t **);
int ide_host_add(const struct ide_port_info *, hw_regs_t **,
struct ide_host **);
void ide_host_remove(struct ide_host *); void ide_host_remove(struct ide_host *);
int ide_legacy_device_add(const struct ide_port_info *, unsigned long); int ide_legacy_device_add(const struct ide_port_info *, unsigned long);
void ide_port_unregister_devices(ide_hwif_t *); void ide_port_unregister_devices(ide_hwif_t *);
......
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