Skip to content

Commit

Permalink
amd64-agp: run fallback when no bridges found, not when driver regist…
Browse files Browse the repository at this point in the history
…ration fails

I think the intent was that if no bridges matched agp_amd64_pci_table[],
we would fall back to checking for any bridge with the AGP capability.
But in the current code, we execute the fallback path only when
pci_register_driver() itself fails, which is unrelated to whether any
matching devices were found.

This patch counts the AGP bridges found in the probe() method and executes
the fallback path when none is found.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Bjorn Helgaas authored and Dave Airlie committed Aug 12, 2008
1 parent 99d32bd commit 55814b7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions drivers/char/agp/amd64-agp.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

static struct resource *aperture_resource;
static int __initdata agp_try_unsupported = 1;
static int agp_bridges_found;

static void amd64_tlbflush(struct agp_memory *temp)
{
Expand Down Expand Up @@ -489,6 +490,7 @@ static int __devinit agp_amd64_probe(struct pci_dev *pdev,
{
struct agp_bridge_data *bridge;
u8 cap_ptr;
int err;

cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
if (!cap_ptr)
Expand Down Expand Up @@ -536,7 +538,12 @@ static int __devinit agp_amd64_probe(struct pci_dev *pdev,
}

pci_set_drvdata(pdev, bridge);
return agp_add_bridge(bridge);
err = agp_add_bridge(bridge);
if (err < 0)
return err;

agp_bridges_found++;
return 0;
}

static void __devexit agp_amd64_remove(struct pci_dev *pdev)
Expand Down Expand Up @@ -713,7 +720,11 @@ int __init agp_amd64_init(void)

if (agp_off)
return -EINVAL;
if (pci_register_driver(&agp_amd64_pci_driver) < 0) {
err = pci_register_driver(&agp_amd64_pci_driver);
if (err < 0)
return err;

if (agp_bridges_found == 0) {
struct pci_dev *dev;
if (!agp_try_unsupported && !agp_try_unsupported_boot) {
printk(KERN_INFO PFX "No supported AGP bridge found.\n");
Expand Down

0 comments on commit 55814b7

Please sign in to comment.