*参照元 [#da7010d9]
#backlinks

*説明 [#tcdd40c0]
-パス: [[linux-4.4.1/drivers/dma-buf/dma-buf.c]]

-FIXME: これは何?
--説明


**引数 [#k08f2e3c]
-const struct dma_buf_export_info *exp_info
--
--[[linux-4.4.1/dma_buf_export_info]]


**返り値 [#g06af5a1]
-struct dma_buf *
--
--[[linux-4.4.1/dma_buf]]


**参考 [#k72722e7]


*実装 [#r1330984]
 /**
  * dma_buf_export - Creates a new dma_buf, and associates an anon file
  * with this buffer, so it can be exported.
  * Also connect the allocator specific data and ops to the buffer.
  * Additionally, provide a name string for exporter; useful in debugging.
  *
  * @exp_info:   [in]    holds all the export related information provided
  *                      by the exporter. see struct dma_buf_export_info
  *                      for further details.
  *
  * Returns, on success, a newly created dma_buf object, which wraps the
  * supplied private data and operations for dma_buf_ops. On either missing
  * ops, or error in allocating struct dma_buf, will return negative error.
  *
  */
 struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
 {
         struct dma_buf *dmabuf;
         struct reservation_object *resv = exp_info->resv;
         struct file *file;
         size_t alloc_size = sizeof(struct dma_buf);
 
-
--[[linux-4.4.1/dma_buf]]
--[[linux-4.4.1/reservation_object]]
--[[linux-4.4.1/file]]

         if (!exp_info->resv)
                 alloc_size += sizeof(struct reservation_object);
         else
                 /* prevent &dma_buf[1] == dma_buf->resv */
                 alloc_size += 1;
 
         if (WARN_ON(!exp_info->priv
                           || !exp_info->ops
                           || !exp_info->ops->map_dma_buf
                           || !exp_info->ops->unmap_dma_buf
                           || !exp_info->ops->release
                           || !exp_info->ops->kmap_atomic
                           || !exp_info->ops->kmap
                           || !exp_info->ops->mmap)) {
                 return ERR_PTR(-EINVAL);
         }
 
         if (!try_module_get(exp_info->owner))
                 return ERR_PTR(-ENOENT);
 
-
--[[linux-4.4.1/try_module_get()]]

         dmabuf = kzalloc(alloc_size, GFP_KERNEL);
         if (!dmabuf) {
                 module_put(exp_info->owner);
                 return ERR_PTR(-ENOMEM);
         }
 
-
--[[linux-4.4.1/kzalloc()]]
--[[linux-4.4.1/module_put()]]
--[[linux-4.4.1/GFP_KERNEL]]

         dmabuf->priv = exp_info->priv;
         dmabuf->ops = exp_info->ops;
         dmabuf->size = exp_info->size;
         dmabuf->exp_name = exp_info->exp_name;
         dmabuf->owner = exp_info->owner;
         init_waitqueue_head(&dmabuf->poll);
         dmabuf->cb_excl.poll = dmabuf->cb_shared.poll = &dmabuf->poll;
         dmabuf->cb_excl.active = dmabuf->cb_shared.active = 0;
 
-
--[[linux-4.4.1/init_waitqueue_head()]]
--dmabuf->cb_excl は struct dma_buf_poll_cb_t 型
--[[linux-4.4.1/dma_buf_poll_cb_t]]

         if (!resv) {
                 resv = (struct reservation_object *)&dmabuf[1];
                 reservation_object_init(resv);
         }
         dmabuf->resv = resv;
 
-
--[[linux-4.4.1/reservation_object_init()]]

         file = anon_inode_getfile("dmabuf", &dma_buf_fops, dmabuf,
                                         exp_info->flags);
         if (IS_ERR(file)) {
                 kfree(dmabuf);
                 return ERR_CAST(file);
         }
 
-
--[[linux-4.4.1/anon_inode_getfile()]]
--[[linux-4.4.1/dma_buf_fops(global)]]
--[[linux-4.4.1/IS_ERR()]]
--[[linux-4.4.1/kfree()]]
--[[linux-4.4.1/ERR_CAST()]]

         file->f_mode |= FMODE_LSEEK;
         dmabuf->file = file;
 
         mutex_init(&dmabuf->lock);
         INIT_LIST_HEAD(&dmabuf->attachments);
 
-
--[[linux-4.4.1/mutex_init()]]
--[[linux-4.4.1/INIT_LIST_HEAD()]]

         mutex_lock(&db_list.lock);
         list_add(&dmabuf->list_node, &db_list.head);
         mutex_unlock(&db_list.lock);
 
-
--[[linux-4.4.1/mutex_lock()]]
--[[linux-4.4.1/list_add()]]
--[[linux-4.4.1/mutex_unlock()]]

         return dmabuf;
 }
 EXPORT_SYMBOL_GPL(dma_buf_export);
-
--[[linux-4.4.1/EXPORT_SYMBOL_GPL()]]


*コメント [#kfb99a4f]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS