Re: [PATCH 2/3] drm/vgem: Enable dmabuf interface for export

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +static struct sg_table *vgem_prime_get_sg_table(struct drm_gem_object *obj)
> +{
> +       long n_pages = obj->size >> PAGE_SHIFT;
> +       struct sg_table *st;
> +       struct page **pages;
> +       int ret;
> +
> +       st = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
> +       if (st == NULL)
> +               return ERR_PTR(-ENOMEM);
> +
> +       pages = drm_gem_get_pages(obj);
> +       if (IS_ERR(pages)) {
> +               ret = PTR_ERR(pages);
> +               goto err;
> +       }
> +
> +       ret = sg_alloc_table_from_pages(st, pages, n_pages,
> +                                       0, obj->size, GFP_KERNEL);
> +       drm_gem_put_pages(obj, pages, false, false);
> +       if (ret)
> +               goto err;
> +
> +       return st;
> +
> +err:
> +       kfree(st);
> +       return ERR_PTR(ret);
> +}
> +
Couldn't this be written more simply as:

pages = drm_gem_get_pages(obj);
if (IS_ERR(pages))
        return ERR_CAST(pages);

st = drm_prime_pages_to_sg(pages, n_pages);
drm_gem_put_pages(obj, pages, false, false);

return st;

But either way:
Reviewed-by: Matthew Auld <matthew.auld@xxxxxxxxx>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux