From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-ide@vger.kernel.org
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/7] ide: fix ide_host_register() return value
Date: Sat, 28 Jun 2008 23:44:03 +0200 [thread overview]
Message-ID: <20080628214403.21345.90750.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080628214355.21345.94835.sendpatchset@localhost.localdomain>
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: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-probe.c | 38 ++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1580,19 +1580,16 @@ int ide_host_register(struct ide_host *h
hw_regs_t **hws)
{
ide_hwif_t *hwif, *mate = NULL;
- u8 idx[MAX_HWIFS];
- int i, rc = 0;
+ int i, j = 0;
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;
continue;
}
- hwif = &ide_hwifs[idx[i]];
-
ide_init_port_hw(hwif, hws[i]);
ide_port_apply_params(hwif);
@@ -1614,10 +1611,10 @@ int ide_host_register(struct ide_host *h
}
for (i = 0; i < MAX_HWIFS; i++) {
- if (idx[i] == 0xff)
- continue;
+ hwif = host->ports[i];
- hwif = &ide_hwifs[idx[i]];
+ if (hwif == NULL)
+ continue;
if (ide_probe_port(hwif) == 0)
hwif->present = 1;
@@ -1631,19 +1628,20 @@ int ide_host_register(struct ide_host *h
}
for (i = 0; i < MAX_HWIFS; i++) {
- if (idx[i] == 0xff)
- continue;
+ hwif = host->ports[i];
- hwif = &ide_hwifs[idx[i]];
+ if (hwif == NULL)
+ continue;
if (hwif_init(hwif) == 0) {
printk(KERN_INFO "%s: failed to initialize IDE "
"interface\n", hwif->name);
hwif->present = 0;
- rc = -1;
continue;
}
+ j++;
+
if (hwif->present)
ide_port_setup_devices(hwif);
@@ -1654,10 +1652,10 @@ int ide_host_register(struct ide_host *h
}
for (i = 0; i < MAX_HWIFS; i++) {
- if (idx[i] == 0xff)
- continue;
+ hwif = host->ports[i];
- hwif = &ide_hwifs[idx[i]];
+ if (hwif == NULL)
+ continue;
if (hwif->chipset == ide_unknown)
hwif->chipset = ide_generic;
@@ -1667,10 +1665,10 @@ int ide_host_register(struct ide_host *h
}
for (i = 0; i < MAX_HWIFS; i++) {
- if (idx[i] == 0xff)
- continue;
+ hwif = host->ports[i];
- hwif = &ide_hwifs[idx[i]];
+ if (hwif == NULL)
+ continue;
ide_sysfs_register_port(hwif);
ide_proc_register_port(hwif);
@@ -1679,7 +1677,7 @@ int ide_host_register(struct ide_host *h
ide_proc_port_register_devices(hwif);
}
- return rc;
+ return j ? 0 : -1;
}
EXPORT_SYMBOL_GPL(ide_host_register);
next prev parent reply other threads:[~2008-06-28 21:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-28 21:43 [PATCH 1/7] ide: add ide_host_add() helper Bartlomiej Zolnierkiewicz
2008-06-28 21:44 ` Bartlomiej Zolnierkiewicz [this message]
2008-06-28 21:44 ` [PATCH 3/7] ide: fix IDE port slots reservation and freeing Bartlomiej Zolnierkiewicz
2008-06-28 21:44 ` [PATCH 4/7] ide: move ide_remove_port_from_hwgroup() to ide-probe.c Bartlomiej Zolnierkiewicz
2008-06-28 21:44 ` [PATCH 5/7] ide: add ide_ports[] Bartlomiej Zolnierkiewicz
2008-06-28 21:44 ` [PATCH 6/7] ide: allocate ide_hwif_t instances dynamically Bartlomiej Zolnierkiewicz
2008-06-28 21:44 ` [PATCH 7/7] ide: add ide_host_free() helper Bartlomiej Zolnierkiewicz
2008-08-21 18:02 ` [PATCH 1/7] ide: add ide_host_add() helper Sergei Shtylyov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080628214403.21345.90750.sendpatchset@localhost.localdomain \
--to=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).