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: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index 013697b..e6c6200 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -709,7 +709,6 @@
*/
static int __init cmd640x_init(void)
{
- struct ide_host *host;
int second_port_cmd640 = 0, rc;
const char *bus_type, *port2;
u8 b, cfr;
@@ -829,11 +828,7 @@
cmd640_dump_regs();
#endif
- host = ide_host_alloc(&cmd640_port_info, hws);
- if (host)
- ide_host_register(host, &cmd640_port_info, hws);
-
- return 1;
+ return ide_host_add(&cmd640_port_info, hws, NULL);
}
module_param_named(probe_vlb, cmd640_vlb, bool, 0);
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index b8ec06d..b03d8ae 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -114,7 +114,6 @@
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];
hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
@@ -140,11 +139,7 @@
ide_pci_setup_ports(dev, d, 14, &hw[0], &hws[0]);
- host = ide_host_alloc(d, hws);
- if (host)
- ide_host_register(host, d, hws);
-
- return 0;
+ return ide_host_add(d, hws, NULL);
}
static const struct pci_device_id cs5520_pci_tbl[] = {
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c
index 5eb9d93..f84bfb4 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -86,12 +86,10 @@
hw.dev = &dev->dev;
hw.chipset = ide_pci; /* this enables IRQ sharing */
- host = ide_host_alloc(&delkin_cb_port_info, hws);
- if (host == NULL)
+ rc = ide_host_add(&delkin_cb_port_info, hws, &host);
+ if (rc)
goto out_disable;
- ide_host_register(host, &delkin_cb_port_info, hws);
-
pci_set_drvdata(dev, host);
return 0;
@@ -99,7 +97,7 @@
out_disable:
pci_release_regions(dev);
pci_disable_device(dev);
- return -ENODEV;
+ return rc;
}
static void
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index d5e2ba6..94a7ab86 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -588,7 +588,7 @@
struct scc_ports *ports = pci_get_drvdata(dev);
struct ide_host *host;
hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
- int i;
+ int i, rc;
memset(&hw, 0, sizeof(hw));
for (i = 0; i <= 8; i++)
@@ -597,11 +597,9 @@
hw.dev = &dev->dev;
hw.chipset = ide_pci;
- host = ide_host_alloc(d, hws);
- if (host == NULL)
- return -ENOMEM;
-
- ide_host_register(host, d, hws);
+ rc = ide_host_add(d, hws, &host);
+ if (rc)
+ return rc;
ports->host = host;