linux-ide.vger.kernel.org archive mirror
 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 03/14] cmd640: add ->init_dev method
Date: Tue, 10 Jun 2008 22:51:19 +0200	[thread overview]
Message-ID: <20080610205119.18469.44635.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080610205059.18469.44856.sendpatchset@localhost.localdomain>

Convert the driver to use ->init_dev method instead of open-coding devices
init in cmd640x_init().

While at it:

- fix printk()-s to use KERN_INFO level instead of the default KERN_ERR

- use DRV_NAME define in printk()-s

- set proper ->pio_mask also for CONFIG_BLK_DEV_CMD640_ENHANCED=n

There should be no functional changes caused by this patch
(except fixing printk()-s levels).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/pci/cmd640.c |   72 +++++++++++++++++++----------------------------
 1 file changed, 30 insertions(+), 42 deletions(-)

Index: b/drivers/ide/pci/cmd640.c
===================================================================
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -611,11 +611,40 @@ static void cmd640_set_pio_mode(ide_driv
 
 	display_clocks(index);
 }
+#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
+
+static void cmd640_init_dev(ide_drive_t *drive)
+{
+	unsigned int i = drive->hwif->channel * 2 + drive->select.b.unit;
+
+#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
+	/*
+	 * Reset timing to the slowest speed and turn off prefetch.
+	 * This way, the drive identify code has a better chance.
+	 */
+	setup_counts[i]    =  4;	/* max possible */
+	active_counts[i]   = 16;	/* max possible */
+	recovery_counts[i] = 16;	/* max possible */
+	program_drive_counts(drive, i);
+	set_prefetch_mode(drive, i, 0);
+	printk(KERN_INFO DRV_NAME ": drive%d timings/prefetch cleared\n", i);
+#else
+	/*
+	 * Set the drive unmask flags to match the prefetch setting.
+	 */
+	check_prefetch(drive, i);
+	printk(KERN_INFO DRV_NAME ": drive%d timings/prefetch(%s) preserved\n",
+				  i, drive->no_io_32bit ? "off" : "on");
+#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
+}
+
 
 static const struct ide_port_ops cmd640_port_ops = {
+	.init_dev		= cmd640_init_dev,
+#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
 	.set_pio_mode		= cmd640_set_pio_mode,
+#endif
 };
-#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
 
 static int pci_conf1(void)
 {
@@ -658,10 +687,8 @@ static const struct ide_port_info cmd640
 				  IDE_HFLAG_NO_DMA |
 				  IDE_HFLAG_ABUSE_PREFETCH |
 				  IDE_HFLAG_ABUSE_FAST_DEVSEL,
-#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
 	.port_ops		= &cmd640_port_ops,
 	.pio_mask		= ATA_PIO5,
-#endif
 };
 
 static int cmd640x_init_one(unsigned long base, unsigned long ctl)
@@ -689,7 +716,6 @@ static int __init cmd640x_init(void)
 {
 	int second_port_cmd640 = 0, rc;
 	const char *bus_type, *port2;
-	unsigned int index;
 	u8 b, cfr;
 	u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
 	hw_regs_t hw[2];
@@ -813,44 +839,6 @@ static int __init cmd640x_init(void)
 	printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n",
 			 second_port_cmd640 ? "" : "not ", port2);
 
-	/*
-	 * Establish initial timings/prefetch for all drives.
-	 * Do not unnecessarily disturb any prior BIOS setup of these.
-	 */
-	for (index = 0; index < (2 + (second_port_cmd640 << 1)); index++) {
-		ide_drive_t *drive;
-
-		if (index > 1) {
-			if (cmd_hwif1 == NULL)
-				continue;
-			drive = &cmd_hwif1->drives[index & 1];
-		} else  {
-			if (cmd_hwif0 == NULL)
-				continue;
-			drive = &cmd_hwif0->drives[index & 1];
-		}
-
-#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
-		/*
-		 * Reset timing to the slowest speed and turn off prefetch.
-		 * This way, the drive identify code has a better chance.
-		 */
-		setup_counts    [index] = 4;	/* max possible */
-		active_counts   [index] = 16;	/* max possible */
-		recovery_counts [index] = 16;	/* max possible */
-		program_drive_counts(drive, index);
-		set_prefetch_mode(drive, index, 0);
-		printk("cmd640: drive%d timings/prefetch cleared\n", index);
-#else
-		/*
-		 * Set the drive unmask flags to match the prefetch setting
-		 */
-		check_prefetch(drive, index);
-		printk("cmd640: drive%d timings/prefetch(%s) preserved\n",
-			index, drive->no_io_32bit ? "off" : "on");
-#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
-	}
-
 #ifdef CMD640_DUMP_REGS
 	cmd640_dump_regs();
 #endif

  parent reply	other threads:[~2008-06-10 20:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-10 20:50 [PATCH 01/14] cmd640: fix warm-plug support for the secondary interface Bartlomiej Zolnierkiewicz
2008-06-10 20:51 ` [PATCH 02/14] ide: ->port_init_devs -> ->init_dev Bartlomiej Zolnierkiewicz
2008-06-10 20:51 ` Bartlomiej Zolnierkiewicz [this message]
2008-06-10 20:51 ` [PATCH 04/14] rapide: use struct ide_port_info Bartlomiej Zolnierkiewicz
2008-06-10 20:51 ` [PATCH 05/14] ide-h8300: " Bartlomiej Zolnierkiewicz
2008-06-10 20:51 ` [PATCH 06/14] ide_platform: " Bartlomiej Zolnierkiewicz
2008-06-10 20:51 ` [PATCH 07/14] ide: print message on error in ide_find_port_slot() Bartlomiej Zolnierkiewicz
2008-06-10 20:52 ` [PATCH 08/14] ide-h8300: print driver banner message early Bartlomiej Zolnierkiewicz
2008-06-10 20:52 ` [PATCH 09/14] ide-pnp: " Bartlomiej Zolnierkiewicz
2008-06-10 20:52 ` [PATCH 10/14] ide: allow any command requesting DMA data phase for HDIO_DRIVE_TASKFILE Bartlomiej Zolnierkiewicz
2008-06-10 20:52 ` [PATCH 11/14] ide: remove superfluous BUG_ON() from set_geometry_intr() Bartlomiej Zolnierkiewicz
2008-06-10 20:52 ` [PATCH 12/14] ide: remove needless includes from ide.c Bartlomiej Zolnierkiewicz
2008-06-10 20:52 ` [PATCH 13/14] ide: remove needless includes from ide-taskfile.c Bartlomiej Zolnierkiewicz
2008-06-10 20:53 ` [PATCH 14/14] ide: remove needless includes from setup-pci.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=20080610205119.18469.44635.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).