@@ -312,11 +312,6 @@ static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
/* DMABUF ops for exporters */
/*********************************************/
-struct vb2_dc_attachment {
- struct sg_table sgt;
- enum dma_data_direction dir;
-};
-
static int vb2_dc_dmabuf_ops_attach(struct dma_buf *dbuf, struct device *dev,
struct dma_buf_attachment *dbuf_attach)
{
@@ -327,17 +322,13 @@ static int vb2_dc_dmabuf_ops_attach(struct dma_buf *dbuf, struct device *dev,
static void vb2_dc_dmabuf_ops_detach(struct dma_buf *dbuf,
struct dma_buf_attachment *db_attach)
{
- struct vb2_dc_attachment *attach = db_attach->priv;
- struct sg_table *sgt;
+ struct sg_table *sgt = db_attach->priv;
- if (!attach)
+ if (!sgt)
return;
- sgt = &attach->sgt;
-
- dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->nents, attach->dir);
sg_free_table(sgt);
- kfree(attach);
+ kfree(sgt);
db_attach->priv = NULL;
}
@@ -346,26 +337,22 @@ static struct sg_table *vb2_dc_dmabuf_ops_map(
{
struct dma_buf *dbuf = db_attach->dmabuf;
struct vb2_dc_buf *buf = dbuf->priv;
- struct vb2_dc_attachment *attach = db_attach->priv;
- struct sg_table *sgt;
+ struct sg_table *sgt = db_attach->priv;
struct scatterlist *rd, *wr;
int i, ret;
/* return previously mapped sg table */
- if (attach)
- return &attach->sgt;
+ if (sgt)
+ return sgt;
- attach = kzalloc(sizeof *attach, GFP_KERNEL);
- if (!attach)
+ sgt = kzalloc(sizeof *sgt, GFP_KERNEL);
+ if (!sgt)
return ERR_PTR(-ENOMEM);
- sgt = &attach->sgt;
- attach->dir = dir;
-
/* copying the buf->base_sgt to attachment */
ret = sg_alloc_table(sgt, buf->sgt_base->orig_nents, GFP_KERNEL);
if (ret) {
- kfree(attach);
+ kfree(sgt);
return ERR_PTR(-ENOMEM);
}
@@ -377,16 +364,7 @@ static struct sg_table *vb2_dc_dmabuf_ops_map(
wr = sg_next(wr);
}
- /* mapping new sglist to the client */
- ret = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents, dir);
- if (ret <= 0) {
- printk(KERN_ERR "failed to map scatterlist\n");
- sg_free_table(sgt);
- kfree(attach);
- return ERR_PTR(-EIO);
- }
-
- db_attach->priv = attach;
+ db_attach->priv = sgt;
return sgt;
}