linux-4.4.1/dma_buf_mmap()
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*参照元 [#qfd606cb]
#backlinks
*説明 [#r7de1183]
-パス: [[linux-4.4.1/drivers/dma-buf/dma-buf.c]]
-FIXME: これは何?
--説明
**引数 [#y71ca7cf]
-struct dma_buf *dmabuf
--
--[[linux-4.4.1/dma_buf]]
-struct vm_area_struct *vma
--
--[[linux-4.4.1/vm_area_struct]]
-unsigned long pgoff
--
**返り値 [#df6ad0de]
-int
--
**参考 [#kad05712]
*実装 [#k001e9c6]
/**
* dma_buf_mmap - Setup up a userspace mmap with the giv...
* @dmabuf: [in] buffer that should back the vma
* @vma: [in] vma for the mmap
* @pgoff: [in] offset in pages where this mmap ...
* dma-buf buffer.
*
* This function adjusts the passed in vma so that it po...
* dma_buf operation. It also adjusts the starting pgoff...
* checking on the size of the vma. Then it calls the ex...
* set up the mapping.
*
* Can return negative error values, returns 0 on success.
*/
int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_...
unsigned long pgoff)
{
struct file *oldfile;
int ret;
-
--[[linux-4.4.1/file]]
if (WARN_ON(!dmabuf || !vma))
return -EINVAL;
-
--[[linux-4.4.1/WARN_ON()]]
/* check for offset overflow */
if (pgoff + ((vma->vm_end - vma->vm_start) >> PA...
return -EOVERFLOW;
/* check for overflowing the buffer's size */
if (pgoff + ((vma->vm_end - vma->vm_start) >> PA...
dmabuf->size >> PAGE_SHIFT)
return -EINVAL;
-
--[[linux-4.4.1/PAGE_SHIFT]]
/* readjust the vma */
get_file(dmabuf->file);
oldfile = vma->vm_file;
vma->vm_file = dmabuf->file;
vma->vm_pgoff = pgoff;
-
--[[linux-4.4.1/get_file()]]
ret = dmabuf->ops->mmap(dmabuf, vma);
if (ret) {
/* restore old parameters on failure */
vma->vm_file = oldfile;
fput(dmabuf->file);
} else {
if (oldfile)
fput(oldfile);
}
-
--dmabuf->ops は const struct dma_buf_ops * 型
--[[linux-4.4.1/dma_buf_ops]]
--[[linux-4.4.1/fput()]]
return ret;
}
EXPORT_SYMBOL_GPL(dma_buf_mmap);
-
--[[linux-4.4.1/EXPORT_SYMBOL_GPL()]]
*コメント [#iab1562a]
終了行:
*参照元 [#qfd606cb]
#backlinks
*説明 [#r7de1183]
-パス: [[linux-4.4.1/drivers/dma-buf/dma-buf.c]]
-FIXME: これは何?
--説明
**引数 [#y71ca7cf]
-struct dma_buf *dmabuf
--
--[[linux-4.4.1/dma_buf]]
-struct vm_area_struct *vma
--
--[[linux-4.4.1/vm_area_struct]]
-unsigned long pgoff
--
**返り値 [#df6ad0de]
-int
--
**参考 [#kad05712]
*実装 [#k001e9c6]
/**
* dma_buf_mmap - Setup up a userspace mmap with the giv...
* @dmabuf: [in] buffer that should back the vma
* @vma: [in] vma for the mmap
* @pgoff: [in] offset in pages where this mmap ...
* dma-buf buffer.
*
* This function adjusts the passed in vma so that it po...
* dma_buf operation. It also adjusts the starting pgoff...
* checking on the size of the vma. Then it calls the ex...
* set up the mapping.
*
* Can return negative error values, returns 0 on success.
*/
int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_...
unsigned long pgoff)
{
struct file *oldfile;
int ret;
-
--[[linux-4.4.1/file]]
if (WARN_ON(!dmabuf || !vma))
return -EINVAL;
-
--[[linux-4.4.1/WARN_ON()]]
/* check for offset overflow */
if (pgoff + ((vma->vm_end - vma->vm_start) >> PA...
return -EOVERFLOW;
/* check for overflowing the buffer's size */
if (pgoff + ((vma->vm_end - vma->vm_start) >> PA...
dmabuf->size >> PAGE_SHIFT)
return -EINVAL;
-
--[[linux-4.4.1/PAGE_SHIFT]]
/* readjust the vma */
get_file(dmabuf->file);
oldfile = vma->vm_file;
vma->vm_file = dmabuf->file;
vma->vm_pgoff = pgoff;
-
--[[linux-4.4.1/get_file()]]
ret = dmabuf->ops->mmap(dmabuf, vma);
if (ret) {
/* restore old parameters on failure */
vma->vm_file = oldfile;
fput(dmabuf->file);
} else {
if (oldfile)
fput(oldfile);
}
-
--dmabuf->ops は const struct dma_buf_ops * 型
--[[linux-4.4.1/dma_buf_ops]]
--[[linux-4.4.1/fput()]]
return ret;
}
EXPORT_SYMBOL_GPL(dma_buf_mmap);
-
--[[linux-4.4.1/EXPORT_SYMBOL_GPL()]]
*コメント [#iab1562a]
ページ名: