OSDN Git Service

Make drm_sg_free callable in-kernel.
authorIan Romanick <idr@us.ibm.com>
Tue, 17 Jul 2007 05:15:01 +0000 (22:15 -0700)
committerIan Romanick <idr@us.ibm.com>
Tue, 17 Jul 2007 05:15:01 +0000 (22:15 -0700)
linux-core/drmP.h
linux-core/drm_scatter.c

index 2bbc620..ebb530b 100644 (file)
@@ -1135,8 +1135,9 @@ extern void drm_sg_cleanup(drm_sg_mem_t * entry);
 extern int drm_sg_alloc_ioctl(struct inode *inode, struct file *filp,
                        unsigned int cmd, unsigned long arg);
 extern int drm_sg_alloc(drm_device_t *dev, drm_scatter_gather_t * request);
-extern int drm_sg_free(struct inode *inode, struct file *filp,
-                      unsigned int cmd, unsigned long arg);
+extern int drm_sg_free(struct drm_device *dev, unsigned long handle);
+extern int drm_sg_free_ioctl(struct inode *inode, struct file *filp,
+                            unsigned int cmd, unsigned long arg);
 
                               /* ATI PCIGART support (ati_pcigart.h) */
 extern int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info *gart_info);
index c0d6db2..5581dc0 100644 (file)
@@ -203,6 +203,7 @@ int drm_sg_alloc_ioctl(struct inode *inode, struct file *filp,
 
        if (copy_to_user(argp, &request, sizeof(request))) {
                drm_sg_cleanup(priv->head->dev->sg);
+               priv->head->dev->sg = NULL;
                return -EFAULT;
        }
 
@@ -211,26 +212,18 @@ int drm_sg_alloc_ioctl(struct inode *inode, struct file *filp,
 
 }
 
-int drm_sg_free(struct inode *inode, struct file *filp,
-               unsigned int cmd, unsigned long arg)
+int drm_sg_free(struct drm_device *dev, unsigned long handle)
 {
-       drm_file_t *priv = filp->private_data;
-       drm_device_t *dev = priv->head->dev;
-       drm_scatter_gather_t request;
        drm_sg_mem_t *entry;
 
        if (!drm_core_check_feature(dev, DRIVER_SG))
                return -EINVAL;
 
-       if (copy_from_user(&request,
-                          (drm_scatter_gather_t __user *) arg,
-                          sizeof(request)))
-               return -EFAULT;
 
        entry = dev->sg;
        dev->sg = NULL;
 
-       if (!entry || entry->handle != request.handle)
+       if (!entry || entry->handle != handle)
                return -EINVAL;
 
        DRM_DEBUG("sg free virtual  = %p\n", entry->virtual);
@@ -239,3 +232,19 @@ int drm_sg_free(struct inode *inode, struct file *filp,
 
        return 0;
 }
+
+EXPORT_SYMBOL(drm_sg_free);
+
+int drm_sg_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_scatter_gather __user *argp = (void __user *)arg;
+       struct drm_scatter_gather request;
+
+       if (copy_from_user(&request, argp, sizeof(request)))
+               return -EFAULT;
+
+       return drm_sg_free(dev, request.handle);
+}