This commit was manufactured by cvs2svn to create tag
[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 "linux/signal.h"
10 #include "linux/interrupt.h"
11 #include "init.h"
12 #include "sigio.h"
13 #include "irq_user.h"
14 #include "irq_kern.h"
15
16 /* Protected by sigio_lock() called from write_sigio_workaround */
17 static int sigio_irq_fd = -1;
18
19 irqreturn_t sigio_interrupt(int irq, void *data, struct pt_regs *unused)
20 {
21         read_sigio_fd(sigio_irq_fd);
22         reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
23         return(IRQ_HANDLED);
24 }
25
26 int write_sigio_irq(int fd)
27 {
28         if(um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
29                           SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio", 
30                           NULL)){
31                 printk("write_sigio_irq : um_request_irq failed\n");
32                 return(-1);
33         }
34         sigio_irq_fd = fd;
35         return(0);
36 }
37
38 static spinlock_t sigio_spinlock = SPIN_LOCK_UNLOCKED;
39
40 void sigio_lock(void)
41 {
42         spin_lock(&sigio_spinlock);
43 }
44
45 void sigio_unlock(void)
46 {
47         spin_unlock(&sigio_spinlock);
48 }
49
50 /*
51  * Overrides for Emacs so that we follow Linus's tabbing style.
52  * Emacs will notice this stuff at the end of the file and automatically
53  * adjust the settings for this buffer only.  This must remain at the end
54  * of the file.
55  * ---------------------------------------------------------------------------
56  * Local variables:
57  * c-file-style: "linux"
58  * End:
59  */