参照元

説明

引数

返り値

参考

実装

/**
 * dma_buf_attach - Add the device to dma_buf's attachments list; optionally,
 * calls attach() of dma_buf_ops to allow device-specific attach functionality
 * @dmabuf:     [in]    buffer to attach device to.
 * @dev:        [in]    device to be attached.
 *
 * Returns struct dma_buf_attachment * for this attachment; returns ERR_PTR on
 * error.
 */
struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
                                          struct device *dev)
{
        struct dma_buf_attachment *attach;
        int ret;
        if (WARN_ON(!dmabuf || !dev))
                return ERR_PTR(-EINVAL);
        attach = kzalloc(sizeof(struct dma_buf_attachment), GFP_KERNEL);
        if (attach == NULL)
                return ERR_PTR(-ENOMEM);
        attach->dev = dev;
        attach->dmabuf = dmabuf;

        mutex_lock(&dmabuf->lock);
        if (dmabuf->ops->attach) {
                ret = dmabuf->ops->attach(dmabuf, dev, attach);
                if (ret)
                        goto err_attach;
        }
        list_add(&attach->node, &dmabuf->attachments);
        mutex_unlock(&dmabuf->lock);
        return attach;
err_attach:
        kfree(attach);
        mutex_unlock(&dmabuf->lock);
        return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(dma_buf_attach);

コメント


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