ide: fix ide_host_register() return value

Fix ide_host_register() to fail only if all ports cannot be registered.

While at it:

* Use host->ports[] instead of ide_hwifs[] and remove idx[].

There should be no functional changes caused by this patch.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 6f904d01
...@@ -1574,19 +1574,16 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1574,19 +1574,16 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
hw_regs_t **hws) hw_regs_t **hws)
{ {
ide_hwif_t *hwif, *mate = NULL; ide_hwif_t *hwif, *mate = NULL;
u8 idx[MAX_HWIFS]; int i, j = 0;
int i, rc = 0;
for (i = 0; i < MAX_HWIFS; i++) { for (i = 0; i < MAX_HWIFS; i++) {
idx[i] = host->ports[i] ? host->ports[i]->index : 0xff; hwif = host->ports[i];
if (idx[i] == 0xff) { if (hwif == NULL) {
mate = NULL; mate = NULL;
continue; continue;
} }
hwif = &ide_hwifs[idx[i]];
ide_init_port_hw(hwif, hws[i]); ide_init_port_hw(hwif, hws[i]);
ide_port_apply_params(hwif); ide_port_apply_params(hwif);
...@@ -1608,10 +1605,10 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1608,10 +1605,10 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
} }
for (i = 0; i < MAX_HWIFS; i++) { for (i = 0; i < MAX_HWIFS; i++) {
if (idx[i] == 0xff) hwif = host->ports[i];
continue;
hwif = &ide_hwifs[idx[i]]; if (hwif == NULL)
continue;
if (ide_probe_port(hwif) == 0) if (ide_probe_port(hwif) == 0)
hwif->present = 1; hwif->present = 1;
...@@ -1625,19 +1622,20 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1625,19 +1622,20 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
} }
for (i = 0; i < MAX_HWIFS; i++) { for (i = 0; i < MAX_HWIFS; i++) {
if (idx[i] == 0xff) hwif = host->ports[i];
continue;
hwif = &ide_hwifs[idx[i]]; if (hwif == NULL)
continue;
if (hwif_init(hwif) == 0) { if (hwif_init(hwif) == 0) {
printk(KERN_INFO "%s: failed to initialize IDE " printk(KERN_INFO "%s: failed to initialize IDE "
"interface\n", hwif->name); "interface\n", hwif->name);
hwif->present = 0; hwif->present = 0;
rc = -1;
continue; continue;
} }
j++;
if (hwif->present) if (hwif->present)
ide_port_setup_devices(hwif); ide_port_setup_devices(hwif);
...@@ -1648,10 +1646,10 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1648,10 +1646,10 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
} }
for (i = 0; i < MAX_HWIFS; i++) { for (i = 0; i < MAX_HWIFS; i++) {
if (idx[i] == 0xff) hwif = host->ports[i];
continue;
hwif = &ide_hwifs[idx[i]]; if (hwif == NULL)
continue;
if (hwif->chipset == ide_unknown) if (hwif->chipset == ide_unknown)
hwif->chipset = ide_generic; hwif->chipset = ide_generic;
...@@ -1661,10 +1659,10 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1661,10 +1659,10 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
} }
for (i = 0; i < MAX_HWIFS; i++) { for (i = 0; i < MAX_HWIFS; i++) {
if (idx[i] == 0xff) hwif = host->ports[i];
continue;
hwif = &ide_hwifs[idx[i]]; if (hwif == NULL)
continue;
ide_sysfs_register_port(hwif); ide_sysfs_register_port(hwif);
ide_proc_register_port(hwif); ide_proc_register_port(hwif);
...@@ -1673,7 +1671,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1673,7 +1671,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
ide_proc_port_register_devices(hwif); ide_proc_port_register_devices(hwif);
} }
return rc; return j ? 0 : -1;
} }
EXPORT_SYMBOL_GPL(ide_host_register); EXPORT_SYMBOL_GPL(ide_host_register);
......
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