参照元

説明

引数

返り値

参考

実装

static int vb2_dc_dmabuf_ops_attach(struct dma_buf *dbuf, struct device *dev,
        struct dma_buf_attachment *dbuf_attach)
{
        struct vb2_dc_attachment *attach;
        unsigned int i;
        struct scatterlist *rd, *wr;
        struct sg_table *sgt;
        struct vb2_dc_buf *buf = dbuf->priv;
        int ret;
        attach = kzalloc(sizeof(*attach), GFP_KERNEL);
        if (!attach)
                return -ENOMEM;
        sgt = &attach->sgt;
        /* Copy the buf->base_sgt scatter list to the attachment, as we can't
         * map the same scatter list to multiple attachments at the same time.
         */
        ret = sg_alloc_table(sgt, buf->sgt_base->orig_nents, GFP_KERNEL);
        if (ret) {
                kfree(attach);
                return -ENOMEM;
        }
        rd = buf->sgt_base->sgl;
        wr = sgt->sgl;
        for (i = 0; i < sgt->orig_nents; ++i) {
                sg_set_page(wr, sg_page(rd), rd->length, rd->offset);
                rd = sg_next(rd);
                wr = sg_next(wr);
        }
        attach->dma_dir = DMA_NONE;
        dbuf_attach->priv = attach;

        return 0;
}

コメント


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-02-08 (月) 12:58:25