diff options
Diffstat (limited to 'drivers/gpu/ion')
| -rw-r--r-- | drivers/gpu/ion/ion.c | 26 | 
1 files changed, 20 insertions, 6 deletions
| diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index 34264edc6ee..722c4a2f72c 100644 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -949,19 +949,19 @@ struct dma_buf_ops dma_buf_ops = {  	.kunmap = ion_dma_buf_kunmap,  }; -int ion_share_dma_buf(struct ion_client *client, struct ion_handle *handle) +struct dma_buf *ion_share_dma_buf(struct ion_client *client, +						struct ion_handle *handle)  {  	struct ion_buffer *buffer;  	struct dma_buf *dmabuf;  	bool valid_handle; -	int fd;  	mutex_lock(&client->lock);  	valid_handle = ion_handle_validate(client, handle);  	mutex_unlock(&client->lock);  	if (!valid_handle) {  		WARN(1, "%s: invalid handle passed to share.\n", __func__); -		return -EINVAL; +		return ERR_PTR(-EINVAL);  	}  	buffer = handle->buffer; @@ -969,15 +969,29 @@ int ion_share_dma_buf(struct ion_client *client, struct ion_handle *handle)  	dmabuf = dma_buf_export(buffer, &dma_buf_ops, buffer->size, O_RDWR);  	if (IS_ERR(dmabuf)) {  		ion_buffer_put(buffer); -		return PTR_ERR(dmabuf); +		return dmabuf;  	} + +	return dmabuf; +} +EXPORT_SYMBOL(ion_share_dma_buf); + +int ion_share_dma_buf_fd(struct ion_client *client, struct ion_handle *handle) +{ +	struct dma_buf *dmabuf; +	int fd; + +	dmabuf = ion_share_dma_buf(client, handle); +	if (IS_ERR(dmabuf)) +		return PTR_ERR(dmabuf); +  	fd = dma_buf_fd(dmabuf, O_CLOEXEC);  	if (fd < 0)  		dma_buf_put(dmabuf);  	return fd;  } -EXPORT_SYMBOL(ion_share_dma_buf); +EXPORT_SYMBOL(ion_share_dma_buf_fd);  struct ion_handle *ion_import_dma_buf(struct ion_client *client, int fd)  { @@ -1086,7 +1100,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)  		if (copy_from_user(&data, (void __user *)arg, sizeof(data)))  			return -EFAULT; -		data.fd = ion_share_dma_buf(client, data.handle); +		data.fd = ion_share_dma_buf_fd(client, data.handle);  		if (copy_to_user((void __user *)arg, &data, sizeof(data)))  			return -EFAULT;  		if (data.fd < 0) |