参照元

説明

引数

返り値

参考

実装

static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size,
                          enum dma_data_direction dma_dir, gfp_t gfp_flags)
{
        struct vb2_dc_conf *conf = alloc_ctx;
        struct device *dev = conf->dev;
        struct vb2_dc_buf *buf;
        buf = kzalloc(sizeof *buf, GFP_KERNEL);
        if (!buf)
                return ERR_PTR(-ENOMEM);
        buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr,
                                                GFP_KERNEL | gfp_flags);
        if (!buf->vaddr) {
                dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size);
                kfree(buf);
                return ERR_PTR(-ENOMEM);
        }
        /* Prevent the device from being released while the buffer is used */
        buf->dev = get_device(dev);
        buf->size = size;
        buf->dma_dir = dma_dir;

        buf->handler.refcount = &buf->refcount;
        buf->handler.put = vb2_dc_put;
        buf->handler.arg = buf;
        atomic_inc(&buf->refcount);
        return buf;
}

コメント


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