*参照元 [#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 given vma * @dmabuf: [in] buffer that should back the vma * @vma: [in] vma for the mmap * @pgoff: [in] offset in pages where this mmap should start within the * dma-buf buffer. * * This function adjusts the passed in vma so that it points at the file of the * dma_buf operation. It also adjusts the starting pgoff and does bounds * checking on the size of the vma. Then it calls the exporters mmap function to * set up the mapping. * * Can return negative error values, returns 0 on success. */ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma, 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) >> PAGE_SHIFT) < pgoff) return -EOVERFLOW; /* check for overflowing the buffer's size */ if (pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) > 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]