Skip to contentSkip to conversation

PATCH: 2.6.10 - Incorrect return from PCI ide controller

PATCH In review Alan Cox 3 participants 11 messages Dec 27, 2004 – Dec 30, 2004

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

Several IDE drivers return positive values as errors in the PCI setup code. Unfortunately the PCI layer considers positive values as success so the driver skips the device but still claims it and things then go downhill.

This fixes the IT8172 driver. There are other drivers with this bug (eg generic) but the -ac IDE is sufficiently diverged from base that someone else needs to generate/test the more divergent cases.

Alan

drivers/ide/pci/it8172.c +1 -1
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.10/drivers/ide/pci/it8172.c linux-2.6.10/drivers/ide/pci/it8172.c
@@ -270,7 +270,7 @@
 {
         if ((!(PCI_FUNC(dev->devfn) & 1) ||
             (!((dev->class >> 8) == PCI_CLASS_STORAGE_IDE))))
-                return 1; /* IT8172 is more than only a IDE controller */
+                return -EAGAIN; /* IT8172 is more than an IDE controller */
 	ide_setup_pci_device(dev, &it8172_chipsets[id->driver_data]);
 	return 0;
 }
#1 lore raw

Alan Cox <[email protected]> :

Quoted 8 lines

Several IDE drivers return positive values as errors in the PCI setup code. Unfortunately the PCI layer considers positive values as success so the driver skips the device but still claims it and things then go downhill.

This fixes the IT8172 driver. There are other drivers with this bug (eg generic) but the -ac IDE is sufficiently diverged from base that someone else needs to generate/test the more divergent cases.

ide_setup_pci_device{s} will always claim that everything is fine even though do_ide_setup_pci_device() has some opportunity to fail.

Should it matter as well ?

--
Ueimor

#2 lore raw
Quoted 6 lines · Francois Romieu

Alan Cox <[email protected]> :

Quoted 5 lines

Several IDE drivers return positive values as errors in the PCI setup code. Unfortunately the PCI layer considers positive values as success so the driver skips the device but still claims it and things then go downhill.

Quoted 8 lines
Quoted 3 lines

This fixes the IT8172 driver. There are other drivers with this bug (eg generic) but the -ac IDE is sufficiently diverged from base that someone else needs to generate/test the more divergent cases.

ide_setup_pci_device{s} will always claim that everything is fine even though do_ide_setup_pci_device() has some opportunity to fail.

Should it matter as well ?

Yes. Patches welcomed.

#4 lore raw

PATCH 1/5 pci-ide: propagation of error code in ide setup

In reply to Bartlomiej Zolnierkiewicz

Propagation of error code in ide setup

- Change the return value and the prototype of do_ide_setup_pci_device Due to lack of appropriate return status code, the current clients of do_ide_setup_pci_device() can not distinguish a failing invocation from a successfull one. The patch modify do_ide_setup_pci_device() so that it can propagate some of the errors from the lower layers.

- Make ide_setup_pci_device() aware of the change and propagate the news itself. I only gave a quick sight to create_proc_ide_interfaces() (and ide_remove_proc_entries()) but they do seem sane and it should not matter if it fails or not.

- ide_setup_pci_devices(): mostly the same thing than ide_setup_pci_device(). do not look trivially suspect.

drivers/ide/setup-pci.c renamed from drivers/ide/setup-pci.c~ata-010 +57 -30
diff -puN drivers/ide/setup-pci.c~ata-010 drivers/ide/setup-pci.c
@@ -643,14 +643,16 @@ EXPORT_SYMBOL_GPL(ide_pci_setup_ports);
  * we "know" about, this information is in the ide_pci_device_t struct;
  * for all other chipsets, we just assume both interfaces are enabled.
  */
-static ata_index_t do_ide_setup_pci_device (struct pci_dev *dev, ide_pci_device_t *d, u8 noisy)
+static int do_ide_setup_pci_device (struct pci_dev *dev, ide_pci_device_t *d,
+				    ata_index_t *index, u8 noisy)
 {
-	int pciirq = 0;
+	static ata_index_t ata_index = { .b = { .low = 0xff, .high = 0xff } };
 	int tried_config = 0;
-	ata_index_t index = { .b = { .low = 0xff, .high = 0xff } };
-
-	if (ide_setup_pci_controller(dev, d, noisy, &tried_config) < 0)
-		return index;
+	int pciirq, ret;
+	
+	ret = ide_setup_pci_controller(dev, d, noisy, &tried_config);
+	if (ret < 0)
+		goto out;
 
 	/*
 	 * Can we trust the reported IRQ?
@@ -668,7 +670,10 @@ static ata_index_t do_ide_setup_pci_devi
 		 * space, place chipset into init-mode, and/or preserve
 		 * an interrupt if the card is not native ide support.
 		 */
-		pciirq = (d->init_chipset) ? d->init_chipset(dev, d->name) : 0;
+		ret = d->init_chipset ? d->init_chipset(dev, d->name) : 0;
+		if (ret < 0)
+			goto out;
+		pciirq = ret;
 	} else if (tried_config) {
 		if (noisy)
 			printk(KERN_INFO "%s: will probe irqs later\n", d->name);
@@ -679,10 +684,10 @@ static ata_index_t do_ide_setup_pci_devi
 				d->name, pciirq);
 		pciirq = 0;
 	} else {
-		if (d->init_chipset)
-		{
-			if(d->init_chipset(dev, d->name) < 0)
-				return index;
+		if (d->init_chipset) {
+			ret = d->init_chipset(dev, d->name);
+			if (ret < 0)
+				goto out;
 		}
 		if (noisy)
 #ifdef __sparc__
@@ -694,17 +699,22 @@ static ata_index_t do_ide_setup_pci_devi
 #endif
 	}
 	
-	if(pciirq < 0)		/* Error not an IRQ */
-		return index;
-
-	ide_pci_setup_ports(dev, d, pciirq, &index);
-
-	return index;
+	/* FIXME: silent failure can happen */
+	
+	*index = ata_index;
+	ide_pci_setup_ports(dev, d, pciirq, index);
+out:
+	return ret;
 }
 
-void ide_setup_pci_device (struct pci_dev *dev, ide_pci_device_t *d)
+int ide_setup_pci_device (struct pci_dev *dev, ide_pci_device_t *d)
 {
-	ata_index_t index_list = do_ide_setup_pci_device(dev, d, 1);
+	ata_index_t index_list;
+	int ret;
+
+	ret = do_ide_setup_pci_device(dev, d, &index_list, 1);
+	if (ret < 0)
+		goto out;
 
 	if ((index_list.b.low & 0xf0) != 0xf0)
 		probe_hwif_init_with_fixup(&ide_hwifs[index_list.b.low], d->fixup);
@@ -712,25 +722,42 @@ void ide_setup_pci_device (struct pci_de
 		probe_hwif_init_with_fixup(&ide_hwifs[index_list.b.high], d->fixup);
 
 	create_proc_ide_interfaces();
+out:
+	return ret;
 }
 
 EXPORT_SYMBOL_GPL(ide_setup_pci_device);
 
-void ide_setup_pci_devices (struct pci_dev *dev, struct pci_dev *dev2, ide_pci_device_t *d)
+int ide_setup_pci_devices (struct pci_dev *dev1, struct pci_dev *dev2,
+			   ide_pci_device_t *d)
 {
-	ata_index_t index_list  = do_ide_setup_pci_device(dev, d, 1);
-	ata_index_t index_list2 = do_ide_setup_pci_device(dev2, d, 0);
+	struct pci_dev *pdev[] = { dev1, dev2 };
+	ata_index_t index_list[2];
+	int ret, i;
 
-	if ((index_list.b.low & 0xf0) != 0xf0)
-		probe_hwif_init(&ide_hwifs[index_list.b.low]);
-	if ((index_list.b.high & 0xf0) != 0xf0)
-		probe_hwif_init(&ide_hwifs[index_list.b.high]);
-	if ((index_list2.b.low & 0xf0) != 0xf0)
-		probe_hwif_init(&ide_hwifs[index_list2.b.low]);
-	if ((index_list2.b.high & 0xf0) != 0xf0)
-		probe_hwif_init(&ide_hwifs[index_list2.b.high]);
+	for (i = 0; i < 2; i++) {
+		ret = do_ide_setup_pci_device(pdev[i], d, index_list + i, !i);
+		/*
+		 * FIXME: Mom, mom, they stole me the helper function to undo
+		 * do_ide_setup_pci_device() on the first device !
+		 */
+		if (ret < 0)
+			goto out;
+	}
+
+	for (i = 0; i < 2; i++) {
+		u8 idx[2] = { index_list[i].b.low, index_list[i].b.high };
+		int j;
+
+		for (j = 0; j < 2; j++) {
+			if ((idx[j] & 0xf0) != 0xf0)
+				probe_hwif_init(ide_hwifs + idx[j]);
+		}
+	}
 
 	create_proc_ide_interfaces();
+out:
+	return ret;
 }
 
 EXPORT_SYMBOL_GPL(ide_setup_pci_devices);
include/linux/ide.h renamed from include/linux/ide.h~ata-010 +2 -2
diff -puN include/linux/ide.h~ata-010 include/linux/ide.h
@@ -1438,8 +1438,8 @@ typedef struct ide_pci_device_s {
 	u8			flags;
 } ide_pci_device_t;
 
-extern void ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
-extern void ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, ide_pci_device_t *);
+extern int ide_setup_pci_device(struct pci_dev *, ide_pci_device_t *);
+extern int ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, ide_pci_device_t *);
 
 void ide_map_sg(ide_drive_t *, struct request *);
 void ide_init_sg_cmd(ide_drive_t *, struct request *);

_

#5 lore raw

PATCH 2/5 pci-ide: clean up error path in do_ide_setup_pci_device

Clean up error path in do_ide_setup_pci_device.

ide_setup_pci_controller() puts the device in a PCI enabled state. The patch adds a small helper to balance it when things go wrong.

Actually the helper does not *exactly* balance the setup: if it can not do a better job, ide_setup_pci_controller() may only enable some BARS whereas the new counterpart will try to disable everything.

drivers/ide/setup-pci.c renamed from drivers/ide/setup-pci.c~ata-020 +13 -2
diff -puN drivers/ide/setup-pci.c~ata-020 drivers/ide/setup-pci.c
@@ -542,6 +542,13 @@ static int ide_setup_pci_controller(stru
 	return 0;
 }
 
+static void ide_release_pci_controller(struct pci_dev *dev, ide_pci_device_t *d,
+				       int noisy)
+{
+	/* Balance ide_pci_enable() */
+	pci_disable_device(dev);
+}
+
 /**
  *	ide_pci_setup_ports	-	configure ports/devices on PCI IDE
  *	@dev: PCI device
@@ -672,7 +679,7 @@ static int do_ide_setup_pci_device (stru
 		 */
 		ret = d->init_chipset ? d->init_chipset(dev, d->name) : 0;
 		if (ret < 0)
-			goto out;
+			goto err_release_pci_controller;
 		pciirq = ret;
 	} else if (tried_config) {
 		if (noisy)
@@ -687,7 +694,7 @@ static int do_ide_setup_pci_device (stru
 		if (d->init_chipset) {
 			ret = d->init_chipset(dev, d->name);
 			if (ret < 0)
-				goto out;
+				goto err_release_pci_controller;
 		}
 		if (noisy)
 #ifdef __sparc__
@@ -705,6 +712,10 @@ static int do_ide_setup_pci_device (stru
 	ide_pci_setup_ports(dev, d, pciirq, index);
 out:
 	return ret;
+
+err_release_pci_controller:
+	ide_release_pci_controller(dev, d, noisy);
+	goto out;
 }
 
 int ide_setup_pci_device (struct pci_dev *dev, ide_pci_device_t *d)

_

#6 lore raw

PATCH 3/5 pci-ide: propagate the error status in ide_pci_enable/ide_setup_pci_controller

- no need to overwrite the status code returned by the pci_xyz() functions;
- jump into the new century and use DMA_32BIT_MASK;
- misc cleanup in the error paths. It should not add a huge value in ide_pci_enable due to the FIXME comment but it should not bite too hard either.

drivers/ide/setup-pci.c renamed from drivers/ide/setup-pci.c~ata-030 +34 -18
diff -puN drivers/ide/setup-pci.c~ata-030 drivers/ide/setup-pci.c
@@ -290,14 +290,16 @@ EXPORT_SYMBOL_GPL(ide_setup_pci_noise);
  
 static int ide_pci_enable(struct pci_dev *dev, ide_pci_device_t *d)
 {
+	int ret;
 	
 	if (pci_enable_device(dev)) {
-		if (pci_enable_device_bars(dev, 1 << 4)) {
+		ret = pci_enable_device_bars(dev, 1 << 4);
+		if (ret < 0) {
 			printk(KERN_WARNING "%s: (ide_setup_pci_device:) "
 				"Could not enable device.\n", d->name);
-			return -EBUSY;
-		} else
-			printk(KERN_WARNING "%s: BIOS configuration fixed.\n", d->name);
+			goto out;
+		}
+		printk(KERN_WARNING "%s: BIOS configuration fixed.\n", d->name);
 	}
 
 	/*
@@ -305,18 +307,23 @@ static int ide_pci_enable(struct pci_dev
 	 * dma mask field to the ide_pci_device_t if we need it (or let
 	 * lower level driver set the dma mask)
 	 */
-	if (pci_set_dma_mask(dev, 0xffffffff)) {
+	ret = pci_set_dma_mask(dev, DMA_32BIT_MASK);
+	if (ret < 0) {
 		printk(KERN_ERR "%s: can't set dma mask\n", d->name);
-		return -EBUSY;
+		pci_disable_device(dev);
+		goto out;
 	}
 	 
 	/* FIXME: Temporary - until we put in the hotplug interface logic
-	   Check that the bits we want are not in use by someone else */
-	if (pci_request_region(dev, 4, "ide_tmp"))
-		return -EBUSY;
+	   Check that the bits we want are not in use by someone else.
+	   As someone else uses it, we do not (yuck) disable the device */
+	ret = pci_request_region(dev, 4, "ide_tmp");
+	if (ret < 0)
+		goto out;
+
 	pci_release_region(dev, 4);
-	
-	return 0;	
+out:	
+	return ret;
 }
 
 /**
@@ -516,21 +523,25 @@ static void ide_hwif_setup_dma(struct pc
 static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, int noisy, int *config)
 {
 	u32 class_rev;
+	int ret;
 	u16 pcicmd;
 
 	if (noisy)
 		ide_setup_pci_noise(dev, d);
 
-	if (ide_pci_enable(dev, d))
-		return -EBUSY;
+	ret = ide_pci_enable(dev, d);
+	if (ret < 0)
+		goto out;
 		
-	if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd)) {
+	ret = pci_read_config_word(dev, PCI_COMMAND, &pcicmd);
+	if (ret < 0) {
 		printk(KERN_ERR "%s: error accessing PCI regs\n", d->name);
-		return -EIO;
+		goto err_disable;
 	}
 	if (!(pcicmd & PCI_COMMAND_IO)) {	/* is device disabled? */
-		if (ide_pci_configure(dev, d))
-			return -ENODEV;
+		ret = ide_pci_configure(dev, d);
+		if (ret < 0)
+			goto err_disable;
 		*config = 1;
 		printk(KERN_INFO "%s: device enabled (Linux)\n", d->name);
 	}
@@ -539,7 +550,12 @@ static int ide_setup_pci_controller(stru
 	class_rev &= 0xff;
 	if (noisy)
 		printk(KERN_INFO "%s: chipset revision %d\n", d->name, class_rev);
-	return 0;
+out:
+	return ret;
+
+err_disable:
+	pci_disable_device(dev);
+	goto out;
 }
 
 static void ide_release_pci_controller(struct pci_dev *dev, ide_pci_device_t *d,

_

#7 lore raw

PATCH 4/5 pci-ide: fix the incorrect returns for the generic driver

This patch updates ide/pci/generic.c to fix the incorrect returns causing PCI devices to be left reserved wrongly by the driver. It doesn't contain the other -ac improvements for pci/generic just these fixes.

drivers/ide/pci/generic.c renamed from drivers/ide/pci/generic.c~ata-035 +3 -3
diff -puN drivers/ide/pci/generic.c~ata-035 drivers/ide/pci/generic.c
@@ -100,18 +100,18 @@ static int __devinit generic_init_one(st
 	if (dev->vendor == PCI_VENDOR_ID_UMC &&
 	    dev->device == PCI_DEVICE_ID_UMC_UM8886A &&
 	    (!(PCI_FUNC(dev->devfn) & 1)))
-		return 1; /* UM8886A/BF pair */
+		return -ENODEV; /* UM8886A/BF pair */
 
 	if (dev->vendor == PCI_VENDOR_ID_OPTI &&
 	    dev->device == PCI_DEVICE_ID_OPTI_82C558 &&
 	    (!(PCI_FUNC(dev->devfn) & 1)))
-		return 1;
+		return -EAGAIN;
 
 	pci_read_config_word(dev, PCI_COMMAND, &command);
 	if(!(command & PCI_COMMAND_IO))
 	{
 		printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name);
-		return 1; 
+		return -EAGAIN; 
 	}
 	ide_setup_pci_device(dev, d);
 	return 0;

_

#8 lore raw

PATCH 5/5 pci-ide: make device drivers code aware of the changes made to ide_setup_pci_device{s}

- nothing clever here: the most noticeable change is the change of returned value for (*init_setup) in struct ide_pci_device_s which goes from void to int. Anything else is editing and checking for errors in the output of the compiler;
- pci_disable_device() added for the error path in pci_init_sgiioc4();
- BUG() removed in amd74xx_probe(): good old printk() is enough.

drivers/ide/pci/aec62xx.c renamed from drivers/ide/pci/aec62xx.c~ata-040 +5 -6
diff -puN drivers/ide/pci/aec62xx.c~ata-040 drivers/ide/pci/aec62xx.c
@@ -321,12 +321,12 @@ static void __devinit init_dma_aec62xx(i
 	ide_setup_dma(hwif, dmabase, 8);
 }
 
-static void __devinit init_setup_aec62xx(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_aec62xx(struct pci_dev *dev, ide_pci_device_t *d)
 {
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
-static void __devinit init_setup_aec6x80(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_aec6x80(struct pci_dev *dev, ide_pci_device_t *d)
 {
 	unsigned long bar4reg = pci_resource_start(dev, 4);
 
@@ -340,7 +340,7 @@ static void __devinit init_setup_aec6x80
 			strcpy(d->name, "AEC6280R");
 	}
 
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
 /**
@@ -356,8 +356,7 @@ static int __devinit aec62xx_init_one(st
 {
 	ide_pci_device_t *d = &aec62xx_chipsets[id->driver_data];
 
-	d->init_setup(dev, d);
-	return 0;
+	return d->init_setup(dev, d);
 }
 
 static struct pci_device_id aec62xx_pci_tbl[] = {
drivers/ide/pci/alim15x3.c renamed from drivers/ide/pci/alim15x3.c~ata-040 +1 -2
diff -puN drivers/ide/pci/alim15x3.c~ata-040 drivers/ide/pci/alim15x3.c
@@ -884,8 +884,7 @@ static int __devinit alim15x3_init_one(s
 #if defined(CONFIG_SPARC64)
 	d->init_hwif = init_hwif_common_ali15x3;
 #endif /* CONFIG_SPARC64 */
-	ide_setup_pci_device(dev, d);
-	return 0;
+	return ide_setup_pci_device(dev, d);
 }
 
 
drivers/ide/pci/amd74xx.c renamed from drivers/ide/pci/amd74xx.c~ata-040 +6 -3
diff -puN drivers/ide/pci/amd74xx.c~ata-040 drivers/ide/pci/amd74xx.c
@@ -493,9 +493,12 @@ static int __devinit amd74xx_probe(struc
 {
 	amd_chipset = amd74xx_chipsets + id->driver_data;
 	amd_config = amd_ide_chips + id->driver_data;
-	if (dev->device != amd_config->id) BUG();
-	ide_setup_pci_device(dev, amd_chipset);
-	return 0;
+	if (dev->device != amd_config->id) {
+		printk(KERN_ERR "%s: assertion 0x%02x == 0x%02x failed !\n",
+		       pci_name(dev), dev->device, amd_config->id);
+		return -ENODEV;
+	}
+	return ide_setup_pci_device(dev, amd_chipset);
 }
 
 static struct pci_device_id amd74xx_pci_tbl[] = {
drivers/ide/pci/atiixp.c renamed from drivers/ide/pci/atiixp.c~ata-040 +1 -2
diff -puN drivers/ide/pci/atiixp.c~ata-040 drivers/ide/pci/atiixp.c
@@ -341,8 +341,7 @@ static ide_pci_device_t atiixp_pci_info[
 
 static int __devinit atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &atiixp_pci_info[id->driver_data]);
-	return 0;
+	return ide_setup_pci_device(dev, &atiixp_pci_info[id->driver_data]);
 }
 
 static struct pci_device_id atiixp_pci_tbl[] = {
drivers/ide/pci/cmd64x.c renamed from drivers/ide/pci/cmd64x.c~ata-040 +1 -2
diff -puN drivers/ide/pci/cmd64x.c~ata-040 drivers/ide/pci/cmd64x.c
@@ -709,8 +709,7 @@ static void __devinit init_hwif_cmd64x(i
 
 static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &cmd64x_chipsets[id->driver_data]);
-	return 0;
+	return ide_setup_pci_device(dev, &cmd64x_chipsets[id->driver_data]);
 }
 
 static struct pci_device_id cmd64x_pci_tbl[] = {
drivers/ide/pci/cs5530.c renamed from drivers/ide/pci/cs5530.c~ata-040 +1 -2
diff -puN drivers/ide/pci/cs5530.c~ata-040 drivers/ide/pci/cs5530.c
@@ -357,8 +357,7 @@ static ide_pci_device_t cs5530_chipset _
 
 static int __devinit cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &cs5530_chipset);
-	return 0;
+	return ide_setup_pci_device(dev, &cs5530_chipset);
 }
 
 static struct pci_device_id cs5530_pci_tbl[] = {
drivers/ide/pci/cy82c693.c renamed from drivers/ide/pci/cy82c693.c~ata-040 +3 -2
diff -puN drivers/ide/pci/cy82c693.c~ata-040 drivers/ide/pci/cy82c693.c
@@ -426,15 +426,16 @@ static int __devinit cy82c693_init_one(s
 {
 	ide_pci_device_t *d = &cy82c693_chipsets[id->driver_data];
 	struct pci_dev *dev2;
+	int ret = -ENODEV;
 
 	/* CY82C693 is more than only a IDE controller.
 	   Function 1 is primary IDE channel, function 2 - secondary. */
         if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE &&
 	    PCI_FUNC(dev->devfn) == 1) {
 		dev2 = pci_find_slot(dev->bus->number, dev->devfn + 1);
-		ide_setup_pci_devices(dev, dev2, d);
+		ret = ide_setup_pci_devices(dev, dev2, d);
 	}
-	return 0;
+	return ret;
 }
 
 static struct pci_device_id cy82c693_pci_tbl[] = {
drivers/ide/pci/generic.c renamed from drivers/ide/pci/generic.c~ata-040 +9 -7
diff -puN drivers/ide/pci/generic.c~ata-040 drivers/ide/pci/generic.c
@@ -96,25 +96,27 @@ static int __devinit generic_init_one(st
 {
 	ide_pci_device_t *d = &generic_chipsets[id->driver_data];
 	u16 command;
+	int ret = -ENODEV;
 
 	if (dev->vendor == PCI_VENDOR_ID_UMC &&
 	    dev->device == PCI_DEVICE_ID_UMC_UM8886A &&
 	    (!(PCI_FUNC(dev->devfn) & 1)))
-		return -ENODEV; /* UM8886A/BF pair */
+		goto out; /* UM8886A/BF pair */
 
 	if (dev->vendor == PCI_VENDOR_ID_OPTI &&
 	    dev->device == PCI_DEVICE_ID_OPTI_82C558 &&
 	    (!(PCI_FUNC(dev->devfn) & 1)))
-		return -EAGAIN;
+		goto out;
 
 	pci_read_config_word(dev, PCI_COMMAND, &command);
-	if(!(command & PCI_COMMAND_IO))
-	{
+	if(!(command & PCI_COMMAND_IO)) {
 		printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name);
-		return -EAGAIN; 
+		ret = -EAGAIN; 
+		goto out;
 	}
-	ide_setup_pci_device(dev, d);
-	return 0;
+	ret = ide_setup_pci_device(dev, d);
+out:
+	return ret;
 }
 
 static struct pci_device_id generic_pci_tbl[] = {
drivers/ide/pci/hpt34x.c renamed from drivers/ide/pci/hpt34x.c~ata-040 +1 -2
diff -puN drivers/ide/pci/hpt34x.c~ata-040 drivers/ide/pci/hpt34x.c
@@ -251,8 +251,7 @@ static int __devinit hpt34x_init_one(str
 	d->name = chipset_names[(pcicmd & PCI_COMMAND_MEMORY) ? 1 : 0];
 	d->bootable = (pcicmd & PCI_COMMAND_MEMORY) ? OFF_BOARD : NEVER_BOARD;
 
-	ide_setup_pci_device(dev, d);
-	return 0;
+	return ide_setup_pci_device(dev, d);
 }
 
 static struct pci_device_id hpt34x_pci_tbl[] = {
drivers/ide/pci/hpt366.c renamed from drivers/ide/pci/hpt366.c~ata-040 +16 -17
diff -puN drivers/ide/pci/hpt366.c~ata-040 drivers/ide/pci/hpt366.c
@@ -1191,12 +1191,12 @@ static void __devinit init_dma_hpt366(id
 	ide_setup_dma(hwif, dmabase, 8);
 }
 
-static void __devinit init_setup_hpt374(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_hpt374(struct pci_dev *dev, ide_pci_device_t *d)
 {
 	struct pci_dev *findev = NULL;
 
 	if (PCI_FUNC(dev->devfn) & 1)
-		return;
+		return -ENODEV;
 
 	while ((findev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) {
 		if ((findev->vendor == dev->vendor) &&
@@ -1209,19 +1209,18 @@ static void __devinit init_setup_hpt374(
 				printk(KERN_WARNING "%s: pci-config space interrupt "
 					"fixed.\n", d->name);
 			}
-			ide_setup_pci_devices(dev, findev, d);
-			return;
+			return ide_setup_pci_devices(dev, findev, d);
 		}
 	}
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
-static void __devinit init_setup_hpt37x(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_hpt37x(struct pci_dev *dev, ide_pci_device_t *d)
 {
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
-static void __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d)
 {
 	struct pci_dev *findev = NULL;
 	u8 pin1 = 0, pin2 = 0;
@@ -1231,7 +1230,7 @@ static void __devinit init_setup_hpt366(
 				 "HPT372N" };
 
 	if (PCI_FUNC(dev->devfn) & 1)
-		return;
+		return -ENODEV;
 
 	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
 	class_rev &= 0xff;
@@ -1246,9 +1245,10 @@ static void __devinit init_setup_hpt366(
 		case 6:
 		case 5:
 		case 4:
-		case 3: ide_setup_pci_device(dev, d);
-			return;
-		default:	break;
+		case 3:
+			goto init_single;
+		default:
+			break;
 	}
 
 	d->channels = 1;
@@ -1266,11 +1266,11 @@ static void __devinit init_setup_hpt366(
 					"pin1=%d pin2=%d\n", d->name,
 					pin1, pin2);
 			}
-			ide_setup_pci_devices(dev, findev, d);
-			return;
+			return ide_setup_pci_devices(dev, findev, d);
 		}
 	}
-	ide_setup_pci_device(dev, d);
+init_single:
+	return ide_setup_pci_device(dev, d);
 }
 
 
@@ -1287,8 +1287,7 @@ static int __devinit hpt366_init_one(str
 {
 	ide_pci_device_t *d = &hpt366_chipsets[id->driver_data];
 
-	d->init_setup(dev, d);
-	return 0;
+	return d->init_setup(dev, d);
 }
 
 static struct pci_device_id hpt366_pci_tbl[] = {
drivers/ide/pci/it8172.c renamed from drivers/ide/pci/it8172.c~ata-040 +2 -3
diff -puN drivers/ide/pci/it8172.c~ata-040 drivers/ide/pci/it8172.c
@@ -270,9 +270,8 @@ static int __devinit it8172_init_one(str
 {
         if ((!(PCI_FUNC(dev->devfn) & 1) ||
             (!((dev->class >> 8) == PCI_CLASS_STORAGE_IDE))))
-                return 1; /* IT8172 is more than only a IDE controller */
-	ide_setup_pci_device(dev, &it8172_chipsets[id->driver_data]);
-	return 0;
+                return -ENODEV; /* IT8172 is more than only a IDE controller */
+	return ide_setup_pci_device(dev, &it8172_chipsets[id->driver_data]);
 }
 
 static struct pci_device_id it8172_pci_tbl[] = {
drivers/ide/pci/ns87415.c renamed from drivers/ide/pci/ns87415.c~ata-040 +1 -2
diff -puN drivers/ide/pci/ns87415.c~ata-040 drivers/ide/pci/ns87415.c
@@ -288,8 +288,7 @@ static ide_pci_device_t ns87415_chipset 
 
 static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &ns87415_chipset);
-	return 0;
+	return ide_setup_pci_device(dev, &ns87415_chipset);
 }
 
 static struct pci_device_id ns87415_pci_tbl[] = {
drivers/ide/pci/opti621.c renamed from drivers/ide/pci/opti621.c~ata-040 +3 -4
diff -puN drivers/ide/pci/opti621.c~ata-040 drivers/ide/pci/opti621.c
@@ -348,15 +348,14 @@ static void __init init_hwif_opti621 (id
 	hwif->drives[1].autodma = hwif->autodma;
 }
 
-static void __init init_setup_opti621 (struct pci_dev *dev, ide_pci_device_t *d)
+static int __init init_setup_opti621 (struct pci_dev *dev, ide_pci_device_t *d)
 {
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
 static int __devinit opti621_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &opti621_chipsets[id->driver_data]);
-	return 0;
+	return ide_setup_pci_device(dev, &opti621_chipsets[id->driver_data]);
 }
 
 static struct pci_device_id opti621_pci_tbl[] = {
drivers/ide/pci/pdc202xx_new.c renamed from drivers/ide/pci/pdc202xx_new.c~ata-040 +13 -14
diff -puN drivers/ide/pci/pdc202xx_new.c~ata-040 drivers/ide/pci/pdc202xx_new.c
@@ -316,21 +316,21 @@ static void __devinit init_hwif_pdc202ne
 #endif /* PDC202_DEBUG_CABLE */
 }
 
-static void __devinit init_setup_pdcnew(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_pdcnew(struct pci_dev *dev, ide_pci_device_t *d)
 {
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
-static void __devinit init_setup_pdc20270(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_pdc20270(struct pci_dev *dev,
+					 ide_pci_device_t *d)
 {
 	struct pci_dev *findev = NULL;
 
 	if ((dev->bus->self &&
 	     dev->bus->self->vendor == PCI_VENDOR_ID_DEC) &&
 	    (dev->bus->self->device == PCI_DEVICE_ID_DEC_21150)) {
-		if (PCI_SLOT(dev->devfn) & 2) {
-			return;
-		}
+		if (PCI_SLOT(dev->devfn) & 2)
+			return -ENODEV;
 		d->extra = 0;
 		while ((findev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) {
 			if ((findev->vendor == dev->vendor) &&
@@ -339,15 +339,15 @@ static void __devinit init_setup_pdc2027
 				if (findev->irq != dev->irq) {
 					findev->irq = dev->irq;
 				}
-				ide_setup_pci_devices(dev, findev, d);
-				return;
+				return ide_setup_pci_devices(dev, findev, d);
 			}
 		}
 	}
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
-static void __devinit init_setup_pdc20276(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_pdc20276(struct pci_dev *dev,
+					 ide_pci_device_t *d)
 {
 	if ((dev->bus->self) &&
 	    (dev->bus->self->vendor == PCI_VENDOR_ID_INTEL) &&
@@ -355,9 +355,9 @@ static void __devinit init_setup_pdc2027
 	     (dev->bus->self->device == PCI_DEVICE_ID_INTEL_I960RM))) {
 		printk(KERN_INFO "ide: Skipping Promise PDC20276 "
 			"attached to I2O RAID controller.\n");
-		return;
+		return -ENODEV;
 	}
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
 /**
@@ -373,8 +373,7 @@ static int __devinit pdc202new_init_one(
 {
 	ide_pci_device_t *d = &pdcnew_chipsets[id->driver_data];
 
-	d->init_setup(dev, d);
-	return 0;
+	return d->init_setup(dev, d);
 }
 
 static struct pci_device_id pdc202new_pci_tbl[] = {
drivers/ide/pci/pdc202xx_old.c renamed from drivers/ide/pci/pdc202xx_old.c~ata-040 +11 -9
diff -puN drivers/ide/pci/pdc202xx_old.c~ata-040 drivers/ide/pci/pdc202xx_old.c
@@ -658,7 +658,8 @@ static void __devinit init_dma_pdc202xx(
 	ide_setup_dma(hwif, dmabase, 8);
 }
 
-static void __devinit init_setup_pdc202ata4(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_pdc202ata4(struct pci_dev *dev,
+					   ide_pci_device_t *d)
 {
 	if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) {
 		u8 irq = 0, irq2 = 0;
@@ -685,10 +686,11 @@ static void __devinit init_setup_pdc202a
         }
 #endif
 
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
-static void __devinit init_setup_pdc20265(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_pdc20265(struct pci_dev *dev,
+					 ide_pci_device_t *d)
 {
 	if ((dev->bus->self) &&
 	    (dev->bus->self->vendor == PCI_VENDOR_ID_INTEL) &&
@@ -696,7 +698,7 @@ static void __devinit init_setup_pdc2026
 	     (dev->bus->self->device == PCI_DEVICE_ID_INTEL_I960RM))) {
 		printk(KERN_INFO "ide: Skipping Promise PDC20265 "
 			"attached to I2O RAID controller.\n");
-		return;
+		return -ENODEV;
 	}
 
 #if 0
@@ -714,12 +716,13 @@ static void __devinit init_setup_pdc2026
         }
 #endif
 
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
-static void __devinit init_setup_pdc202xx(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_pdc202xx(struct pci_dev *dev,
+					 ide_pci_device_t *d)
 {
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
 /**
@@ -735,8 +738,7 @@ static int __devinit pdc202xx_init_one(s
 {
 	ide_pci_device_t *d = &pdc202xx_chipsets[id->driver_data];
 
-	d->init_setup(dev, d);
-	return 0;
+	return d->init_setup(dev, d);
 }
 
 static struct pci_device_id pdc202xx_pci_tbl[] = {
drivers/ide/pci/piix.c renamed from drivers/ide/pci/piix.c~ata-040 +3 -4
diff -puN drivers/ide/pci/piix.c~ata-040 drivers/ide/pci/piix.c
@@ -535,9 +535,9 @@ static void __devinit init_hwif_piix(ide
  *	a standard ide PCI setup
  */
 
-static void __devinit init_setup_piix(struct pci_dev *dev, ide_pci_device_t *d)
+static int __devinit init_setup_piix(struct pci_dev *dev, ide_pci_device_t *d)
 {
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
 /**
@@ -553,8 +553,7 @@ static int __devinit piix_init_one(struc
 {
 	ide_pci_device_t *d = &piix_pci_info[id->driver_data];
 
-	d->init_setup(dev, d);
-	return 0;
+	return d->init_setup(dev, d);
 }
 
 /**
drivers/ide/pci/rz1000.c renamed from drivers/ide/pci/rz1000.c~ata-040 +1 -2
diff -puN drivers/ide/pci/rz1000.c~ata-040 drivers/ide/pci/rz1000.c
@@ -62,8 +62,7 @@ static ide_pci_device_t rz1000_chipset _
 
 static int __devinit rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &rz1000_chipset);
-	return 0;
+	return ide_setup_pci_device(dev, &rz1000_chipset);
 }
 
 static struct pci_device_id rz1000_pci_tbl[] = {
drivers/ide/pci/sc1200.c renamed from drivers/ide/pci/sc1200.c~ata-040 +1 -2
diff -puN drivers/ide/pci/sc1200.c~ata-040 drivers/ide/pci/sc1200.c
@@ -489,8 +489,7 @@ static ide_pci_device_t sc1200_chipset _
 
 static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &sc1200_chipset);
-	return 0;
+	return ide_setup_pci_device(dev, &sc1200_chipset);
 }
 
 static struct pci_device_id sc1200_pci_tbl[] = {
drivers/ide/pci/serverworks.c renamed from drivers/ide/pci/serverworks.c~ata-040 +6 -7
diff -puN drivers/ide/pci/serverworks.c~ata-040 drivers/ide/pci/serverworks.c
@@ -566,12 +566,12 @@ static void __init init_dma_svwks (ide_h
 	ide_setup_dma(hwif, dmabase, 8);
 }
 
-static void __init init_setup_svwks (struct pci_dev *dev, ide_pci_device_t *d)
+static int __init init_setup_svwks (struct pci_dev *dev, ide_pci_device_t *d)
 {
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
-static void __init init_setup_csb6 (struct pci_dev *dev, ide_pci_device_t *d)
+static int __init init_setup_csb6 (struct pci_dev *dev, ide_pci_device_t *d)
 {
 	if (!(PCI_FUNC(dev->devfn) & 1)) {
 		d->bootable = NEVER_BOARD;
@@ -579,7 +579,7 @@ static void __init init_setup_csb6 (stru
 			d->bootable = ON_BOARD;
 	} else {
 		if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE)
-			return;
+			return -ENODEV;
 	}
 #if 0
 	if ((IDE_PCI_DEVID_EQ(d->devid, DEVID_CSB6) &&
@@ -591,7 +591,7 @@ static void __init init_setup_csb6 (stru
 			dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) &&
 		       (!(PCI_FUNC(dev->devfn) & 1))) ? 1 : 2;
 
-	ide_setup_pci_device(dev, d);
+	return ide_setup_pci_device(dev, d);
 }
 
 
@@ -608,8 +608,7 @@ static int __devinit svwks_init_one(stru
 {
 	ide_pci_device_t *d = &serverworks_chipsets[id->driver_data];
 
-	d->init_setup(dev, d);
-	return 0;
+	return d->init_setup(dev, d);
 }
 
 static struct pci_device_id svwks_pci_tbl[] = {
drivers/ide/pci/sgiioc4.c renamed from drivers/ide/pci/sgiioc4.c~ata-040 +15 -4
diff -puN drivers/ide/pci/sgiioc4.c~ata-040 drivers/ide/pci/sgiioc4.c
@@ -681,12 +681,14 @@ static unsigned int __devinit
 pci_init_sgiioc4(struct pci_dev *dev, ide_pci_device_t * d)
 {
 	unsigned int class_rev;
+	int ret;
 
-	if (pci_enable_device(dev)) {
+	ret = pci_enable_device(dev);
+	if (ret < 0) {
 		printk(KERN_ERR
 		       "Failed to enable device %s at slot %s\n",
 		       d->name, dev->slot_name);
-		return -ENODEV;
+		goto out;
 	}
 	pci_set_master(dev);
 
@@ -698,9 +700,18 @@ pci_init_sgiioc4(struct pci_dev *dev, id
 		printk(KERN_ERR "Skipping %s IDE controller in slot %s: "
 			"firmware is obsolete - please upgrade to revision"
 			"46 or higher\n", d->name, dev->slot_name);
-		return -ENODEV;
+		ret = -EAGAIN;
+		goto err_disable;
 	}
-	return sgiioc4_ide_setup_pci_device(dev, d);
+	ret = sgiioc4_ide_setup_pci_device(dev, d);
+	if (ret < 0)
+		goto err_disable;
+out:
+	return ret;
+
+err_disable:
+	pci_disable_device(dev);
+	goto out;
 }
 
 static ide_pci_device_t sgiioc4_chipsets[] __devinitdata = {
drivers/ide/pci/siimage.c renamed from drivers/ide/pci/siimage.c~ata-040 +1 -2
diff -puN drivers/ide/pci/siimage.c~ata-040 drivers/ide/pci/siimage.c
@@ -1102,8 +1102,7 @@ static ide_pci_device_t siimage_chipsets
  
 static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &siimage_chipsets[id->driver_data]);
-	return 0;
+	return ide_setup_pci_device(dev, &siimage_chipsets[id->driver_data]);
 }
 
 static struct pci_device_id siimage_pci_tbl[] = {
drivers/ide/pci/sis5513.c renamed from drivers/ide/pci/sis5513.c~ata-040 +1 -2
diff -puN drivers/ide/pci/sis5513.c~ata-040 drivers/ide/pci/sis5513.c
@@ -946,8 +946,7 @@ static ide_pci_device_t sis5513_chipset 
 
 static int __devinit sis5513_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &sis5513_chipset);
-	return 0;
+	return ide_setup_pci_device(dev, &sis5513_chipset);
 }
 
 static struct pci_device_id sis5513_pci_tbl[] = {
drivers/ide/pci/sl82c105.c renamed from drivers/ide/pci/sl82c105.c~ata-040 +1 -2
diff -puN drivers/ide/pci/sl82c105.c~ata-040 drivers/ide/pci/sl82c105.c
@@ -490,8 +490,7 @@ static ide_pci_device_t sl82c105_chipset
 
 static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &sl82c105_chipset);
-	return 0;
+	return ide_setup_pci_device(dev, &sl82c105_chipset);
 }
 
 static struct pci_device_id sl82c105_pci_tbl[] = {
drivers/ide/pci/slc90e66.c renamed from drivers/ide/pci/slc90e66.c~ata-040 +1 -2
diff -puN drivers/ide/pci/slc90e66.c~ata-040 drivers/ide/pci/slc90e66.c
@@ -246,8 +246,7 @@ static ide_pci_device_t slc90e66_chipset
 
 static int __devinit slc90e66_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &slc90e66_chipset);
-	return 0;
+	return ide_setup_pci_device(dev, &slc90e66_chipset);
 }
 
 static struct pci_device_id slc90e66_pci_tbl[] = {
drivers/ide/pci/triflex.c renamed from drivers/ide/pci/triflex.c~ata-040 +1 -3
diff -puN drivers/ide/pci/triflex.c~ata-040 drivers/ide/pci/triflex.c
@@ -158,9 +158,7 @@ static ide_pci_device_t triflex_device _
 static int __devinit triflex_init_one(struct pci_dev *dev, 
 		const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &triflex_device);
-
-	return 0;
+	return ide_setup_pci_device(dev, &triflex_device);
 }
 
 static struct pci_device_id triflex_pci_tbl[] = {
drivers/ide/pci/trm290.c renamed from drivers/ide/pci/trm290.c~ata-040 +1 -2
diff -puN drivers/ide/pci/trm290.c~ata-040 drivers/ide/pci/trm290.c
@@ -342,8 +342,7 @@ static ide_pci_device_t trm290_chipset _
 
 static int __devinit trm290_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &trm290_chipset);
-	return 0;
+	return ide_setup_pci_device(dev, &trm290_chipset);
 }
 
 static struct pci_device_id trm290_pci_tbl[] = {
drivers/ide/pci/via82cxxx.c renamed from drivers/ide/pci/via82cxxx.c~ata-040 +1 -2
diff -puN drivers/ide/pci/via82cxxx.c~ata-040 drivers/ide/pci/via82cxxx.c
@@ -620,8 +620,7 @@ static ide_pci_device_t via82cxxx_chipse
 
 static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	ide_setup_pci_device(dev, &via82cxxx_chipset);
-	return 0;
+	return ide_setup_pci_device(dev, &via82cxxx_chipset);
 }
 
 static struct pci_device_id via_pci_tbl[] = {
drivers/ide/pci/aec62xx.h renamed from drivers/ide/pci/aec62xx.h~ata-040 +2 -2
diff -puN drivers/ide/pci/aec62xx.h~ata-040 drivers/ide/pci/aec62xx.h
@@ -61,8 +61,8 @@ static struct chipset_bus_clock_list_ent
 #define BUSCLOCK(D)	\
 	((struct chipset_bus_clock_list_entry *) pci_get_drvdata((D)))
 
-static void init_setup_aec6x80(struct pci_dev *, ide_pci_device_t *);
-static void init_setup_aec62xx(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_aec6x80(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_aec62xx(struct pci_dev *, ide_pci_device_t *);
 static unsigned int init_chipset_aec62xx(struct pci_dev *, const char *);
 static void init_hwif_aec62xx(ide_hwif_t *);
 static void init_dma_aec62xx(ide_hwif_t *, unsigned long);
include/linux/ide.h renamed from include/linux/ide.h~ata-040 +1 -1
diff -puN include/linux/ide.h~ata-040 include/linux/ide.h
@@ -1422,7 +1422,7 @@ enum {
 
 typedef struct ide_pci_device_s {
 	char			*name;
-	void			(*init_setup)(struct pci_dev *, struct ide_pci_device_s *);
+	int			(*init_setup)(struct pci_dev *, struct ide_pci_device_s *);
 	void			(*init_setup_dma)(struct pci_dev *, struct ide_pci_device_s *, ide_hwif_t *);
 	unsigned int		(*init_chipset)(struct pci_dev *, const char *);
 	void			(*init_iops)(ide_hwif_t *);
drivers/ide/pci/hpt366.h renamed from drivers/ide/pci/hpt366.h~ata-040 +3 -3
diff -puN drivers/ide/pci/hpt366.h~ata-040 drivers/ide/pci/hpt366.h
@@ -414,9 +414,9 @@ static struct chipset_bus_clock_list_ent
 #define F_LOW_PCI_50      0x2d
 #define F_LOW_PCI_66      0x42
 
-static void init_setup_hpt366(struct pci_dev *, ide_pci_device_t *);
-static void init_setup_hpt37x(struct pci_dev *, ide_pci_device_t *);
-static void init_setup_hpt374(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_hpt366(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_hpt37x(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_hpt374(struct pci_dev *, ide_pci_device_t *);
 static unsigned int init_chipset_hpt366(struct pci_dev *, const char *);
 static void init_hwif_hpt366(ide_hwif_t *);
 static void init_dma_hpt366(ide_hwif_t *, unsigned long);
drivers/ide/pci/opti621.h renamed from drivers/ide/pci/opti621.h~ata-040 +1 -1
diff -puN drivers/ide/pci/opti621.h~ata-040 drivers/ide/pci/opti621.h
@@ -5,7 +5,7 @@
 #include <linux/pci.h>
 #include <linux/ide.h>
 
-static void init_setup_opti621(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_opti621(struct pci_dev *, ide_pci_device_t *);
 static void init_hwif_opti621(ide_hwif_t *);
 
 static ide_pci_device_t opti621_chipsets[] __devinitdata = {
drivers/ide/pci/pdc202xx_old.h renamed from drivers/ide/pci/pdc202xx_old.h~ata-040 +3 -3
diff -puN drivers/ide/pci/pdc202xx_old.h~ata-040 drivers/ide/pci/pdc202xx_old.h
@@ -63,9 +63,9 @@ static const char *pdc_quirk_drives[] = 
 #define	MC1		0x02	/* DMA"C" timing */
 #define	MC0		0x01	/* DMA"C" timing */
 
-static void init_setup_pdc202ata4(struct pci_dev *dev, ide_pci_device_t *d);
-static void init_setup_pdc20265(struct pci_dev *, ide_pci_device_t *);
-static void init_setup_pdc202xx(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_pdc202ata4(struct pci_dev *dev, ide_pci_device_t *d);
+static int init_setup_pdc20265(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_pdc202xx(struct pci_dev *, ide_pci_device_t *);
 static unsigned int init_chipset_pdc202xx(struct pci_dev *, const char *);
 static void init_hwif_pdc202xx(ide_hwif_t *);
 static void init_dma_pdc202xx(ide_hwif_t *, unsigned long);
drivers/ide/pci/pdc202xx_new.h renamed from drivers/ide/pci/pdc202xx_new.h~ata-040 +3 -3
diff -puN drivers/ide/pci/pdc202xx_new.h~ata-040 drivers/ide/pci/pdc202xx_new.h
@@ -43,9 +43,9 @@ const static char *pdc_quirk_drives[] = 
 		set_2regs(0x13,(c));			\
 	} while(0)
 
-static void init_setup_pdcnew(struct pci_dev *, ide_pci_device_t *);
-static void init_setup_pdc20270(struct pci_dev *, ide_pci_device_t *);
-static void init_setup_pdc20276(struct pci_dev *dev, ide_pci_device_t *d);
+static int init_setup_pdcnew(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_pdc20270(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_pdc20276(struct pci_dev *dev, ide_pci_device_t *d);
 static unsigned int init_chipset_pdcnew(struct pci_dev *, const char *);
 static void init_hwif_pdc202new(ide_hwif_t *);
 
drivers/ide/pci/piix.h renamed from drivers/ide/pci/piix.h~ata-040 +1 -1
diff -puN drivers/ide/pci/piix.h~ata-040 drivers/ide/pci/piix.h
@@ -5,7 +5,7 @@
 #include <linux/pci.h>
 #include <linux/ide.h>
 
-static void init_setup_piix(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_piix(struct pci_dev *, ide_pci_device_t *);
 static unsigned int __devinit init_chipset_piix(struct pci_dev *, const char *);
 static void init_hwif_piix(ide_hwif_t *);
 
drivers/ide/pci/serverworks.h renamed from drivers/ide/pci/serverworks.h~ata-040 +2 -2
diff -puN drivers/ide/pci/serverworks.h~ata-040 drivers/ide/pci/serverworks.h
@@ -21,8 +21,8 @@ static const char *svwks_bad_ata100[] = 
 	NULL
 };
 
-static void init_setup_svwks(struct pci_dev *, ide_pci_device_t *);
-static void init_setup_csb6(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_svwks(struct pci_dev *, ide_pci_device_t *);
+static int init_setup_csb6(struct pci_dev *, ide_pci_device_t *);
 static unsigned int init_chipset_svwks(struct pci_dev *, const char *);
 static void init_hwif_svwks(ide_hwif_t *);
 static void init_dma_svwks(ide_hwif_t *, unsigned long);

_

author
#10 lore raw
In reply to Francois Romieu
Quoted 9 lines · Francois Romieu

Alan Cox <[email protected]> :

Quoted 3 lines

This fixes the IT8172 driver. There are other drivers with this bug (eg generic) but the -ac IDE is sufficiently diverged from base that someone else needs to generate/test the more divergent cases.

ide_setup_pci_device{s} will always claim that everything is fine even though do_ide_setup_pci_device() has some opportunity to fail.

Should it matter as well ?

Probably. It's less pressing because the bad cases are those where ->init_one() errors with a positive return and we steal the device. The nasty one only showed up in -ac because it has a generic driver that can be told to capture all other IDE devices that are unknown, and it ran off with all the SATA devices until the bug was fixed 8)