[PATCH 4/9] cmd640: use ide_find_port()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-ide@...>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@...>, <linux-kernel@...>
Date: Saturday, February 16, 2008 - 4:26 pm

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

Index: b/drivers/ide/pci/cmd640.c
===================================================================
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -744,20 +744,21 @@ static int __init cmd640x_init(void)
 	printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x"
 			 "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr);
 
-	cmd_hwif0 = &ide_hwifs[0];
-	cmd_hwif1 = &ide_hwifs[1];
+	cmd_hwif0 = ide_find_port();
 
 	/*
 	 * Initialize data for primary port
 	 */
-	oldnoprobe = cmd_hwif0->noprobe;
-	ide_init_port_hw(cmd_hwif0, &hw[0]);
-	cmd_hwif0->noprobe = oldnoprobe;
+	if (cmd_hwif0) {
+		oldnoprobe = cmd_hwif0->noprobe;
+		ide_init_port_hw(cmd_hwif0, &hw[0]);
+		cmd_hwif0->noprobe = oldnoprobe;
 #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
-	cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode;
+		cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode;
 #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
 
-	idx[0] = cmd_hwif0->index;
+		idx[0] = cmd_hwif0->index;
+	}
 
 	/*
 	 * Ensure compatibility by always using the slowest timings
@@ -772,7 +773,7 @@ static int __init cmd640x_init(void)
 	/*
 	 * Try to enable the secondary interface, if not already enabled
 	 */
-	if (cmd_hwif1->noprobe) {
+	if (cmd_hwif1 && cmd_hwif1->noprobe) {
 		port2 = "not probed";
 	} else {
 		b = get_cmd640_reg(CNTRL);
@@ -803,7 +804,7 @@ static int __init cmd640x_init(void)
 	/*
 	 * Initialize data for secondary cmd640 port, if enabled
 	 */
-	if (second_port_cmd640) {
+	if (second_port_cmd640 && cmd_hwif1) {
 		oldnoprobe = cmd_hwif1->noprobe;
 		ide_init_port_hw(cmd_hwif1, &hw[1]);
 		cmd_hwif1->noprobe = oldnoprobe;
@@ -813,7 +814,7 @@ static int __init cmd640x_init(void)
 
 		idx[1] = cmd_hwif1->index;
 	}
-	printk(KERN_INFO "%s: %sserialized, secondary interface %s\n", cmd_hwif1->name,
+	printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n",
 			 second_port_cmd640 ? "" : "not ", port2);
 
 	/*
@@ -823,10 +824,15 @@ static int __init cmd640x_init(void)
 	for (index = 0; index < (2 + (second_port_cmd640 << 1)); index++) {
 		ide_drive_t *drive;
 
-		if (index > 1)
+		if (index > 1) {
+			if (cmd_hwif1 == NULL)
+				continue;
 			drive = &cmd_hwif1->drives[index & 1];
-		else
+		} else  {
+			if (cmd_hwif0 == NULL)
+				continue;
 			drive = &cmd_hwif0->drives[index & 1];
+		}
 
 #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
 		if (drive->autotune || ((index > 1) && second_port_toggled)) {
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/9] sgiioc4: use ide_find_port(), Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 4:26 pm)
[PATCH 9/9] ide: IDE_HFLAG_BOOTABLE -&gt; IDE_HFLAG_NON_BOOTABLE, Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 4:27 pm)
[PATCH 8/9] qd65xx: return error value in qd_probe(), Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 4:27 pm)
Re: [PATCH 8/9] qd65xx: return error value in qd_probe(), Sergei Shtylyov, (Mon Feb 18, 1:00 pm)
[PATCH 7/9] ht6560b: use driver name for resource allocation, Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 4:27 pm)
[PATCH 6/9] umc8672: don't use ide_hwifs[] in umc_set_pio_mo..., Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 4:27 pm)
[PATCH 5/9] scc_pata: store 'hwif' pointer in struct scc_ports, Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 4:27 pm)
[PATCH 4/9] cmd640: use ide_find_port(), Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 4:26 pm)
[PATCH 3/9] cmd640: remove cmd_drives[], Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 4:26 pm)
[PATCH 2/9] au1xxx-ide: use ide_find_port(), Bartlomiej Zolnierkiewicz..., (Sat Feb 16, 4:26 pm)