]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/agp/i460-agp.c
Pull sony-2.6.24 into release branch
[linux-2.6-omap-h63xx.git] / drivers / char / agp / i460-agp.c
index 8ee19a4a6bce4741b75ecb9e1adb21bfe4d1c017..75d2aca6353de9ce1bb1bd90acfca27eddc60688 100644 (file)
@@ -78,7 +78,7 @@ static struct {
        } *lp_desc;
 } i460;
 
-static struct aper_size_info_8 i460_sizes[3] =
+static const struct aper_size_info_8 i460_sizes[3] =
 {
        /*
         * The 32GB aperture is only available with a 4M GART page size.  Due to the
@@ -249,6 +249,10 @@ static int i460_create_gatt_table (struct agp_bridge_data *bridge)
        num_entries = A_SIZE_8(temp)->num_entries;
 
        i460.gatt = ioremap(INTEL_I460_ATTBASE, PAGE_SIZE << page_order);
+       if (!i460.gatt) {
+               printk(KERN_ERR PFX "ioremap failed\n");
+               return -ENOMEM;
+       }
 
        /* These are no good, the should be removed from the agp_bridge strucure... */
        agp_bridge->gatt_table_real = NULL;
@@ -293,6 +297,9 @@ static int i460_insert_memory_small_io_page (struct agp_memory *mem,
        pr_debug("i460_insert_memory_small_io_page(mem=%p, pg_start=%ld, type=%d, paddr0=0x%lx)\n",
                 mem, pg_start, type, mem->memory[0]);
 
+       if (type >= AGP_USER_TYPES || mem->type >= AGP_USER_TYPES)
+               return -EINVAL;
+
        io_pg_start = I460_IOPAGES_PER_KPAGE * pg_start;
 
        temp = agp_bridge->current_size;
@@ -396,14 +403,17 @@ static int i460_insert_memory_large_io_page (struct agp_memory *mem,
        struct lp_desc *start, *end, *lp;
        void *temp;
 
+       if (type >= AGP_USER_TYPES || mem->type >= AGP_USER_TYPES)
+               return -EINVAL;
+
        temp = agp_bridge->current_size;
        num_entries = A_SIZE_8(temp)->num_entries;
 
        /* Figure out what pg_start means in terms of our large GART pages */
-       start           = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE];
-       end             = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE];
-       start_offset    = pg_start % I460_KPAGES_PER_IOPAGE;
-       end_offset      = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE;
+       start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE];
+       end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE];
+       start_offset = pg_start % I460_KPAGES_PER_IOPAGE;
+       end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE;
 
        if (end > i460.lp_desc + num_entries) {
                printk(KERN_ERR PFX "Looks like we're out of AGP memory\n");
@@ -458,10 +468,10 @@ static int i460_remove_memory_large_io_page (struct agp_memory *mem,
        num_entries = A_SIZE_8(temp)->num_entries;
 
        /* Figure out what pg_start means in terms of our large GART pages */
-       start           = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE];
-       end             = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE];
-       start_offset    = pg_start % I460_KPAGES_PER_IOPAGE;
-       end_offset      = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE;
+       start = &i460.lp_desc[pg_start / I460_KPAGES_PER_IOPAGE];
+       end = &i460.lp_desc[(pg_start + mem->page_count - 1) / I460_KPAGES_PER_IOPAGE];
+       start_offset = pg_start % I460_KPAGES_PER_IOPAGE;
+       end_offset = (pg_start + mem->page_count - 1) % I460_KPAGES_PER_IOPAGE;
 
        for (i = 0, lp = start; lp <= end; ++lp) {
                for (idx = ((lp == start) ? start_offset : 0);
@@ -544,7 +554,7 @@ static unsigned long i460_mask_memory (struct agp_bridge_data *bridge,
                | (((addr & ~((1 << I460_IO_PAGE_SHIFT) - 1)) & 0xfffff000) >> 12);
 }
 
-struct agp_bridge_driver intel_i460_driver = {
+const struct agp_bridge_driver intel_i460_driver = {
        .owner                  = THIS_MODULE,
        .aperture_sizes         = i460_sizes,
        .size_type              = U8_APER_SIZE,
@@ -572,6 +582,7 @@ struct agp_bridge_driver intel_i460_driver = {
 #endif
        .alloc_by_type          = agp_generic_alloc_by_type,
        .free_by_type           = agp_generic_free_by_type,
+       .agp_type_to_mask_type  = agp_generic_type_to_mask_type,
        .cant_use_aperture      = 1,
 };