*参照元 [#i9e7762f] #backlinks *説明 [#hfbd0fb4] -パス: [[linux-4.4.1/drivers/dma-buf/dma-buf.c]] -FIXME: これは何? --説明 **引数 [#qf8ef28c] -struct dma_buf *dmabuf -- --[[linux-4.4.1/]] -struct device *dev -- --[[linux-4.4.1/]] **返り値 [#aaf5079b] -struct dma_buf_attachment * -- **参考 [#a1ec3360] *実装 [#k584cc3e] /** * 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; - --[[linux-4.4.1/dma_buf_attachment]] if (WARN_ON(!dmabuf || !dev)) return ERR_PTR(-EINVAL); - --[[linux-4.4.1/WARN_ON()]] --[[linux-4.4.1/ERR_PTR()]] attach = kzalloc(sizeof(struct dma_buf_attachment), GFP_KERNEL); if (attach == NULL) return ERR_PTR(-ENOMEM); - --[[linux-4.4.1/kzalloc()]] attach->dev = dev; attach->dmabuf = dmabuf; mutex_lock(&dmabuf->lock); - --[[linux-4.4.1/mutex_lock()]] if (dmabuf->ops->attach) { ret = dmabuf->ops->attach(dmabuf, dev, attach); if (ret) goto err_attach; } list_add(&attach->node, &dmabuf->attachments); - --dmabuf->ops は struct dma_buf_ops 型 --[[linux-4.4.1/dma_buf_ops]] --[[linux-4.4.1/list_add()]] mutex_unlock(&dmabuf->lock); return attach; - --[[linux-4.4.1/mutex_unlock()]] err_attach: kfree(attach); mutex_unlock(&dmabuf->lock); return ERR_PTR(ret); - --[[linux-4.4.1/kfree()]] } EXPORT_SYMBOL_GPL(dma_buf_attach); *コメント [#r05057eb]