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 05/16] ide-probe: remove needless Status register reads
Date: Tue, 22 Jan 2008 00:31:10 +0100	[thread overview]
Message-ID: <20080121233110.30311.7772.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080121233036.30311.76015.sendpatchset@localhost.localdomain>


* Cache value read from the Status register in 'stat' variable in do_probe()
  and enable_nest(), then remove remove needless Status register reads.

While at it:

* Add proper KERN_* levels to printk() calls.

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

Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -423,8 +423,9 @@ static int ide_busy_sleep(ide_hwif_t *hw
 
 static int do_probe (ide_drive_t *drive, u8 cmd)
 {
-	int rc;
 	ide_hwif_t *hwif = HWIF(drive);
+	int rc;
+	u8 stat;
 
 	if (drive->present) {
 		/* avoid waiting for inappropriate probes */
@@ -461,15 +462,17 @@ static int do_probe (ide_drive_t *drive,
 			/* failed: try again */
 			rc = try_to_identify(drive,cmd);
 		}
-		if (hwif->INB(IDE_STATUS_REG) == (BUSY_STAT|READY_STAT))
+
+		stat = hwif->INB(IDE_STATUS_REG);
+
+		if (stat == (BUSY_STAT | READY_STAT))
 			return 4;
 
 		if ((rc == 1 && cmd == WIN_PIDENTIFY) &&
 			((drive->autotune == IDE_TUNE_DEFAULT) ||
 			(drive->autotune == IDE_TUNE_AUTO))) {
-			printk("%s: no response (status = 0x%02x), "
-				"resetting drive\n", drive->name,
-				hwif->INB(IDE_STATUS_REG));
+			printk(KERN_ERR "%s: no response (status = 0x%02x), "
+					"resetting drive\n", drive->name, stat);
 			msleep(50);
 			hwif->OUTB(drive->select.all, IDE_SELECT_REG);
 			msleep(50);
@@ -477,11 +480,13 @@ static int do_probe (ide_drive_t *drive,
 			(void)ide_busy_sleep(hwif);
 			rc = try_to_identify(drive, cmd);
 		}
+
+		/* ensure drive IRQ is clear */
+		stat = hwif->INB(IDE_STATUS_REG);
+
 		if (rc == 1)
-			printk("%s: no response (status = 0x%02x)\n",
-				drive->name, hwif->INB(IDE_STATUS_REG));
-		/* ensure drive irq is clear */
-		(void) hwif->INB(IDE_STATUS_REG);
+			printk(KERN_ERR "%s: no response (status = 0x%02x)\n",
+					drive->name, stat);
 	} else {
 		/* not present or maybe ATAPI */
 		rc = 3;
@@ -502,6 +507,7 @@ static int do_probe (ide_drive_t *drive,
 static void enable_nest (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = HWIF(drive);
+	u8 stat;
 
 	printk("%s: enabling %s -- ", hwif->name, drive->id->model);
 	SELECT_DRIVE(drive);
@@ -515,11 +521,12 @@ static void enable_nest (ide_drive_t *dr
 
 	msleep(50);
 
-	if (!OK_STAT((hwif->INB(IDE_STATUS_REG)), 0, BAD_STAT)) {
-		printk("failed (status = 0x%02x)\n", hwif->INB(IDE_STATUS_REG));
-	} else {
-		printk("success\n");
-	}
+	stat = hwif->INB(IDE_STATUS_REG);
+
+	if (!OK_STAT(stat, 0, BAD_STAT))
+		printk(KERN_CONT "failed (status = 0x%02x)\n", stat);
+	else
+		printk(KERN_CONT "success\n");
 
 	/* if !(success||timed-out) */
 	if (do_probe(drive, WIN_IDENTIFY) >= 2) {

  parent reply	other threads:[~2008-01-21 23:19 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-21 23:30 [PATCH 00/16] ide: various fixes/cleanups Bartlomiej Zolnierkiewicz
2008-01-21 23:30 ` [PATCH 01/16] ide-tape: use ide_execute_command() Bartlomiej Zolnierkiewicz
2008-01-22 14:32   ` Sergei Shtylyov
2008-01-21 23:30 ` [PATCH 02/16] ide-scsi: " Bartlomiej Zolnierkiewicz
2008-01-22 14:32   ` Sergei Shtylyov
2008-01-21 23:30 ` [PATCH 03/16] trm290: " Bartlomiej Zolnierkiewicz
2008-01-22 14:32   ` Sergei Shtylyov
2008-01-21 23:31 ` [PATCH 04/16] ide-cris: " Bartlomiej Zolnierkiewicz
2008-01-22 14:34   ` Sergei Shtylyov
2008-01-21 23:31 ` Bartlomiej Zolnierkiewicz [this message]
2008-01-21 23:31 ` [PATCH 06/16] ide: remove unused ->auto_poll field from ide_hwif_t Bartlomiej Zolnierkiewicz
2008-01-22 14:04   ` Sergei Shtylyov
2008-01-21 23:31 ` [PATCH 07/16] ide: convert ->straight8 field in ide_hwif_t to bit flag Bartlomiej Zolnierkiewicz
2008-01-22 14:11   ` Sergei Shtylyov
2008-01-21 23:31 ` [PATCH 08/16] ide: remove ->nice0 and ->nice2 fields from ide_drive_t Bartlomiej Zolnierkiewicz
2008-01-22 14:10   ` Sergei Shtylyov
2008-01-21 23:31 ` [PATCH 09/16] ide: remove SATA_*_REG macros Bartlomiej Zolnierkiewicz
2008-01-21 23:31 ` [PATCH 10/16] ide: use __ide_set_handler() in ide_execute_command() Bartlomiej Zolnierkiewicz
2008-01-22 14:16   ` Sergei Shtylyov
2008-01-21 23:31 ` [PATCH 11/16] ide: unexport SELECT_DRIVE() Bartlomiej Zolnierkiewicz
2008-01-22 16:28   ` Sergei Shtylyov
2008-01-21 23:31 ` [PATCH 12/16] ide: remove set_transfer() Bartlomiej Zolnierkiewicz
2008-01-22 14:24   ` Sergei Shtylyov
2008-01-21 23:32 ` [PATCH 13/16] ide: remove ide_ata66_check() Bartlomiej Zolnierkiewicz
2008-01-22 16:31   ` Sergei Shtylyov
2008-01-21 23:32 ` [PATCH 14/16] ide: move drive->crc_count check out from check_dma_crc() Bartlomiej Zolnierkiewicz
2008-01-22 16:38   ` Sergei Shtylyov
2008-01-21 23:32 ` [PATCH 15/16] ide: remove ide_auto_reduce_xfer() Bartlomiej Zolnierkiewicz
2008-01-22 16:39   ` Sergei Shtylyov
2008-01-21 23:32 ` [PATCH 16/16] ide: move check_dma_crc() to ide-dma.c Bartlomiej Zolnierkiewicz

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