PATCH - via_agp.c: VP3 souldn't work / "Detected VIA %s chipset" fails (kernel 2.6.7)

From: Carsten Rietzschel
Date: Wed Jun 16 2004 - 10:29:48 EST


Hello,

the AGP-driver should not work for Apollo VP3, cause it's not listed in
struct pci_device_id list in the fresh kernel 2.6.7.

So it also displays "Detected VIA %s chipset" wrong for every VIA chipset.

The reason for both is, in
static struct pci_device_id agp_via_pci_table[]
the line
ID(PCI_DEVICE_ID_VIA_82C597_0),
is missing.

The source code has an comment:
/* must be the same order as name table above */
but it doesn't match.

The attached patch:
- adds ID(PCI_DEVICE_ID_VIA_82C597_0) to pci_device_id agp_via_pci_table[]
- it compares the correct number of entries in both tables in init-function
(agp_via_pci_table vs. via_agp_device_ids), if it doesn't match in prints a
warning
<--- this is not neccessary, but just to be sure :)

Regards,
Carsten
diff -uprN linux-2.6.7-org/drivers/char/agp/via-agp.c linux-2.6.7/drivers/char/agp/via-agp.c
--- linux-2.6.7-org/drivers/char/agp/via-agp.c 2004-06-16 13:26:03.000000000 +0200
+++ linux-2.6.7/drivers/char/agp/via-agp.c 2004-06-16 17:10:47.000000000 +0200
@@ -351,6 +351,7 @@ static struct agp_device_ids via_agp_dev

{ }, /* dummy final entry, always present */
};
+#define AGP_VIA_DEVICE_ELEMENTS (sizeof(via_agp_device_ids)/sizeof(via_agp_device_ids[0]))


/*
@@ -434,6 +435,7 @@ static struct pci_device_id agp_via_pci_
.subvendor = PCI_ANY_ID, \
.subdevice = PCI_ANY_ID, \
}
+ ID(PCI_DEVICE_ID_VIA_82C597_0),
ID(PCI_DEVICE_ID_VIA_82C598_0),
ID(PCI_DEVICE_ID_VIA_8501_0),
ID(PCI_DEVICE_ID_VIA_8601_0),
@@ -459,10 +461,12 @@ static struct pci_device_id agp_via_pci_
ID(PCI_DEVICE_ID_VIA_PX8X0_0),
{ }
};
+#define AGP_VIA_PCI_ELEMENTS (sizeof(agp_via_pci_table)/sizeof(agp_via_pci_table[0]))

MODULE_DEVICE_TABLE(pci, agp_via_pci_table);


+
static struct pci_driver agp_via_pci_driver = {
.name = "agpgart-via",
.id_table = agp_via_pci_table,
@@ -473,6 +477,8 @@ static struct pci_driver agp_via_pci_dri

static int __init agp_via_init(void)
{
+ if(AGP_VIA_DEVICE_ELEMENTS != AGP_VIA_PCI_ELEMENTS)
+ printk (KERN_INFO PFX "Warning: sizeof device and pci elements don't match. Please send a bug report.\n");
return pci_module_init(&agp_via_pci_driver);
}