aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/dma-buf.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index 1e16cbd61da2..cfe1d8bc7bb8 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -251,9 +251,8 @@ EXPORT_SYMBOL_GPL(dma_buf_put);
251 * @dmabuf: [in] buffer to attach device to. 251 * @dmabuf: [in] buffer to attach device to.
252 * @dev: [in] device to be attached. 252 * @dev: [in] device to be attached.
253 * 253 *
254 * Returns struct dma_buf_attachment * for this attachment; may return negative 254 * Returns struct dma_buf_attachment * for this attachment; returns ERR_PTR on
255 * error codes. 255 * error.
256 *
257 */ 256 */
258struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf, 257struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
259 struct device *dev) 258 struct device *dev)
@@ -319,9 +318,8 @@ EXPORT_SYMBOL_GPL(dma_buf_detach);
319 * @attach: [in] attachment whose scatterlist is to be returned 318 * @attach: [in] attachment whose scatterlist is to be returned
320 * @direction: [in] direction of DMA transfer 319 * @direction: [in] direction of DMA transfer
321 * 320 *
322 * Returns sg_table containing the scatterlist to be returned; may return NULL 321 * Returns sg_table containing the scatterlist to be returned; returns ERR_PTR
323 * or ERR_PTR. 322 * on error.
324 *
325 */ 323 */
326struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach, 324struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
327 enum dma_data_direction direction) 325 enum dma_data_direction direction)
@@ -334,6 +332,8 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
334 return ERR_PTR(-EINVAL); 332 return ERR_PTR(-EINVAL);
335 333
336 sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction); 334 sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
335 if (!sg_table)
336 sg_table = ERR_PTR(-ENOMEM);
337 337
338 return sg_table; 338 return sg_table;
339} 339}
@@ -544,6 +544,8 @@ EXPORT_SYMBOL_GPL(dma_buf_mmap);
544 * These calls are optional in drivers. The intended use for them 544 * These calls are optional in drivers. The intended use for them
545 * is for mapping objects linear in kernel space for high use objects. 545 * is for mapping objects linear in kernel space for high use objects.
546 * Please attempt to use kmap/kunmap before thinking about these interfaces. 546 * Please attempt to use kmap/kunmap before thinking about these interfaces.
547 *
548 * Returns NULL on error.
547 */ 549 */
548void *dma_buf_vmap(struct dma_buf *dmabuf) 550void *dma_buf_vmap(struct dma_buf *dmabuf)
549{ 551{
@@ -566,7 +568,9 @@ void *dma_buf_vmap(struct dma_buf *dmabuf)
566 BUG_ON(dmabuf->vmap_ptr); 568 BUG_ON(dmabuf->vmap_ptr);
567 569
568 ptr = dmabuf->ops->vmap(dmabuf); 570 ptr = dmabuf->ops->vmap(dmabuf);
569 if (IS_ERR_OR_NULL(ptr)) 571 if (WARN_ON_ONCE(IS_ERR(ptr)))
572 ptr = NULL;
573 if (!ptr)
570 goto out_unlock; 574 goto out_unlock;
571 575
572 dmabuf->vmap_ptr = ptr; 576 dmabuf->vmap_ptr = ptr;