/**
* struct ion_device - the metadata of the ion device node
* @dev: the actual misc device
+ * @pdev: the device from platform
* @buffers: an rb tree of all the existing buffers
* @buffer_lock: lock protecting the tree of buffers
* @lock: rwsem protecting the tree of heaps and clients
*/
struct ion_device {
struct miscdevice dev;
+ struct device *pdev;
struct rb_root buffers;
struct mutex buffer_lock;
struct rw_semaphore lock;
{
struct dma_buf *dmabuf;
struct ion_buffer *buffer;
+ struct ion_device *idev = client->dev;
+ struct device *dev = ion_device_get_platform(idev);
dmabuf = dma_buf_get(fd);
if (IS_ERR(dmabuf))
}
buffer = dmabuf->priv;
- dma_sync_sg_for_device(NULL, buffer->sg_table->sgl,
+ dma_sync_sg_for_device(dev, buffer->sg_table->sgl,
buffer->sg_table->nents, DMA_BIDIRECTIONAL);
dma_buf_put(dmabuf);
return 0;
}
EXPORT_SYMBOL(ion_device_add_heap);
+struct device *ion_device_get_platform(struct ion_device *idev)
+{
+ if (!idev)
+ return NULL;
+
+ return idev->pdev;
+}
+
+void ion_device_set_platform(struct ion_device *idev, struct device *dev)
+{
+ if (dev && !idev->pdev)
+ idev->pdev = dev;
+}
+
struct ion_device *ion_device_create(long (*custom_ioctl)
(struct ion_client *client,
unsigned int cmd,
struct ion_platform_heap *heaps;
};
+struct device *ion_device_get_platform(struct ion_device *idev);
+
+void ion_device_set_platform(struct ion_device *idev,
+ struct device *dev);
+
/**
* ion_reserve() - reserve memory for ion heaps if applicable
* @data: platform data specifying starting physical address and