ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / um / kernel / sigio_kern.c
1 /* 
2  * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
6 #include "linux/kernel.h"
7 #include "linux/list.h"
8 #include "linux/slab.h"
9 #include "asm/irq.h"
10 #include "init.h"
11 #include "sigio.h"
12 #include "irq_user.h"
13
14 /* Protected by sigio_lock() called from write_sigio_workaround */
15 static int sigio_irq_fd = -1;
16
17 void sigio_interrupt(int irq, void *data, struct pt_regs *unused)
18 {
19         read_sigio_fd(sigio_irq_fd);
20         reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
21 }
22
23 int write_sigio_irq(int fd)
24 {
25         if(um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
26                           SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio", 
27                           NULL)){
28                 printk("write_sigio_irq : um_request_irq failed\n");
29                 return(-1);
30         }
31         sigio_irq_fd = fd;
32         return(0);
33 }
34
35 static spinlock_t sigio_spinlock = SPIN_LOCK_UNLOCKED;
36
37 void sigio_lock(void)
38 {
39         spin_lock(&sigio_spinlock);
40 }
41
42 void sigio_unlock(void)
43 {
44         spin_unlock(&sigio_spinlock);
45 }
46
47 /*
48  * Overrides for Emacs so that we follow Linus's tabbing style.
49  * Emacs will notice this stuff at the end of the file and automatically
50  * adjust the settings for this buffer only.  This must remain at the end
51  * of the file.
52  * ---------------------------------------------------------------------------
53  * Local variables:
54  * c-file-style: "linux"
55  * End:
56  */