Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / char / agp / ati-agp.c
index e572ced..06fd10b 100644 (file)
@@ -6,6 +6,8 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/string.h>
+#include <linux/slab.h>
 #include <linux/agp_backend.h>
 #include <asm/agp.h>
 #include "agp.h"
@@ -72,7 +74,7 @@ static int ati_create_page_map(ati_page_map *page_map)
        /*CACHE_FLUSH();*/
        global_cache_flush();
 
-       for(i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) {
+       for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) {
                writel(agp_bridge->scratch_page, page_map->remapped+i);
                readl(page_map->remapped+i);    /* PCI Posting. */
        }
@@ -97,7 +99,7 @@ static void ati_free_gatt_pages(void)
        ati_page_map *entry;
 
        tables = ati_generic_private.gatt_pages;
-       for(i = 0; i < ati_generic_private.num_tables; i++) {
+       for (i = 0; i < ati_generic_private.num_tables; i++) {
                entry = tables[i];
                if (entry != NULL) {
                        if (entry->real != NULL)
@@ -116,14 +118,12 @@ static int ati_create_gatt_pages(int nr_tables)
        int retval = 0;
        int i;
 
-       tables = kmalloc((nr_tables + 1) * sizeof(ati_page_map *),
-                        GFP_KERNEL);
+       tables = kzalloc((nr_tables + 1) * sizeof(ati_page_map *),GFP_KERNEL);
        if (tables == NULL)
                return -ENOMEM;
 
-       memset(tables, 0, sizeof(ati_page_map *) * (nr_tables + 1));
        for (i = 0; i < nr_tables; i++) {
-               entry = kmalloc(sizeof(ati_page_map), GFP_KERNEL);
+               entry = kzalloc(sizeof(ati_page_map), GFP_KERNEL);
                if (entry == NULL) {
                        while (i>0) {
                                kfree (tables[i-1]);
@@ -134,7 +134,6 @@ static int ati_create_gatt_pages(int nr_tables)
                        retval = -ENOMEM;
                        break;
                }
-               memset(entry, 0, sizeof(ati_page_map));
                tables[i] = entry;
                retval = ati_create_page_map(entry);
                if (retval != 0) break;
@@ -245,6 +244,22 @@ static int ati_configure(void)
 }
 
 
+#ifdef CONFIG_PM
+static int agp_ati_resume(struct pci_dev *dev)
+{
+       pci_restore_state(dev);
+
+       return ati_configure();
+}
+
+static int agp_ati_suspend(struct pci_dev *dev, pm_message_t state)
+{
+       pci_save_state(dev);
+
+       return 0;
+}
+#endif
+
 /*
  *Since we don't need contigious memory we just try
  * to get the gatt table once
@@ -372,7 +387,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge)
        agp_bridge->gart_bus_addr = addr;
 
        /* Calculate the agp offset */
-       for(i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
+       for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
                writel(virt_to_gart(ati_generic_private.gatt_pages[i]->real) | 1,
                        page_dir.remapped+GET_PAGE_DIR_OFF(addr));
                readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr));        /* PCI Posting. */
@@ -451,6 +466,10 @@ static struct agp_device_ids ati_agp_device_ids[] __devinitdata =
                .device_id      = PCI_DEVICE_ID_ATI_RS300_200,
                .chipset_name   = "IGP9100/M",
        },
+       {
+               .device_id      = PCI_DEVICE_ID_ATI_RS350_200,
+               .chipset_name   = "IGP9100/M",
+       },
        { }, /* dummy final entry, always present */
 };
 
@@ -526,6 +545,10 @@ static struct pci_driver agp_ati_pci_driver = {
        .id_table       = agp_ati_pci_table,
        .probe          = agp_ati_probe,
        .remove         = agp_ati_remove,
+#ifdef CONFIG_PM
+       .resume         = agp_ati_resume,
+       .suspend        = agp_ati_suspend,
+#endif
 };
 
 static int __init agp_ati_init(void)