Merge remote-tracking branch 'torvalds/master' into perf/core
[sfrench/cifs-2.6.git] / drivers / dma-buf / heaps / system_heap.c
index 17e0e9a68baff4695f17c079b5f8ae29ec1e7ad3..29e49ac1725135ee6254ed9e0726e42bc885e7b3 100644 (file)
@@ -331,10 +331,10 @@ static struct page *alloc_largest_available(unsigned long size,
        return NULL;
 }
 
-static int system_heap_allocate(struct dma_heap *heap,
-                               unsigned long len,
-                               unsigned long fd_flags,
-                               unsigned long heap_flags)
+static struct dma_buf *system_heap_allocate(struct dma_heap *heap,
+                                           unsigned long len,
+                                           unsigned long fd_flags,
+                                           unsigned long heap_flags)
 {
        struct system_heap_buffer *buffer;
        DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
@@ -349,7 +349,7 @@ static int system_heap_allocate(struct dma_heap *heap,
 
        buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
        if (!buffer)
-               return -ENOMEM;
+               return ERR_PTR(-ENOMEM);
 
        INIT_LIST_HEAD(&buffer->attachments);
        mutex_init(&buffer->lock);
@@ -363,8 +363,10 @@ static int system_heap_allocate(struct dma_heap *heap,
                 * Avoid trying to allocate memory if the process
                 * has been killed by SIGKILL
                 */
-               if (fatal_signal_pending(current))
+               if (fatal_signal_pending(current)) {
+                       ret = -EINTR;
                        goto free_buffer;
+               }
 
                page = alloc_largest_available(size_remaining, max_order);
                if (!page)
@@ -397,14 +399,7 @@ static int system_heap_allocate(struct dma_heap *heap,
                ret = PTR_ERR(dmabuf);
                goto free_pages;
        }
-
-       ret = dma_buf_fd(dmabuf, fd_flags);
-       if (ret < 0) {
-               dma_buf_put(dmabuf);
-               /* just return, as put will call release and that will free */
-               return ret;
-       }
-       return ret;
+       return dmabuf;
 
 free_pages:
        for_each_sgtable_sg(table, sg, i) {
@@ -418,7 +413,7 @@ free_buffer:
                __free_pages(page, compound_order(page));
        kfree(buffer);
 
-       return ret;
+       return ERR_PTR(ret);
 }
 
 static const struct dma_heap_ops system_heap_ops = {