]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/agp/frontend.c
Merge branch 'for-2.6.25' of git://git.secretlab.ca/git/linux-2.6-mpc52xx into for...
[linux-2.6-omap-h63xx.git] / drivers / char / agp / frontend.c
index 0f2ed2aa2d815039d7cd6cd3dc26a20a4e15791e..55d7a82bd071a725a8813d888dabb77215de79be 100644 (file)
 #include <linux/agpgart.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
+#include <linux/fs.h>
+#include <linux/sched.h>
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 #include "agp.h"
 
-static struct agp_front_data agp_fe;
+struct agp_front_data agp_fe;
 
-static struct agp_memory *agp_find_mem_by_key(int key)
+struct agp_memory *agp_find_mem_by_key(int key)
 {
        struct agp_memory *curr;
 
@@ -159,7 +161,7 @@ static pgprot_t agp_convert_mmap_flags(int prot)
        return vm_get_page_prot(prot_bits);
 }
 
-static int agp_create_segment(struct agp_client *client, struct agp_region *region)
+int agp_create_segment(struct agp_client *client, struct agp_region *region)
 {
        struct agp_segment_priv **ret_seg;
        struct agp_segment_priv *seg;
@@ -211,7 +213,7 @@ static void agp_insert_into_pool(struct agp_memory * temp)
 
 /* File private list routines */
 
-static struct agp_file_private *agp_find_private(pid_t pid)
+struct agp_file_private *agp_find_private(pid_t pid)
 {
        struct agp_file_private *curr;
 
@@ -266,13 +268,13 @@ static void agp_remove_file_private(struct agp_file_private * priv)
  * Wrappers for agp_free_memory & agp_allocate_memory
  * These make sure that internal lists are kept updated.
  */
-static void agp_free_memory_wrap(struct agp_memory *memory)
+void agp_free_memory_wrap(struct agp_memory *memory)
 {
        agp_remove_from_pool(memory);
        agp_free_memory(memory);
 }
 
-static struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type)
+struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type)
 {
        struct agp_memory *memory;
 
@@ -484,7 +486,7 @@ static struct agp_controller *agp_find_controller_for_client(pid_t id)
        return NULL;
 }
 
-static struct agp_client *agp_find_client_by_pid(pid_t id)
+struct agp_client *agp_find_client_by_pid(pid_t id)
 {
        struct agp_client *temp;
 
@@ -509,7 +511,7 @@ static void agp_insert_client(struct agp_client *client)
        agp_fe.current_controller->num_clients++;
 }
 
-static struct agp_client *agp_create_client(pid_t id)
+struct agp_client *agp_create_client(pid_t id)
 {
        struct agp_client *new_client;
 
@@ -522,7 +524,7 @@ static struct agp_client *agp_create_client(pid_t id)
        return new_client;
 }
 
-static int agp_remove_client(pid_t id)
+int agp_remove_client(pid_t id)
 {
        struct agp_client *client;
        struct agp_client *prev_client;
@@ -687,7 +689,7 @@ static int agp_open(struct inode *inode, struct file *file)
        set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags);
        priv->my_pid = current->pid;
 
-       if ((current->uid == 0) || (current->suid == 0)) {
+       if (capable(CAP_SYS_RAWIO)) {
                /* Root priv, can be controller */
                set_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags);
        }
@@ -746,7 +748,7 @@ static int agpioc_info_wrap(struct agp_file_private *priv, void __user *arg)
        return 0;
 }
 
-static int agpioc_acquire_wrap(struct agp_file_private *priv)
+int agpioc_acquire_wrap(struct agp_file_private *priv)
 {
        struct agp_controller *controller;
 
@@ -789,14 +791,14 @@ static int agpioc_acquire_wrap(struct agp_file_private *priv)
        return 0;
 }
 
-static int agpioc_release_wrap(struct agp_file_private *priv)
+int agpioc_release_wrap(struct agp_file_private *priv)
 {
        DBG("");
        agp_controller_release_current(agp_fe.current_controller, priv);
        return 0;
 }
 
-static int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg)
+int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg)
 {
        struct agp_setup mode;
 
@@ -876,7 +878,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
        return -EINVAL;
 }
 
-static int agpioc_protect_wrap(struct agp_file_private *priv)
+int agpioc_protect_wrap(struct agp_file_private *priv)
 {
        DBG("");
        /* This function is not currently implemented */
@@ -892,6 +894,9 @@ static int agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg)
        if (copy_from_user(&alloc, arg, sizeof(struct agp_allocate)))
                return -EFAULT;
 
+       if (alloc.type >= AGP_USER_TYPES)
+               return -EINVAL;
+
        memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type);
 
        if (memory == NULL)
@@ -907,7 +912,7 @@ static int agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg)
        return 0;
 }
 
-static int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg)
+int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg)
 {
        struct agp_memory *memory;
 
@@ -955,6 +960,13 @@ static int agpioc_unbind_wrap(struct agp_file_private *priv, void __user *arg)
        return agp_unbind_memory(memory);
 }
 
+int agpioc_chipset_flush_wrap(struct agp_file_private *priv)
+{
+       DBG("");
+       agp_flush_chipset(agp_bridge);
+       return 0;
+}
+
 static int agp_ioctl(struct inode *inode, struct file *file,
                     unsigned int cmd, unsigned long arg)
 {
@@ -1028,6 +1040,10 @@ static int agp_ioctl(struct inode *inode, struct file *file,
        case AGPIOC_UNBIND:
                ret_val = agpioc_unbind_wrap(curr_priv, (void __user *) arg);
                break;
+              
+       case AGPIOC_CHIPSET_FLUSH:
+               ret_val = agpioc_chipset_flush_wrap(curr_priv);
+               break;
        }
 
 ioctl_out:
@@ -1043,6 +1059,9 @@ static const struct file_operations agp_fops =
        .read           = agp_read,
        .write          = agp_write,
        .ioctl          = agp_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl   = compat_agp_ioctl,
+#endif
        .mmap           = agp_mmap,
        .open           = agp_open,
        .release        = agp_release,