Skip to content
Snippets Groups Projects
Select Git revision
  • 33ea2dcb39ba50b0b69d1b1dc24702f084b46411
  • master default protected
  • android-msm-bullhead-3.10-nougat_kgdb_less_changes
  • android-msm-bullhead-3.10-nougat_kgdb
  • android-msm-bullhead-3.10-nougat_klist
  • android-4.4
  • android-msm-vega-4.4-oreo-daydream
  • android-msm-wahoo-4.4-p-preview-5
  • android-msm-wahoo-4.4-pie
  • android-msm-marlin-3.18-p-preview-5
  • android-msm-marlin-3.18-pie
  • android-msm-wahoo-2018.07-oreo-m2
  • android-msm-wahoo-2018.07-oreo-m4
  • android-msm-wahoo-4.4-p-preview-4
  • android-msm-bullhead-3.10-oreo-m6
  • android-msm-angler-3.10-oreo-m6
  • android-msm-marlin-3.18-p-preview-4
  • android-msm-stargazer-3.18-oreo-wear-dr
  • android-msm-catshark-3.18-oreo-wear-dr
  • android-msm-wahoo-4.4-oreo-m2
  • android-msm-wahoo-4.4-oreo-m4
  • android-daydreamos-8.0.0_r0.5
  • android-8.1.0_r0.92
  • android-8.1.0_r0.91
  • android-daydreamos-8.0.0_r0.4
  • android-p-preview-5_r0.2
  • android-p-preview-5_r0.1
  • android-9.0.0_r0.5
  • android-9.0.0_r0.4
  • android-9.0.0_r0.2
  • android-9.0.0_r0.1
  • android-8.1.0_r0.81
  • android-8.1.0_r0.80
  • android-8.1.0_r0.78
  • android-8.1.0_r0.76
  • android-8.1.0_r0.75
  • android-8.1.0_r0.72
  • android-8.1.0_r0.70
  • android-p-preview-4_r0.2
  • android-p-preview-4_r0.1
  • android-wear-8.0.0_r0.30
41 results

dma-buf.c

Blame
  • dma-buf.c 7.36 KiB
    /*
     * Framework for buffer objects that can be shared across devices/subsystems.
     *
     * Copyright(C) 2011 Linaro Limited. All rights reserved.
     * Author: Sumit Semwal <sumit.semwal@ti.com>
     *
     * Many thanks to linaro-mm-sig list, and specially
     * Arnd Bergmann <arnd@arndb.de>, Rob Clark <rob@ti.com> and
     * Daniel Vetter <daniel@ffwll.ch> for their support in creation and
     * refining of this idea.
     *
     * This program is free software; you can redistribute it and/or modify it
     * under the terms of the GNU General Public License version 2 as published by
     * the Free Software Foundation.
     *
     * This program is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
     * more details.
     *
     * You should have received a copy of the GNU General Public License along with
     * this program.  If not, see <http://www.gnu.org/licenses/>.
     */
    
    #include <linux/fs.h>
    #include <linux/slab.h>
    #include <linux/dma-buf.h>
    #include <linux/anon_inodes.h>
    #include <linux/export.h>
    
    static inline int is_dma_buf_file(struct file *);
    
    static int dma_buf_release(struct inode *inode, struct file *file)
    {
    	struct dma_buf *dmabuf;
    
    	if (!is_dma_buf_file(file))
    		return -EINVAL;
    
    	dmabuf = file->private_data;
    
    	dmabuf->ops->release(dmabuf);
    	kfree(dmabuf);
    	return 0;
    }
    
    static const struct file_operations dma_buf_fops = {
    	.release	= dma_buf_release,
    };
    
    /*
     * is_dma_buf_file - Check if struct file* is associated with dma_buf
     */
    static inline int is_dma_buf_file(struct file *file)
    {
    	return file->f_op == &dma_buf_fops;
    }
    
    /**
     * 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.
     *
     * @priv:	[in]	Attach private data of allocator to this buffer
     * @ops:	[in]	Attach allocator-defined dma buf ops to the new buffer.
     * @size:	[in]	Size of the buffer
     * @flags:	[in]	mode flags for the file.
     *
     * Returns, on success, a newly created dma_buf object, which wraps the
     * supplied private data and operations for dma_buf_ops. On either missing