From 5aa43c056c7686174da60e72cf9c667d04220b17 Mon Sep 17 00:00:00 2001 From: Jeff Hartmann Date: Mon, 10 Apr 2000 16:04:56 +0000 Subject: [PATCH] Created a seperate fops structure so that the code only changes mmap for the file its operating on --- linux-core/i810_dma.c | 17 +++++++++++++++-- linux-core/i810_drv.h | 1 + linux/i810_dma.c | 17 +++++++++++++++-- linux/i810_drv.h | 1 + 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/linux-core/i810_dma.c b/linux-core/i810_dma.c index 90c7eb15..c940f5cd 100644 --- a/linux-core/i810_dma.c +++ b/linux-core/i810_dma.c @@ -138,6 +138,17 @@ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf) return 0; } +static struct file_operations i810_buffer_fops = { + open: i810_open, + flush: drm_flush, + release: i810_release, + ioctl: i810_ioctl, + mmap: i810_mmap_buffers, + read: drm_read, + fasync: drm_fasync, + poll: drm_poll, +}; + int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma) { vma->vm_flags |= VM_IO; @@ -152,15 +163,17 @@ static int i810_map_buffer(drm_buf_t *buf, struct file *filp) { drm_i810_buf_priv_t *buf_priv = buf->dev_private; int retcode = 0; + struct file_operations *old_fops; if(buf_priv->currently_mapped == I810_BUF_MAPPED) return -EINVAL; down(¤t->mm->mmap_sem); - filp->f_op->mmap = i810_mmap_buffers; + old_fops = filp->f_op; + filp->f_op = &i810_buffer_fops; buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total, PROT_READ|PROT_WRITE, MAP_SHARED, buf->bus_address); - filp->f_op->mmap = drm_mmap; + filp->f_op = old_fops; if ((unsigned long)buf_priv->virtual > -1024UL) { /* Real error */ DRM_DEBUG("mmap error\n"); diff --git a/linux-core/i810_drv.h b/linux-core/i810_drv.h index a4e4d6c7..e775d1b6 100644 --- a/linux-core/i810_drv.h +++ b/linux-core/i810_drv.h @@ -86,6 +86,7 @@ extern int i810_flush_ioctl(struct inode *inode, struct file *filp, extern void i810_reclaim_buffers(drm_device_t *dev, pid_t pid); extern int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); +extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma); /* i810_bufs.c */ diff --git a/linux/i810_dma.c b/linux/i810_dma.c index 90c7eb15..c940f5cd 100644 --- a/linux/i810_dma.c +++ b/linux/i810_dma.c @@ -138,6 +138,17 @@ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf) return 0; } +static struct file_operations i810_buffer_fops = { + open: i810_open, + flush: drm_flush, + release: i810_release, + ioctl: i810_ioctl, + mmap: i810_mmap_buffers, + read: drm_read, + fasync: drm_fasync, + poll: drm_poll, +}; + int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma) { vma->vm_flags |= VM_IO; @@ -152,15 +163,17 @@ static int i810_map_buffer(drm_buf_t *buf, struct file *filp) { drm_i810_buf_priv_t *buf_priv = buf->dev_private; int retcode = 0; + struct file_operations *old_fops; if(buf_priv->currently_mapped == I810_BUF_MAPPED) return -EINVAL; down(¤t->mm->mmap_sem); - filp->f_op->mmap = i810_mmap_buffers; + old_fops = filp->f_op; + filp->f_op = &i810_buffer_fops; buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total, PROT_READ|PROT_WRITE, MAP_SHARED, buf->bus_address); - filp->f_op->mmap = drm_mmap; + filp->f_op = old_fops; if ((unsigned long)buf_priv->virtual > -1024UL) { /* Real error */ DRM_DEBUG("mmap error\n"); diff --git a/linux/i810_drv.h b/linux/i810_drv.h index a4e4d6c7..e775d1b6 100644 --- a/linux/i810_drv.h +++ b/linux/i810_drv.h @@ -86,6 +86,7 @@ extern int i810_flush_ioctl(struct inode *inode, struct file *filp, extern void i810_reclaim_buffers(drm_device_t *dev, pid_t pid); extern int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); +extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma); /* i810_bufs.c */