--- agpgart_be.c	2005-01-31 19:50:00.000000000 +0200
+++ agpgart_be.c	2005-03-02 22:19:25.000000000 +0200
@@ -261,6 +261,12 @@
 #define firegl_pci_find_class(class,from) pci_find_class(class,from)
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11) 
+#define firegl_pci_find_class(class,from) pci_get_class(class,from)
+#else
+#define firegl_pci_find_class(class,from) pci_find_class(class,from)
+#endif
+
 int agp_backend_acquire(void)
 {
 	if (agp_bridge.type == NOT_SUPPORTED) {
@@ -4075,6 +4081,13 @@
 			}
 		}
 	}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11) 
+            // the reference count has been increased in agp_backend_initialize.
+        if (device)
+            pci_dev_put(device); 
+#endif
+
 	/*
 	 * PASS3: Figure out the 8X/4X setting and enable the
 	 *        target (our motherboard chipset).
@@ -5283,6 +5296,12 @@
             pci_dev_put(device); 
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11) 
+            // the reference count has been increased in agp_backend_initialize.
+        if (device)
+            pci_dev_put(device); 
+#endif
+
     return(0); /* success */
 }
 
@@ -7428,6 +7447,11 @@
 		return rc;
 	}
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)
+        // decrease the reference count.
+        pci_dev_put(agp_bridge.dev);
+#endif
+
 	if (agp_bridge.needs_scratch_page == TRUE) {
 		agp_bridge.scratch_page = agp_bridge.agp_alloc_page();
