Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.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 | static 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 | int err; |
| 29 | |
| 30 | err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt, |
| 31 | SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio", |
| 32 | NULL); |
| 33 | if(err){ |
| 34 | printk("write_sigio_irq : um_request_irq failed, err = %d\n", |
| 35 | err); |
| 36 | return(-1); |
| 37 | } |
| 38 | sigio_irq_fd = fd; |
| 39 | return(0); |
| 40 | } |
| 41 | |
| 42 | static DEFINE_SPINLOCK(sigio_spinlock); |
| 43 | |
| 44 | void sigio_lock(void) |
| 45 | { |
| 46 | spin_lock(&sigio_spinlock); |
| 47 | } |
| 48 | |
| 49 | void sigio_unlock(void) |
| 50 | { |
| 51 | spin_unlock(&sigio_spinlock); |
| 52 | } |
| 53 | |
| 54 | /* |
| 55 | * Overrides for Emacs so that we follow Linus's tabbing style. |
| 56 | * Emacs will notice this stuff at the end of the file and automatically |
| 57 | * adjust the settings for this buffer only. This must remain at the end |
| 58 | * of the file. |
| 59 | * --------------------------------------------------------------------------- |
| 60 | * Local variables: |
| 61 | * c-file-style: "linux" |
| 62 | * End: |
| 63 | */ |