Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] via82cxxx: handle error condition properly

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>

authored by

Alan Cox and committed by
Linus Torvalds
23a1b2a7 87b4126f

+16 -5
+16 -5
drivers/ide/pci/via82cxxx.c
··· 282 282 * Find the ISA bridge to see how good the IDE is. 283 283 */ 284 284 via_config = via_config_find(&isa); 285 - if (!via_config->id) { 286 - printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); 287 - pci_dev_put(isa); 288 - return -ENODEV; 289 - } 285 + 286 + /* We checked this earlier so if it fails here deeep badness 287 + is involved */ 288 + 289 + BUG_ON(!via_config->id); 290 290 291 291 /* 292 292 * Setup or disable Clk66 if appropriate ··· 494 494 495 495 static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id) 496 496 { 497 + struct pci_dev *isa = NULL; 498 + struct via_isa_bridge *via_config; 499 + /* 500 + * Find the ISA bridge and check we know what it is. 501 + */ 502 + via_config = via_config_find(&isa); 503 + pci_dev_put(isa); 504 + if (!via_config->id) { 505 + printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); 506 + return -ENODEV; 507 + } 497 508 return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]); 498 509 } 499 510