[PATCH] via82cxxx: handle error condition properly
authorAlan Cox <alan@lxorguk.ukuu.org.uk>
Thu, 7 Dec 2006 04:36:12 +0000 (20:36 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Thu, 7 Dec 2006 16:39:32 +0000 (08:39 -0800)
Jeff noted that the via driver returned an error to an unsigned int in a
a case where errors are not permitted. Move the check down earlier so we
can handle it properly. Not as pretty but it works this way and avoids
hacking up ugly stuff in the legacy ide core.

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/ide/pci/via82cxxx.c

index eb7ab112c05010fec0f9048ef2b8c1a837d62eb4..61f1a9665a7f911729ae17faad0492a5b89309fe 100644 (file)
@@ -282,11 +282,11 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const
         * Find the ISA bridge to see how good the IDE is.
         */
        via_config = via_config_find(&isa);
-       if (!via_config->id) {
-               printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n");
-               pci_dev_put(isa);
-               return -ENODEV;
-       }
+
+       /* We checked this earlier so if it fails here deeep badness
+          is involved */
+
+       BUG_ON(!via_config->id);
 
        /*
         * Setup or disable Clk66 if appropriate
@@ -494,6 +494,17 @@ static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
 
 static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
+       struct pci_dev *isa = NULL;
+       struct via_isa_bridge *via_config;
+       /*
+        * Find the ISA bridge and check we know what it is.
+        */
+       via_config = via_config_find(&isa);
+       pci_dev_put(isa);
+       if (!via_config->id) {
+               printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n");
+               return -ENODEV;
+       }
        return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]);
 }