struct mem_handle *nvhost_dmabuf_get(u32 id, struct nvhost_device *dev) { struct mem_handle *h; struct dma_buf *buf; buf = dma_buf_get(to_dmabuf_fd(id)); if (IS_ERR_OR_NULL(buf)) return (struct mem_handle *)buf; else { h = (struct mem_handle *)dma_buf_attach(buf, &dev->dev); if (IS_ERR_OR_NULL(h)) dma_buf_put(buf); } return (struct mem_handle *) ((u32)h | mem_mgr_type_dmabuf); }
struct mem_handle *nvhost_dmabuf_get(ulong id, struct platform_device *dev) { struct mem_handle *h; struct dma_buf *buf; buf = dma_buf_get(to_dmabuf_fd(id)); if (IS_ERR(buf)) return (struct mem_handle *)buf; else { h = (struct mem_handle *)dma_buf_attach(buf, &dev->dev); if (IS_ERR(h)) { dma_buf_put(buf); return (struct mem_handle *)h; } } return (struct mem_handle *) ((uintptr_t)h | mem_mgr_type_dmabuf); }