patch-2.4.0-test3 linux/drivers/sgi/char/shmiq.c
Next file: linux/drivers/sgi/char/streamable.c
Previous file: linux/drivers/sgi/char/sgiserial.c
Back to the patch index
Back to the overall index
- Lines: 151
- Date:
Sun Jul 9 22:32:58 2000
- Orig file:
v2.4.0-test2/linux/drivers/sgi/char/shmiq.c
- Orig date:
Fri Jun 23 21:55:10 2000
diff -u --recursive --new-file v2.4.0-test2/linux/drivers/sgi/char/shmiq.c linux/drivers/sgi/char/shmiq.c
@@ -1,4 +1,4 @@
-/* $Id: shmiq.c,v 1.20 2000/02/24 00:13:10 ralf Exp $
+/* $Id: shmiq.c,v 1.19 2000/02/23 00:41:21 ralf Exp $
*
* shmiq.c: shared memory input queue driver
* written 1997 Miguel de Icaza (miguel@nuclecu.unam.mx)
@@ -56,6 +56,7 @@
#include <linux/devfs_fs_kernel.h>
#include <asm/shmiq.h>
+#include <asm/gfx.h>
#include <asm/mman.h>
#include <asm/uaccess.h>
#include <asm/poll.h>
@@ -236,8 +237,8 @@
}
return -EINVAL;
+
bad_file:
- unlock_kernel ();
return -EBADF;
}
@@ -250,51 +251,62 @@
struct vm_area_struct *vma;
int v;
- switch (cmd){
+ switch (cmd) {
/*
* The address space is already mapped as a /dev/zero
* mapping. FIXME: check that /dev/zero is what the user
* had mapped before :-)
*/
- case QIOCATTACH: {
- unsigned long vaddr;
- int s;
-
- v = verify_area (VERIFY_READ, (void *) arg, sizeof (struct shmiqreq));
- if (v)
- return v;
- if (copy_from_user (&req, (void *) arg, sizeof (req)))
- return -EFAULT;
- /* Do not allow to attach to another region if it has been already attached */
- if (shmiqs [minor].mapped){
- printk ("SHMIQ:The thingie is already mapped\n");
- return -EINVAL;
- }
+ case QIOCATTACH: {
+ unsigned long vaddr;
+ int s;
+
+ v = verify_area (VERIFY_READ, (void *) arg,
+ sizeof (struct shmiqreq));
+ if (v)
+ return v;
+ if (copy_from_user(&req, (void *) arg, sizeof (req)))
+ return -EFAULT;
+ /*
+ * Do not allow to attach to another region if it has
+ * already been attached
+ */
+ if (shmiqs [minor].mapped) {
+ printk("SHMIQ:The thingie is already mapped\n");
+ return -EINVAL;
+ }
+
+ vaddr = (unsigned long) req.user_vaddr;
+ vma = find_vma (current->mm, vaddr);
+ if (!vma) {
+ printk ("SHMIQ: could not find %lx the vma\n",
+ vaddr);
+ return -EINVAL;
+ }
+ s = req.arg * sizeof (struct shmqevent) +
+ sizeof (struct sharedMemoryInputQueue);
+ v = sys_munmap (vaddr, s);
+ down(¤t->mm->mmap_sem);
+ do_munmap(current->mm, vaddr, s);
+ do_mmap(filp, vaddr, s, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE|MAP_FIXED, 0);
+ up(¤t->mm->mmap_sem);
+ shmiqs[minor].events = req.arg;
+ shmiqs[minor].mapped = 1;
- vaddr = (unsigned long) req.user_vaddr;
- vma = find_vma (current->mm, vaddr);
- if (!vma){
- printk ("SHMIQ: could not find %lx the vma\n", vaddr);
- return -EINVAL;
+ return 0;
}
- s = req.arg * sizeof (struct shmqevent) + sizeof (struct sharedMemoryInputQueue);
- down(¤t->mm->mmap_sem);
- do_munmap (current->mm, vaddr, s);
- do_mmap (filp, vaddr, s, PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 0);
- up(¤t->mm->mmap_sem);
- shmiqs [minor].events = req.arg;
- shmiqs [minor].mapped = 1;
- return 0;
- }
}
+
return -EINVAL;
}
-unsigned long
-shmiq_nopage (struct vm_area_struct *vma, unsigned long address, int write_access)
+struct page *
+shmiq_nopage (struct vm_area_struct *vma, unsigned long address,
+ int write_access)
{
/* Do not allow for mremap to expand us */
- return 0;
+ return NULL;
}
static struct vm_operations_struct qcntl_mmap = {
@@ -336,14 +348,12 @@
return error;
}
-
+
static int
shmiq_qcntl_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
{
int minor = MINOR (inode->i_rdev);
- lock_kernel ();
-
if (minor-- == 0)
return shmiq_ioctl (inode, filp, cmd, arg);
@@ -387,6 +397,7 @@
shmiqs [minor].opened = 1;
shmiqs [minor].shmiq_vaddr = 0;
unlock_kernel ();
+
return 0;
}
@@ -427,6 +438,7 @@
vfree (shmiqs [minor].shmiq_vaddr);
shmiqs [minor].shmiq_vaddr = 0;
unlock_kernel ();
+
return 0;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)