aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/dma-buf.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index 965833acf0d2..198edd8a9f0a 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -185,7 +185,7 @@ struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
185 struct dma_buf_attachment *attach; 185 struct dma_buf_attachment *attach;
186 int ret; 186 int ret;
187 187
188 if (WARN_ON(!dmabuf || !dev || !dmabuf->ops)) 188 if (WARN_ON(!dmabuf || !dev))
189 return ERR_PTR(-EINVAL); 189 return ERR_PTR(-EINVAL);
190 190
191 attach = kzalloc(sizeof(struct dma_buf_attachment), GFP_KERNEL); 191 attach = kzalloc(sizeof(struct dma_buf_attachment), GFP_KERNEL);
@@ -224,7 +224,7 @@ EXPORT_SYMBOL_GPL(dma_buf_attach);
224 */ 224 */
225void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach) 225void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
226{ 226{
227 if (WARN_ON(!dmabuf || !attach || !dmabuf->ops)) 227 if (WARN_ON(!dmabuf || !attach))
228 return; 228 return;
229 229
230 mutex_lock(&dmabuf->lock); 230 mutex_lock(&dmabuf->lock);
@@ -255,12 +255,11 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
255 255
256 might_sleep(); 256 might_sleep();
257 257
258 if (WARN_ON(!attach || !attach->dmabuf || !attach->dmabuf->ops)) 258 if (WARN_ON(!attach || !attach->dmabuf))
259 return ERR_PTR(-EINVAL); 259 return ERR_PTR(-EINVAL);
260 260
261 mutex_lock(&attach->dmabuf->lock); 261 mutex_lock(&attach->dmabuf->lock);
262 if (attach->dmabuf->ops->map_dma_buf) 262 sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
263 sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
264 mutex_unlock(&attach->dmabuf->lock); 263 mutex_unlock(&attach->dmabuf->lock);
265 264
266 return sg_table; 265 return sg_table;
@@ -278,13 +277,11 @@ EXPORT_SYMBOL_GPL(dma_buf_map_attachment);
278void dma_buf_unmap_attachment(struct dma_buf_attachment *attach, 277void dma_buf_unmap_attachment(struct dma_buf_attachment *attach,
279 struct sg_table *sg_table) 278 struct sg_table *sg_table)
280{ 279{
281 if (WARN_ON(!attach || !attach->dmabuf || !sg_table 280 if (WARN_ON(!attach || !attach->dmabuf || !sg_table))
282 || !attach->dmabuf->ops))
283 return; 281 return;
284 282
285 mutex_lock(&attach->dmabuf->lock); 283 mutex_lock(&attach->dmabuf->lock);
286 if (attach->dmabuf->ops->unmap_dma_buf) 284 attach->dmabuf->ops->unmap_dma_buf(attach, sg_table);
287 attach->dmabuf->ops->unmap_dma_buf(attach, sg_table);
288 mutex_unlock(&attach->dmabuf->lock); 285 mutex_unlock(&attach->dmabuf->lock);
289 286
290} 287}