x86, suspend, acpi: correct and add comments about Big Real Mode
[pandora-kernel.git] / drivers / char / drm / drm_agpsupport.c
index 354f0e3..aefa5ac 100644 (file)
@@ -40,7 +40,7 @@
  * Get AGP information.
  *
  * \param inode device inode.
- * \param filp file pointer.
+ * \param file_priv DRM file private.
  * \param cmd command.
  * \param arg pointer to a (output) drm_agp_info structure.
  * \return zero on success or a negative number on failure.
@@ -71,20 +71,16 @@ int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info)
 
 EXPORT_SYMBOL(drm_agp_info);
 
-int drm_agp_info_ioctl(struct inode *inode, struct file *filp,
-                      unsigned int cmd, unsigned long arg)
+int drm_agp_info_ioctl(struct drm_device *dev, void *data,
+                      struct drm_file *file_priv)
 {
-       struct drm_file *priv = filp->private_data;
-       struct drm_device *dev = priv->head->dev;
-       struct drm_agp_info info;
+       struct drm_agp_info *info = data;
        int err;
 
-       err = drm_agp_info(dev, &info);
+       err = drm_agp_info(dev, info);
        if (err)
                return err;
 
-       if (copy_to_user((struct drm_agp_info __user *) arg, &info, sizeof(info)))
-               return -EFAULT;
        return 0;
 }
 
@@ -115,7 +111,7 @@ EXPORT_SYMBOL(drm_agp_acquire);
  * Acquire the AGP device (ioctl).
  *
  * \param inode device inode.
- * \param filp file pointer.
+ * \param file_priv DRM file private.
  * \param cmd command.
  * \param arg user argument.
  * \return zero on success or a negative number on failure.
@@ -123,12 +119,10 @@ EXPORT_SYMBOL(drm_agp_acquire);
  * Verifies the AGP device hasn't been acquired before and calls
  * \c agp_backend_acquire.
  */
-int drm_agp_acquire_ioctl(struct inode *inode, struct file *filp,
-                         unsigned int cmd, unsigned long arg)
+int drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
+                         struct drm_file *file_priv)
 {
-       struct drm_file *priv = filp->private_data;
-
-       return drm_agp_acquire((struct drm_device *) priv->head->dev);
+       return drm_agp_acquire((struct drm_device *) file_priv->minor->dev);
 }
 
 /**
@@ -149,12 +143,9 @@ int drm_agp_release(struct drm_device * dev)
 }
 EXPORT_SYMBOL(drm_agp_release);
 
-int drm_agp_release_ioctl(struct inode *inode, struct file *filp,
-                         unsigned int cmd, unsigned long arg)
+int drm_agp_release_ioctl(struct drm_device *dev, void *data,
+                         struct drm_file *file_priv)
 {
-       struct drm_file *priv = filp->private_data;
-       struct drm_device *dev = priv->head->dev;
-
        return drm_agp_release(dev);
 }
 
@@ -175,31 +166,25 @@ int drm_agp_enable(struct drm_device * dev, struct drm_agp_mode mode)
 
        dev->agp->mode = mode.mode;
        agp_enable(dev->agp->bridge, mode.mode);
-       dev->agp->base = dev->agp->agp_info.aper_base;
        dev->agp->enabled = 1;
        return 0;
 }
 
 EXPORT_SYMBOL(drm_agp_enable);
 
-int drm_agp_enable_ioctl(struct inode *inode, struct file *filp,
-                        unsigned int cmd, unsigned long arg)
+int drm_agp_enable_ioctl(struct drm_device *dev, void *data,
+                        struct drm_file *file_priv)
 {
-       struct drm_file *priv = filp->private_data;
-       struct drm_device *dev = priv->head->dev;
-       struct drm_agp_mode mode;
-
-       if (copy_from_user(&mode, (struct drm_agp_mode __user *) arg, sizeof(mode)))
-               return -EFAULT;
+       struct drm_agp_mode *mode = data;
 
-       return drm_agp_enable(dev, mode);
+       return drm_agp_enable(dev, *mode);
 }
 
 /**
  * Allocate AGP memory.
  *
  * \param inode device inode.
- * \param filp file pointer.
+ * \param file_priv file private pointer.
  * \param cmd command.
  * \param arg pointer to a drm_agp_buffer structure.
  * \return zero on success or a negative number on failure.
@@ -241,35 +226,13 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
 }
 EXPORT_SYMBOL(drm_agp_alloc);
 
-int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp,
-                       unsigned int cmd, unsigned long arg)
-{
-       struct drm_file *priv = filp->private_data;
-       struct drm_device *dev = priv->head->dev;
-       struct drm_agp_buffer request;
-       struct drm_agp_buffer __user *argp = (void __user *)arg;
-       int err;
-
-       if (copy_from_user(&request, argp, sizeof(request)))
-               return -EFAULT;
 
-       err = drm_agp_alloc(dev, &request);
-       if (err)
-               return err;
-
-       if (copy_to_user(argp, &request, sizeof(request))) {
-               struct drm_agp_mem *entry;
-               list_for_each_entry(entry, &dev->agp->memory, head) {
-                       if (entry->handle == request.handle)
-                               break;
-               }
-               list_del(&entry->head);
-               drm_free_agp(entry->memory, entry->pages);
-               drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
-               return -EFAULT;
-       }
+int drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
+                       struct drm_file *file_priv)
+{
+       struct drm_agp_buffer *request = data;
 
-       return 0;
+       return drm_agp_alloc(dev, request);
 }
 
 /**
@@ -297,7 +260,7 @@ static struct drm_agp_mem *drm_agp_lookup_entry(struct drm_device * dev,
  * Unbind AGP memory from the GATT (ioctl).
  *
  * \param inode device inode.
- * \param filp file pointer.
+ * \param file_priv DRM file private.
  * \param cmd command.
  * \param arg pointer to a drm_agp_binding structure.
  * \return zero on success or a negative number on failure.
@@ -323,25 +286,20 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
 }
 EXPORT_SYMBOL(drm_agp_unbind);
 
-int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp,
-                        unsigned int cmd, unsigned long arg)
-{
-       struct drm_file *priv = filp->private_data;
-       struct drm_device *dev = priv->head->dev;
-       struct drm_agp_binding request;
 
-       if (copy_from_user
-           (&request, (struct drm_agp_binding __user *) arg, sizeof(request)))
-               return -EFAULT;
+int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
+                        struct drm_file *file_priv)
+{
+       struct drm_agp_binding *request = data;
 
-       return drm_agp_unbind(dev, &request);
+       return drm_agp_unbind(dev, request);
 }
 
 /**
  * Bind AGP memory into the GATT (ioctl)
  *
  * \param inode device inode.
- * \param filp file pointer.
+ * \param file_priv DRM file private.
  * \param cmd command.
  * \param arg pointer to a drm_agp_binding structure.
  * \return zero on success or a negative number on failure.
@@ -372,25 +330,20 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
 }
 EXPORT_SYMBOL(drm_agp_bind);
 
-int drm_agp_bind_ioctl(struct inode *inode, struct file *filp,
-                      unsigned int cmd, unsigned long arg)
-{
-       struct drm_file *priv = filp->private_data;
-       struct drm_device *dev = priv->head->dev;
-       struct drm_agp_binding request;
 
-       if (copy_from_user
-           (&request, (struct drm_agp_binding __user *) arg, sizeof(request)))
-               return -EFAULT;
+int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
+                      struct drm_file *file_priv)
+{
+       struct drm_agp_binding *request = data;
 
-       return drm_agp_bind(dev, &request);
+       return drm_agp_bind(dev, request);
 }
 
 /**
  * Free AGP memory (ioctl).
  *
  * \param inode device inode.
- * \param filp file pointer.
+ * \param file_priv DRM file private.
  * \param cmd command.
  * \param arg pointer to a drm_agp_buffer structure.
  * \return zero on success or a negative number on failure.
@@ -419,18 +372,14 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
 }
 EXPORT_SYMBOL(drm_agp_free);
 
-int drm_agp_free_ioctl(struct inode *inode, struct file *filp,
-                      unsigned int cmd, unsigned long arg)
-{
-       struct drm_file *priv = filp->private_data;
-       struct drm_device *dev = priv->head->dev;
-       struct drm_agp_buffer request;
 
-       if (copy_from_user
-           (&request, (struct drm_agp_buffer __user *) arg, sizeof(request)))
-               return -EFAULT;
 
-       return drm_agp_free(dev, &request);
+int drm_agp_free_ioctl(struct drm_device *dev, void *data,
+                      struct drm_file *file_priv)
+{
+       struct drm_agp_buffer *request = data;
+
+       return drm_agp_free(dev, request);
 }
 
 /**
@@ -467,7 +416,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
        INIT_LIST_HEAD(&head->memory);
        head->cant_use_aperture = head->agp_info.cant_use_aperture;
        head->page_mask = head->agp_info.page_mask;
-
+       head->base = head->agp_info.aper_base;
        return head;
 }