This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / char / drm / gamma_old_dma.h
index abdd454..43be5c8 100644 (file)
@@ -122,8 +122,6 @@ int DRM(dma_enqueue)(struct file *filp, drm_dma_t *d)
        int               idx;
        int               while_locked = 0;
        drm_device_dma_t  *dma = dev->dma;
-       int               *ind;
-       int               err;
        DECLARE_WAITQUEUE(entry, current);
 
        DRM_DEBUG("%d\n", d->send_count);
@@ -170,51 +168,45 @@ int DRM(dma_enqueue)(struct file *filp, drm_dma_t *d)
                remove_wait_queue(&q->write_queue, &entry);
        }
 
-       ind = DRM(alloc)(d->send_count * sizeof(int), DRM_MEM_DRIVER);
-       if (!ind)
-               return -ENOMEM;
-
-       if (copy_from_user(ind, d->send_indices, d->send_count * sizeof(int))) {
-               err = -EFAULT;
-                goto out;
-       }
-
-       err = -EINVAL;
        for (i = 0; i < d->send_count; i++) {
-               idx = ind[i];
+               idx = d->send_indices[i];
                if (idx < 0 || idx >= dma->buf_count) {
+                       atomic_dec(&q->use_count);
                        DRM_ERROR("Index %d (of %d max)\n",
-                                 ind[i], dma->buf_count - 1);
-                       goto out;
+                                 d->send_indices[i], dma->buf_count - 1);
+                       return -EINVAL;
                }
                buf = dma->buflist[ idx ];
                if (buf->filp != filp) {
+                       atomic_dec(&q->use_count);
                        DRM_ERROR("Process %d using buffer not owned\n",
                                  current->pid);
-                       goto out;
+                       return -EINVAL;
                }
                if (buf->list != DRM_LIST_NONE) {
+                       atomic_dec(&q->use_count);
                        DRM_ERROR("Process %d using buffer %d on list %d\n",
                                  current->pid, buf->idx, buf->list);
-                       goto out;
                }
-               buf->used         = ind[i];
+               buf->used         = d->send_sizes[i];
                buf->while_locked = while_locked;
                buf->context      = d->context;
                if (!buf->used) {
                        DRM_ERROR("Queueing 0 length buffer\n");
                }
                if (buf->pending) {
+                       atomic_dec(&q->use_count);
                        DRM_ERROR("Queueing pending buffer:"
                                  " buffer %d, offset %d\n",
-                                 ind[i], i);
-                       goto out;
+                                 d->send_indices[i], i);
+                       return -EINVAL;
                }
                if (buf->waiting) {
+                       atomic_dec(&q->use_count);
                        DRM_ERROR("Queueing waiting buffer:"
                                  " buffer %d, offset %d\n",
-                                 ind[i], i);
-                       goto out;
+                                 d->send_indices[i], i);
+                       return -EINVAL;
                }
                buf->waiting = 1;
                if (atomic_read(&q->use_count) == 1
@@ -228,11 +220,6 @@ int DRM(dma_enqueue)(struct file *filp, drm_dma_t *d)
        atomic_dec(&q->use_count);
 
        return 0;
-
-out:
-       DRM(free)(ind, d->send_count * sizeof(int), DRM_MEM_DRIVER);
-       atomic_dec(&q->use_count);
-       return err;
 }
 
 static int DRM(dma_get_buffers_of_order)(struct file *filp, drm_dma_t *d,