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 08/22] ide: add ->init_port_devs method to ide_hwif_t
Date: Thu, 17 Jan 2008 00:27:02 +0100	[thread overview]
Message-ID: <20080116232702.9166.77564.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080116232556.9166.13457.sendpatchset@localhost.localdomain>

* Add ->init_port_devs method to ide_hwif_t for a host specific
  initialization of devices on a port.  Call the new method from
  ide_port_init_devices().

* Convert ht6560b, qd65xx and opti621 host drivers to use the new
  ->init_port_devs method.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-probe.c      |    3 ++
 drivers/ide/legacy/ht6560b.c |   26 +++++++++++++------------
 drivers/ide/legacy/qd65xx.c  |   44 ++++++++++++++++++++++++++++++++-----------
 drivers/ide/pci/opti621.c    |   10 ++++++---
 include/linux/ide.h          |    2 +
 5 files changed, 59 insertions(+), 26 deletions(-)

Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1305,6 +1305,9 @@ static void ide_port_init_devices(ide_hw
 		if ((hwif->host_flags & IDE_HFLAG_NO_AUTOTUNE) == 0)
 			drive->autotune = 1;
 	}
+
+	if (hwif->port_init_devs)
+		hwif->port_init_devs(hwif);
 }
 
 static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
Index: b/drivers/ide/legacy/ht6560b.c
===================================================================
--- a/drivers/ide/legacy/ht6560b.c
+++ b/drivers/ide/legacy/ht6560b.c
@@ -300,6 +300,18 @@ static void ht6560b_set_pio_mode(ide_dri
 #endif
 }
 
+static void __init ht6560b_port_init_devs(ide_hwif_t *hwif)
+{
+	/* Setting default configurations for drives. */
+	int t = (HT_CONFIG_DEFAULT << 8) | HT_TIMING_DEFAULT;
+
+	if (hwif->channel)
+		t |= (HT_SECONDARY_IF << 8);
+
+	hwif->drives[0].drive_data = t;
+	hwif->drives[1].drive_data = t;
+}
+
 int probe_ht6560b = 0;
 
 module_param_named(probe, probe_ht6560b, bool, 0);
@@ -318,7 +330,6 @@ static int __init ht6560b_init(void)
 {
 	ide_hwif_t *hwif, *mate;
 	static u8 idx[4] = { 0, 1, 0xff, 0xff };
-	int t;
 
 	if (probe_ht6560b == 0)
 		return -ENODEV;
@@ -343,17 +354,8 @@ static int __init ht6560b_init(void)
 	mate->selectproc = &ht6560b_selectproc;
 	mate->set_pio_mode = &ht6560b_set_pio_mode;
 
-	/*
-	 * Setting default configurations for drives
-	 */
-	t = (HT_CONFIG_DEFAULT << 8);
-	t |= HT_TIMING_DEFAULT;
-	hwif->drives[0].drive_data = t;
-	hwif->drives[1].drive_data = t;
-
-	t |= (HT_SECONDARY_IF << 8);
-	mate->drives[0].drive_data = t;
-	mate->drives[1].drive_data = t;
+	hwif->port_init_devs = ht6560b_port_init_devs;
+	mate->port_init_devs = ht6560b_port_init_devs;
 
 	ide_device_add(idx, &ht6560b_port_info);
 
Index: b/drivers/ide/legacy/qd65xx.c
===================================================================
--- a/drivers/ide/legacy/qd65xx.c
+++ b/drivers/ide/legacy/qd65xx.c
@@ -305,13 +305,33 @@ static int __init qd_testreg(int port)
  * called to setup an ata channel : adjusts attributes & links for tuning
  */
 
-static void __init qd_setup(ide_hwif_t *hwif, int base, int config,
-			    unsigned int data0, unsigned int data1)
+static void __init qd_setup(ide_hwif_t *hwif, int base, int config)
 {
 	hwif->select_data = base;
 	hwif->config_data = config;
-	hwif->drives[0].drive_data = data0;
-	hwif->drives[1].drive_data = data1;
+}
+
+static void __init qd6500_port_init_devs(ide_hwif_t *hwif)
+{
+	u8 base = hwif->select_data, config = QD_CONFIG(hwif);
+
+	hwif->drives[0].drive_data = QD6500_DEF_DATA;
+	hwif->drives[1].drive_data = QD6500_DEF_DATA;
+}
+
+static void __init qd6580_port_init_devs(ide_hwif_t *hwif)
+{
+	u16 t1, t2;
+	u8 base = hwif->select_data, config = QD_CONFIG(hwif);
+
+	if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) {
+		t1 = QD6580_DEF_DATA;
+		t2 = QD6580_DEF_DATA2;
+	} else
+		t2 = t1 = hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA;
+
+	hwif->drives[0].drive_data = t1;
+	hwif->drives[1].drive_data = t2;
 }
 
 /*
@@ -396,8 +416,9 @@ static int __init qd_probe(int base)
 			return 1;
 		}
 
-		qd_setup(hwif, base, config, QD6500_DEF_DATA, QD6500_DEF_DATA);
+		qd_setup(hwif, base, config);
 
+		hwif->port_init_devs = qd6500_port_init_devs;
 		hwif->set_pio_mode = &qd6500_set_pio_mode;
 
 		idx[unit] = unit;
@@ -429,9 +450,10 @@ static int __init qd_probe(int base)
 			hwif = &ide_hwifs[unit];
 			printk(KERN_INFO "%s: qd6580: single IDE board\n",
 					 hwif->name);
-			qd_setup(hwif, base, config | (control << 8),
-				 QD6580_DEF_DATA, QD6580_DEF_DATA2);
 
+			qd_setup(hwif, base, config | (control << 8));
+
+			hwif->port_init_devs = qd6580_port_init_devs;
 			hwif->set_pio_mode = &qd6580_set_pio_mode;
 
 			idx[unit] = unit;
@@ -450,14 +472,14 @@ static int __init qd_probe(int base)
 			printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n",
 					hwif->name, mate->name);
 
-			qd_setup(hwif, base, config | (control << 8),
-				 QD6580_DEF_DATA, QD6580_DEF_DATA);
+			qd_setup(hwif, base, config | (control << 8));
 
+			hwif->port_init_devs = qd6580_port_init_devs;
 			hwif->set_pio_mode = &qd6580_set_pio_mode;
 
-			qd_setup(mate, base, config | (control << 8),
-				 QD6580_DEF_DATA2, QD6580_DEF_DATA2);
+			qd_setup(mate, base, config | (control << 8));
 
+			mate->port_init_devs = qd6580_port_init_devs;
 			mate->set_pio_mode = &qd6580_set_pio_mode;
 
 			idx[0] = 0;
Index: b/drivers/ide/pci/opti621.c
===================================================================
--- a/drivers/ide/pci/opti621.c
+++ b/drivers/ide/pci/opti621.c
@@ -315,14 +315,18 @@ static void opti621_set_pio_mode(ide_dri
 	spin_unlock_irqrestore(&opti621_lock, flags);
 }
 
+static void __devinit opti621_port_init_devs(ide_hwif_t *hwif)
+{
+	hwif->drives[0].drive_data = PIO_DONT_KNOW;
+	hwif->drives[1].drive_data = PIO_DONT_KNOW;
+}
+
 /*
  * init_hwif_opti621() is called once for each hwif found at boot.
  */
 static void __devinit init_hwif_opti621 (ide_hwif_t *hwif)
 {
-	hwif->drives[0].drive_data = PIO_DONT_KNOW;
-	hwif->drives[1].drive_data = PIO_DONT_KNOW;
-
+	hwif->port_init_devs = opti621_port_init_devs;
 	hwif->set_pio_mode = &opti621_set_pio_mode;
 }
 
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -514,6 +514,8 @@ typedef struct hwif_s {
 #if 0
 	ide_hwif_ops_t	*hwifops;
 #else
+	/* host specific initialization of devices on a port */
+	void	(*port_init_devs)(struct hwif_s *);
 	/* routine to program host for PIO mode */
 	void	(*set_pio_mode)(ide_drive_t *, const u8);
 	/* routine to program host for DMA mode */

  parent reply	other threads:[~2008-01-16 23:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-16 23:25 [PATCH 00/22] ide: even more IDE probing code rework Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 01/22] ide: remove redundant hwif->present check from ide_register_hw() Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 02/22] ide: remove redundant init_hwif_default() call " Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 03/22] ide: add 'init_default' and 'restore' arguments to ide_unregister() Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 04/22] ide: add ide_deprecated_find_port() helper Bartlomiej Zolnierkiewicz
2008-05-21 14:29   ` Sergei Shtylyov
2008-05-27 18:36     ` Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 05/22] ide: fix ide_unregister() usage in host drivers Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 06/22] ide: factor out code initializing devices from ide_init_port() Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 07/22] ide: add IDE_HFLAG_NO_{IO32_BIT,UNMASK_IRQS} host flags Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` Bartlomiej Zolnierkiewicz [this message]
2008-01-16 23:27 ` [PATCH 09/22] ide: remove incorrect init_gendisk() comment Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 10/22] ide: skip not present devices in init_gendisk() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 11/22] ide: move blk_register_region() call out from init_gendisk() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 12/22] ide: call init_gendisk() after ide_acpi_init() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 13/22] ide: merge init_gendisk() into hwif_register_devices() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 14/22] ide: move hwif->rqsize init from ide_init_queue() to init_irq() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 15/22] ide: factor out adding drive to hwgroup from init_irq() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 16/22] ide: factor out devices setup " Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 17/22] ide: move ide_acpi_init() call to ide_device_add_all() Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 18/22] ide-acpi: remove needless exports Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 19/22] ide-acpi: remove dead code from do_drive_get_GTF() Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 20/22] ide: factor out devices setup from ide_acpi_init() Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 21/22] ide: move hwif->present check out from ide_proc_register_port() Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 22/22] ide: move create_proc_ide_drives() call to ide_device_add_all() 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=20080116232702.9166.77564.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).