LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
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 15/15] ide: move hwif_register() call out of ide_probe_port()
Date: Fri, 04 Jan 2008 22:26:21 +0100	[thread overview]
Message-ID: <20080104212621.6978.60873.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080104212424.6978.93646.sendpatchset@localhost.localdomain>

* Add BUG_ON(hwif->present) at the start of ide_probe_port().

* Move hwif_register() call (along with setting hwif->present) from
  ide_probe_port() to ide_device_add_all().

  As a result the port will be registered with the device tree _after_:
  - probing both devices (if both are present)
  - port reset (if hwif->reset is set)
  - restoring local IRQs state and re-enabling port IRQ

While at it:

* Rename hwif_register() to ide_register_port().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
+17 bytes
 drivers/ide/ide-probe.c |   27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -613,7 +613,7 @@ static void hwif_release_dev (struct dev
 	complete(&hwif->gendev_rel_comp);
 }
 
-static void hwif_register (ide_hwif_t *hwif)
+static void ide_register_port(ide_hwif_t *hwif)
 {
 	int ret;
 
@@ -742,7 +742,9 @@ static int ide_probe_port(ide_hwif_t *hw
 {
 	unsigned long flags;
 	unsigned int irqd;
-	int unit;
+	int unit, rc = -ENODEV;
+
+	BUG_ON(hwif->present);
 
 	if (hwif->noprobe)
 		return -EACCES;
@@ -767,14 +769,8 @@ static int ide_probe_port(ide_hwif_t *hw
 		ide_drive_t *drive = &hwif->drives[unit];
 		drive->dn = (hwif->channel ? 2 : 0) + unit;
 		(void) probe_for_drive(drive);
-		if (drive->present && !hwif->present) {
-			hwif->present = 1;
-			if (hwif->chipset != ide_4drives ||
-			    !hwif->mate || 
-			    !hwif->mate->present) {
-				hwif_register(hwif);
-			}
-		}
+		if (drive->present)
+			rc = 0;
 	}
 	if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) {
 		printk(KERN_WARNING "%s: reset\n", hwif->name);
@@ -791,10 +787,7 @@ static int ide_probe_port(ide_hwif_t *hw
 	if (irqd)
 		enable_irq(irqd);
 
-	if (!hwif->present)
-		return -ENODEV;
-
-	return 0;
+	return rc;
 }
 
 static void ide_port_tune_devices(ide_hwif_t *hwif)
@@ -1319,6 +1312,12 @@ int ide_device_add_all(u8 *idx)
 			continue;
 		}
 
+		hwif->present = 1;
+
+		if (hwif->chipset != ide_4drives || !hwif->mate ||
+		    !hwif->mate->present)
+			ide_register_port(hwif);
+
 		ide_port_tune_devices(hwif);
 	}
 

      parent reply	other threads:[~2008-01-04 21:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-04 21:24 [PATCH 0/15] ide: fixes/cleanups for IDE devices probing Bartlomiej Zolnierkiewicz
2008-01-04 21:24 ` [PATCH 1/15] ide: fix handling of busy I/O resources in probe_hwif() Bartlomiej Zolnierkiewicz
2008-01-04 21:24 ` [PATCH 2/15] ide: move wait_hwif_ready() documentation in the right place Bartlomiej Zolnierkiewicz
2008-01-09 17:47   ` Sergei Shtylyov
2008-01-09 17:53     ` Sergei Shtylyov
2008-01-04 21:24 ` [PATCH 3/15] ide: remove hwif->present manipulations from hwif_init() Bartlomiej Zolnierkiewicz
2008-01-04 21:24 ` [PATCH 4/15] ide_platform: remove struct hwif_prop Bartlomiej Zolnierkiewicz
2008-01-04 21:25 ` [PATCH 5/15] ide: remove unused ide_hwgroup_t fields Bartlomiej Zolnierkiewicz
2008-01-04 21:25 ` [PATCH 6/15] ide: remove needless zeroing of hwgroup fields from init_irq() Bartlomiej Zolnierkiewicz
2008-01-04 21:25 ` [PATCH 7/15] ide: cleanup ide_system_bus_speed() Bartlomiej Zolnierkiewicz
2008-01-04 21:25 ` [PATCH 8/15] ide: I/O resources are released too early in ide_unregister() Bartlomiej Zolnierkiewicz
2008-01-04 21:25 ` [PATCH 9/15] ide: factor out code removing port from hwgroup from ide_unregister() Bartlomiej Zolnierkiewicz
2008-01-04 21:25 ` [PATCH 10/15] ide: prepare init_irq() for using ide_remove_port_from_hwgroup() Bartlomiej Zolnierkiewicz
2008-01-04 21:25 ` [PATCH 11/15] ide: use ide_remove_port_from_hwgroup in init_irq() Bartlomiej Zolnierkiewicz
2008-01-04 21:25 ` [PATCH 12/15] ide: make probe_hwif() return an error value Bartlomiej Zolnierkiewicz
2008-01-04 21:26 ` [PATCH 13/15] ide: move handling of I/O resources out of ide_probe_port() Bartlomiej Zolnierkiewicz
2008-01-04 21:26 ` [PATCH 14/15] ide: factor out code for tuning devices from ide_probe_port() Bartlomiej Zolnierkiewicz
2008-01-04 21:26 ` Bartlomiej Zolnierkiewicz [this message]

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=20080104212621.6978.60873.sendpatchset@localhost.localdomain \
    --to=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 15/15] ide: move hwif_register() call out of ide_probe_port()' \
    /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

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).